Skip to content

Instantly share code, notes, and snippets.

@murajun1978
Created September 13, 2014 03:32
Show Gist options
  • Save murajun1978/d6fe3fcefd34ace08cf0 to your computer and use it in GitHub Desktop.
Save murajun1978/d6fe3fcefd34ace08cf0 to your computer and use it in GitHub Desktop.
あいて = %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