Created
September 13, 2014 03:32
-
-
Save murajun1978/d6fe3fcefd34ace08cf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
あいて = %w(ぐー ちょき ぱー) | |
じゃんけん = { :"ぐー" => 0, | |
:"ちょき" => 1, | |
:"ぱー" => 2} | |
loop do | |
print 'じゃんけん... :' | |
ぷれいやーの手 = gets.chomp | |
break if ぷれいやーの手 == 'やめる' | |
あいての手 = あいて.sample | |
puts "相手の手#{あいての手}" | |
result_num = (じゃんけん[ぷれいやーの手.to_sym] - | |
じゃんけん[あいての手.to_sym]) | |
if あいての手 == ぷれいやーの手 | |
puts 'あいこ!' | |
elsif [-1, 2].include?(result_num) | |
puts 'かち!' | |
else | |
puts 'まけ!' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment