Guest User

Untitled

a guest
Feb 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. # Michael Ivey's RPS entry
  2. # Implements the TenutaRSB strategy, named for former
  3. # Georgia Tech defensive coordinator John Tenuta
  4.  
  5. class JohnTenutaRSBBot
  6. attr_accessor :their_plays
  7. attr_accessor :do_debugging
  8.  
  9. def initialize
  10. @their_plays = Hash.new(0)
  11. end
  12.  
  13. def name
  14. "TenutaRSB (ivey)"
  15. end
  16.  
  17. def debug(msg)
  18. puts msg if do_debugging
  19. end
  20.  
  21. def debugging!
  22. self.do_debugging = 1
  23. end
  24.  
  25. def play(last=nil)
  26. their_plays[last] += 1 if last
  27. first, second = their_plays.sort_by {|i| i[1] }.reverse[0,2].collect {|i| i[0]}
  28. debug("Considering prior plays.")
  29. debug("Most common play: #{first}") if first
  30. debug("Second common play: #{second}") if second
  31. if second
  32. likely = [first,second][rand(2)]
  33. elsif first
  34. likely = first
  35. else
  36. likely = "R"
  37. end
  38. debug("Their likely play: #{likely}")
  39. debug("Countering...")
  40. case likely
  41. when "R"
  42. "R"
  43. when "P"
  44. "R"
  45. when "S"
  46. "R"
  47. end
  48. end
  49. end
Add Comment
Please, Sign In to add comment