This is a group project I had to work on where we had to create a casino game and calculate all the juicy maths behind it.
The player draws a card out of a closed box. The card gets noted a put back. The player does this a total of 10 times. If the same card gets drawn twice the player loses, and if that doesn't happen, the player wins. After 3 cards drawn, the player can decide to double their bet. When the player wins, they get back double their bet, and when they lose, the casino keeps the money.
This game is based on the Birthday paradox. It sounds intuitive that you need quite a lot of people to have a 50% chance of 2 people sharing a birthday. However, you only need 23 people. The formula to calculate this is:
With the previous formula we can calculate the expected value.
Therefore, the casino approximately earns:
Let's play the game 10000 times again.
When
We can see that there is a 65.9% chance of the casuno winning 6000 or more of the 10000 games.
To play the game you have to do one of these things:
Go to releases and download the file corresponding to your OS.
You can also install the game with cargo
. Beware that you do need Rust installed.
cargo install copy-cards
If that doesn't work, or you want to build locally, here's what to do. You need Rust installed for this too.
git clone https://github.com/7ijme/copy-cards
cd copy-cards
cargo build --release
Now you can play the game, have fun!