[RUBY] Simple rock-paper-scissors


puts "First goo!Rock-paper-scissors. .. .."
puts "[0] Goo [1] Choki [2] Par"

user_input = gets.to_i #Let the user choose (integer) to_i
computer = rand(3) #Random computer selection 0~2

if user_input >= 3 #Output when a number of 3 or more is selected and stop the subsequent processing
    puts "0~Please enter the number 2"
exit
end

puts "you are#{user_input}"
puts "computer is#{computer}"



if user_input == computer
    puts "This is Aiko."

elsif (user_input == 0 && computer == 1) ||
 (user_input == 1 && computer == 2) ||
 (user_input == 2 && computer == 0) 
    puts "You win"
#Describes 3 patterns of rock-paper-scissors wins and losses&&(and) ||(or)How to use

else
    puts "You lose"
    

end

#0 users~Enter 2
#judge

#1.user_input == computer_input =>Aiko
#2.user_input (Winning pattern)
#3.

#View results



Recommended Posts

Simple rock-paper-scissors
Object-oriented rock-paper-scissors
Rock-paper-scissors game
java rock-paper-scissors
Rock-paper-scissors in Java
A simple rock-paper-scissors game with JavaFX and SceneBuilder