view myproj.rb @ 0:316a45277858 draft

init
author HIROSE Yuuji <yuuji@e.koeki-u.ac.jp>
date Tue, 17 Nov 2009 12:34:29 +0900
parents
children
line wrap: on
line source

#!/usr/bin/env ruby
srand
judge = 0
hand = %w,グー チョキ パー,
while judge == 0
  print "グーは1、チョキは2、パーは3、どれ? :"
  human = gets.to_i-1
  com   = rand(3)
  printf("ぽんっ キミ %s : %s わし\n", hand[human], hand[com])
  judge = (3+human-com) % 3
  if judge == 2
    puts "キミの勝ちだ、めで"
  elsif judge == 1
    puts "キミの負けだ、けけ"
  else
    puts "あいこでしょっ"
  end
end

yatex.org