6
2
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.
1
I'm assuming we take no input, and I'm assuming we have to use random for the dice-rolls and bets each round? Also, how does a round look when some of the gamblers have run out of money?
– Kevin Cruijssen – 2018-08-08T09:24:36.637@KevinCruijssen useful questions, as ever :) I said it’s fine for the gamblers to always bet the same way, the die roll has to be random™️. I’ll add a broke gambler table. – AJFaraday – 2018-08-08T09:43:32.567
Does the table need to be formatted exactly as shown in the post, or does it just need to be a legible table of results? – Skidsdev – 2018-08-08T10:07:15.073
Not to be a pain, but 3:1 odds would mean either £3 bookie->punter or £1 punter->bookie. As written, when I win I bet £1 but don't pay, then get £4 back... – Phil H – 2018-08-08T10:17:20.953
@Mayube It just needs to be recognised as a table, really. – AJFaraday – 2018-08-08T10:36:21.103
@PhilH Good point, but it puts me in a quandry, I don't know if anyone's part-way through a solution at this moment in time. I concede that you're completely correct, but I'm afraid I'll have to leave the rules as they are, wrong. – AJFaraday – 2018-08-08T10:37:23.807
1@AJFaraday the only issue is it says 3:1 but the rules actually are 4:1, just change the post to say 4:1 – Skidsdev – 2018-08-08T10:38:13.967
hang on. for the die, it's a 5:1 chance – ASCII-only – 2018-08-08T22:59:54.617
"If they win their bet, £4 is transferred from the bookmaker to the gambler." This is not consistent with the example. – Peter Taylor – 2018-08-14T13:29:05.400