Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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
Add Comment
Please, Sign In to add comment