Skip to content

Instantly share code, notes, and snippets.

@webcrafts
Created July 8, 2013 13:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save webcrafts/5948862 to your computer and use it in GitHub Desktop.
Save webcrafts/5948862 to your computer and use it in GitHub Desktop.
今日のお題のじゃんけんゲーム
# coding:utf-8
te = ["","グー","チョキ","パー"]
report = [""]
3.times do |i|
# my_te = gets.to_i
my_te = rand(3)+1
pc_te = rand(3)+1
puts "人間の手は「#{te[my_te]}」、コンピュータの手は「#{te[pc_te]}」"
if my_te == pc_te then
kekka = "あいこ"
elsif (my_te == 1 && pc_te == 2) || (my_te == 2 && pc_te == 3) || (my_te == 3 && pc_te == 1) then
kekka = "人間の勝ち"
else
kekka = "コンピュータの勝ち"
end
puts "勝敗結果は・・・「#{kekka}」です。"
report[i] = kekka
end
puts "******************************************"
puts "対戦結果は・・・"
report.size.times do |i|
puts "#{i}回戦の結果は・・・#{report[i]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment