Skip to content

Instantly share code, notes, and snippets.

@awhit012
Created May 5, 2015 00:25
Show Gist options
  • Save awhit012/5db080d691ed79ea2d37 to your computer and use it in GitHub Desktop.
Save awhit012/5db080d691ed79ea2d37 to your computer and use it in GitHub Desktop.
Rock Paper Scissors in Ruby
MESSAGES = [
"Choose your weapon",
"Computer has chosen ",
"TIE!",
"Computer Wins",
"You Win!"
]
def run
puts MESSAGES[0]
human = gets.chomp
computer = ["rock", "paper", "scissors"].sample
puts MESSAGES[1] + " " + computer
if human == computer
puts MESSAGES[2]
run
end
case human
when "rock"
if computer == "paper"
puts MESSAGES[3]
else puts MESSAGES[4]
end
when "paper"
if computer == "scissors"
puts MESSAGES[3]
else puts MESSAGES[4]
end
when "scissors"
if computer == "rock"
puts MESSAGES[3]
else puts MESSAGES[4]
end
end
end
run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment