Skip to content

Commit

Permalink
Added helper methods what_beats(choice) and what_gets_beaten_by(choice).
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte Büchmann authored and Malte Büchmann committed May 30, 2012
1 parent a876a17 commit 53e5622
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README
Expand Up @@ -9,6 +9,8 @@ learn(choise, opponents_choise) will be called after each contest, which will gi

You can use the method judge(choice1, choice2) to determine the winner of the result. 0 is returned on a draw, 1 if the first choice is the winner, 2 if the second choice is the winner.

You can use the helper methods what_beats(choice) and what_gets_beaten_by(choice).

Feel free to participate. Fork, write your own kickass bot and feel free to send a pull request.

Made by me and coding god nilclass.
8 changes: 8 additions & 0 deletions judge.rb
Expand Up @@ -12,4 +12,12 @@ def judge choice1, choice2
CHOICE_MAP[choice1] == choice2 ? 1 : (choice1 == choice2 ? 0 : 2)
end

def what_beats choice
what_gets_beaten_by(what_gets_beaten_by(choice))
end

def what_gets_beaten_by choice
CHOICE_MAP[choice]
end

end

0 comments on commit 53e5622

Please sign in to comment.