Created
August 9, 2008 18:31
-
-
Save ivey/4694 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
# Michael Ivey's RPS entry | |
# Implements the TenutaRSB strategy, named for former | |
# Georgia Tech defensive coordinator John Tenuta | |
class JohnTenutaRSBBot | |
attr_accessor :their_plays | |
attr_accessor :do_debugging | |
def initialize | |
@their_plays = Hash.new(0) | |
end | |
def name | |
"TenutaRSB (ivey)" | |
end | |
def debug(msg) | |
puts msg if do_debugging | |
end | |
def debugging! | |
self.do_debugging = 1 | |
end | |
def play(last=nil) | |
their_plays[last] += 1 if last | |
first, second = their_plays.sort_by {|i| i[1] }.reverse[0,2].collect {|i| i[0]} | |
debug("Considering prior plays.") | |
debug("Most common play: #{first}") if first | |
debug("Second common play: #{second}") if second | |
if second | |
likely = [first,second][rand(2)] | |
elsif first | |
likely = first | |
else | |
likely = "R" | |
end | |
debug("Their likely play: #{likely}") | |
debug("Countering...") | |
case likely | |
when "R" | |
"R" | |
when "P" | |
"R" | |
when "S" | |
"R" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment