Skip to content

Instantly share code, notes, and snippets.

@ddd1600
Created June 11, 2012 23:26
Show Gist options
  • Save ddd1600/2913400 to your computer and use it in GitHub Desktop.
Save ddd1600/2913400 to your computer and use it in GitHub Desktop.
rps console -- computer versus computer
require './rps.rb'
HAND = { :rock => 1, :paper => 3, :scissors => 4 }
class ComputerVersusComputer
def doTenTimes
i=0
10.times do
i += 1
possibles = HAND.keys
a = Random.rand(possibles.length)
b = Random.rand(possibles.length)
param1 = possibles[a]
param2 = possibles[b]
puts "Game ##{i}: #{param1} versus #{param2}"
rps = RockPaperScissors.new
if param1==param2
puts "tie"
puts ""
else
puts "#{winner = rps.play(param1, param2)}wins"
puts ""
end
end
end
end
g = ComputerVersusComputer.new
g.doTenTimes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment