This is a game for Dev Dev based on the gameshow "Golden balls". In the show, contestants work in pairs to earn money, but in the final round they have to choose between "share" or "steal". If both choose "split", they split the money. If one chooses "split" and the other "steal", the one who chose "steal" gets all the money. If both choose "steal", they both get nothing.
In this project, we'll play the last round with a twist. Everyone will play everyone else, and themselves 1000 times. Every time you play the same person, you'll be given the history of all the other rounds you've played together.
At the end we'll see who beat who, and who earned the most money overall.
- Clone the repo
- Run
bundle install
- Create a file in the players folder with your name
<your_name>.rb
- Add
Player.register("<your_name>") do |history| ... end
, you can see an example inrandom.rb
- Implement your strategy in the block, you'll be given the history of all the games you've played with the other player.
- Return either "share" or "steal" from the block.
- Run
bundle exec rspec
to make sure it's all working. - Open a pull request, once we're all ready we'll see who the winner is!
The format of the history is an array of hashes in the order the turns occurred, like this:
[
{
"<your_name>" => "share",
"<their_name>" => "steal"
},
{
"<your_name>" => "steal",
"<their_name>" => "share"
}
]
- If you both choose "share", you both get 2 points.
- If you both choose "steal", you both get 0 points.
- If one chooses "share" and the other "steal", the one who chose "steal" gets 3 points, and the one who chose "share" gets 0 points.