Rock Paper Randomize
Started cracking away at the RPS program today! Once I got over a big dumb problem it started working pretty smoothly, and I really feel like I’m getting the hang of if/elsif stuff.
I’m actually writing two separate chunks at once - the part that’s going to be the shell and while loop until the score hits 3, and the part that’s the actual Rock Paper Scissors method.
PROBLEM THE FIRST: I was getting a local variable error, even though I’d already defined player_throw outside of the method. Turns out I can’t do that, it ALL has to be inside the method. Once I just scooted player_throw = gets.chomp down two lines and into the method it started working.
PROBLEM THE SECOND: calling mutliple arguments on a method. I had a brain fart and didn’t remember that the parens are only when you’re defining a method (e.g. def rps (x, y), but then you call it as rps x, y) PROBLEM THE THIRD AND CURRENT: I can call the method, get a random result that’s checked against the player’s throw, it correctly prints whether you won, tied, or lost, and prints “you get +1 point” or “ai gets +1 point” but... I can’t make the score variables change. I *thought* I was using return properly, but even my second pass at it leaves the score at 0/0 no matter what I do. I’ll post part of my code here tomorrow after I take another crack at it. Hmmmmmm












