Blackjack 2

First, set the browser to Full Screen view, to give this worksheet and your code as much space as possible.

Then choose either one of the two options below:

Option 1: Start this worksheet from scratch

Option 2: Continue, or view, previous work

This worksheet is copyright © Richard Pawson 2025, and protected by the Creative Commons license: Attribution-NonCommercial-NoDerivatives 4.0 International. You may freely make and distribute copies of this worksheet as is, but if you modify this worksheet you may not distribute your modified version (outside your own teaching institution) without the author's permission. Please email the author to report errors or suggest improvements.

Step 1: load the starting code

Immediately file > auto save it to local file storage, so that changes you make are preserved.

Move onto the next step before running the program.

Notes

Total hints used: /

Step 2: exploring the code

Briefly describe the meaning of 'abstraction' in programming:

Notes

Total hints used: /

Step 3: automated players

Having run the program 3-4 times, which of the two players is operating the very 'high risk' strategy, and which the very 'cautious' strategy?

Notes

Total hints used: /

Step 4: identifying the better of the strategies

Having run the program to play 10 rounds automatically, how many points did the Dealer, and each of the players ended up with?

Run the program a second time, and record how many points ended up with this time

Notes

Total hints used: /

Step 5: speeding up the program

Make sure that you have ghosted the pause (instruction 31) and all five occurrences of call displayprocedureName?(gamearguments?)0 within the playOneRound procedure. Then run the program. You will see that both of the two players have lost points - only the Dealer is ahead.

Which of the two players has lost the least points?

Given that the result is from playing 100 rounds, and each participant started with 1000 points, calculate the average points lost or gained per round expressed as a percentage, for the Dealer and each Player (where a loss is a negative percentage and a gain is positive). Show how you worked this out.

Notes

Total hints used: /

Step 6: the default strategies

What can you say that every function does?

Notes

Total hints used: /

Step 7:implement a simple strategy with a decision

With the changes, how many points does each have after running 100 games?

Notes

Total hints used: /

Step 8: simulating 10,000 rounds

After making the changes such that the display now only updated after the last round, approximately how long did it take to run 10,000 rounds of Blackjack?

How many points did the Dealer, and each Player end up with?

Given that Player B is mimicking the strategy of the Dealer, why are they still losing points to the Dealer? (If you can't see why, say so.)

Notes

Total hints used: /

Step 9: making use of the soft ace

After making the changes and running the new version, what were the points for Player A and Player B?

Notes

Total hints used: /

Step 10: paying attention to the Dealer's 'face up card'

After making the changes and running the new version, what were the points for Player A and Player B?

Notes

Total hints used: /

Step 11: expanding the scope of the previous rule

After making the changes and running the new version, what were the points for Player A and Player B?

Notes

Total hints used: /

Step 12: testing what you have learned

What does defining a named value as a 'variable' allow you to then do?

When defining a variable, what two things must you specify?

What kind of instruction is used to change the value of a variable?

What must the code written into the 'condition' field of an 'if' instruction evaluate to?

Some types offer 'properties'. What is a property?

If you have a named value and you want to see what properties (if any) you can access from it, how do you do that?

What happens if you try to compare two values that are of different types?

If an 'if instruction' is given an 'else' clause, under what condition is that else clause executed?

If you combine more than one operator within a condition, what must you be careful about?

And what is the best way to ensure that you don't run into a problem when combining operators?

Notes

Total hints used: /

Congratulations! You have finished this worksheet

Answers to the questions in the previous step: If you are interested in taking this project further, watch this video first: