Back

Punto Banco - modelling a gambler - 8

Our next job is to introduce a gambler to play Punto Banco. Let's introduce a high-roller called Red Tex. He will start with £1000 and he will always bet on the player to start with, because the player will get paid at double the bet when they win whereas the bank only pays at the bet plus 19/20 of the bet. 

Q1. Modify your code as shown below. You need to start by adding an extra line to the main() function, to initialise a new variable called result, like this:

punto8b

Next, add a few extra lines to the section #check to see who won and then the code for Red Tex underneath, like this:

 

punto8
Q2. Run the program a few times. What happened? What about playing just 10 games? how about 1000?
Q3. Modify the gambler() function so that Red Tex always bets on the bank and loses money if the player wins or it is a draw. (HINT: gamblerTotal + wager + wager*19/20). Try running the program a few times again. Did Red Tex win?
Q4. Perhaps Red Tex will have more luck betting on a draw. Modify the gambler() function so that Red Tex always bets on a draw and loses money if the bank or player win. (HINT: gamblerTotal + 9*wager). Try running the program a few times again. Did Red Tex win?

Extension task
a) Perhaps Red Tex will have more luck if he can randomly select between player, bank and a draw. Modify the code to make this happen. One approach is to set up a list like we did with the cards and randomly select from it. You could have player in the list 5 times, bank in the list 5 times and a draw once.
b) The game we have written so far is one version. Another slightly different version changes what the bank must do when they have a total of 6 from two cards. In our game, we say that the bank must get a third card if the player has a 6 or a 7. Most casinos, however, say that the bank should only get a card if the player got a 6 or a 7 with 3 cards. If they got a 6 or a 7 with two cards, then the bank should not get a third card. Modify your program to take this into account.

Back