When you roll a die, you have a 6:1 chance of any given option.
There's a bookmaker taking bets on die rolls. He owns £20 at the start of the game.
The bookmaker offers odds of 4:1, but gamblers take it, because there's money on offer.
There are 10 gamblers. A, B, C, D, E, F, G, H, I, and J. Each gambler owns 10 pounds sterling.
Each round, the 10 gamblers each bet £1 on a die roll, if they have any money left.
- If they win their bet, £4 is transferred from the bookmaker to the gambler.
- If they lose, £1 is transferred from the gambler to the bookmaker.
The game ends in either of these conditions:
- The bookmaker runs out of money, or is in debt.
- All of the gamblers have run out of money.
We should see the result presented as a series of tables, like so:
Turn 1
Roll: 2
| | Bookie | A | B | C | D | E | F | G | H | I | J |
| Start money | 20 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 |
| Bet | n/a | 1 | 3 | 2 | 1 | 2 | 4 | 6 | 5 | 2 | 4 |
| Balance change | -2 | -1 | -1 | +3 | -1 | +3 | -1 | -1 | -1 | +3 | -1 |
| End money | 18 | 9 | 9 | 13 | 9 | 13 | 9 | 9 | 9 | 13 | 9 |
Turn 2
Roll: 4
| | Bookie | A | B | C | D | E | F | G | H | I | J |
| Start money | 18 | 9 | 9 | 13 | 9 | 13 | 9 | 9 | 9 | 13 | 3 |
| Bet | n/a | 1 | 2 | 3 | 4 | 5 | 6 | 1 | 2 | 3 | 4 |
| Balance change | +2 | -1 | -1 | -1 | +3 | -1 | -1 | -1 | -1 | -1 | +3 |
| End money | 20 | 8 | 8 | 12 | 8 | 12 | 8 | 8 | 8 | 12 | 12 |
When a gambler runs out of money, they can't bet any more. Their bet is 0.
turn 20 roll: 5
| | Bookie | A | B | C | D | E | F | G | H | I | J |
| Start money | 180 | 3 | 1 | 12 | 4 | 0 | 1 | 3 | 6 | 23 | 1 |
| Bet | n/a | 1 | 2 | 3 | 4 | 0 | 6 | 1 | 2 | 3 | 4 |
| Balance change | +2 | -1 | -1 | -1 | +3 | 0 | -1 | -1 | -1 | -1 | +3 |
| End money | 20 | 8 | 8 | 12 | 8 | 0 | 8 | 8 | 8 | 12 | 12 |
Write some code to model this game, and display the results in a table:
- Use any language
- The gamblers can change their bet each turn, always bet on the same number, all bet on the same number. As long as each turn they bet on one number from 1 to 6.
- The die roll must be a random integer from 1 to 6. Use a typical, vernacular definition of random.
- The end money from one turn is the start money of the next turn.
- The balance change for the bookie is the sum of the other balance changes.
- Each turn your program should output:
- Which turn we are on
- The resulting die roll
- The starting balance, die roll, balance change, and ending balance for the bookie and all ten gamblers, as an ascii table.
- Attempt to do so in the fewest bytes.