Skip to content

@therocketman93 /gist:11160503
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
result =['Scissors cut paper', #0
'Paper covers rock', #01
'Rock crushes lizard', #02
'Lizard poisons Spock', #03
'Spock smashes scissors', #04
'Scissors decapitate lizard', #05
'Lizard eats paper', #06
'Paper disproves Spock', #07
'Spock vaporizes rock', #08
'Rock crushes scissors'] #09
ai = ['r','p','s','l','k']
while true
puts( 'Welcome to Rock-Paper-Scissors-Lizard-Spock!'.center(line_width = 50))
puts ''
puts 'Please pick your attack by selecting the corresponding letter.'
puts ''
puts 'R: Rock'
puts 'P: Paper'
puts 'S: Scissors'
puts 'L: Lizard'
puts 'K: Spock'
player = gets.chomp
while player.downcase != 'done'
ai_rand = ai.sample
# player picks rock
if player.downcase == 'r' && ai_rand == 'l'
puts result[2] + ', you win!'
elsif player.downcase == 'r' && ai_rand == 's'
puts result[9] + ', you win!'
#rock looses
elsif player.downcase == 'r' && ai_rand == 'p'
puts result[1] + ', you loose!'
elsif player.downcase == 'r' && ai_rand == 'k'
puts result[8] + ', you loose!'
elsif player.downcase == 'r' && ai_rand == 'r'
puts 'It\'s a tie!'
end
# player picks paper
if player.downcase == 'p' && ai_rand == 'r'
puts result[1] + ', you win!'
elsif player.downcase == 'p' && ai_rand == 'k'
puts result[7] + ', you win!'
elsif player.downcase == 'p' && ai_rand == 's'
puts result[0] + ', you loose!'
elsif player.downcase == 'p' && ai_rand == 'l'
puts result[6] + ', you loose!'
elsif player.downcase == 'p' && ai_rand == 'p'
puts 'It\'s a tie!'
end
# player picks scissors
if player.downcase == 's' && ai_rand == 'p'
puts result[0] + ', you win!'
elsif player.downcase == 's' && ai_rand == 'l'
puts result[5] + ', you win!'
elsif player.downcase == 's' && ai_rand == 'k'
puts result[4] + ', you loose!'
elsif player.downcase == 's' && ai_rand == 'r'
puts result[9] + ', you loose!'
elsif player.downcase == 's' && ai_rand == 's'
puts 'It\'s a tie!'
end
# player picks lizard
if player.downcase == 'l' && ai_rand == 'k'
puts result[3] + ', you win!'
elsif player.downcase == 'l' && ai_rand == 'p'
puts result[6] + ', you win!'
elsif player.downcase == 'l' && ai_rand == 'r'
puts result[2] + ', you loose!'
elsif player.downcase == 'l' && ai_rand == 's'
puts result[5] + ', you loose!'
elsif player.downcase == 'l' && ai_rand == 'l'
puts 'It\'s a tie!'
end
# player picks spock
if player.downcase == 'k' && ai_rand == 's'
puts result[4] + ', you win!'
elsif player.downcase == 'k' && ai_rand == 'r'
puts result[8] + ', you win!'
elsif player.downcase == 'k' && ai_rand == 'l'
puts result[3] + ', you loose!'
elsif player.downcase == 'k' && ai_rand == 'p'
puts result[7] + ', you loose!'
elsif player.downcase == 'k' && ai_rand == 'k'
puts 'It\'s a tie!'
end
puts ''
puts 'press enter to play again or say "done" if you\'re finished.'
player = gets.chomp
break
end
if player.downcase == 'done'
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.