Skip to content

Commit c2878d5

Browse files
committed
resplit, 0deck-s17
1 parent bf002ec commit c2878d5

18 files changed

Lines changed: 357 additions & 68 deletions

doc/blackjack.md

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,93 @@ Proper quotation migh be needed if the value contains spaces. For example,
8686
blackjack --internal --cards="TH JS 6D"
8787
```
8888

89-
With no command-line options and no configuration file, `blackjack` starts in interactive mode and it is ready to start a blackjack game (see @sec:interactive for details).
89+
With no command-line options and no configuration file, `blackjack` starts in interactive mode and it is ready to start an ASCII blackjack game (see @sec:interactive).
9090

9191
## Results {#sec:results}
9292

93-
TBD
93+
Before exiting, the program prints a summary of the results in YAML format:
94+
95+
```terminal
96+
---
97+
result: "(-0.8 ± 0.3)"
98+
rules: "ahc h17 das doa 3rsp 0decks"
99+
mean: -0.008237
100+
error: 0.00348378
101+
hands: 1e+06
102+
bankroll: -8237
103+
busts_player: 0.139315
104+
busts_dealer: 0.239251
105+
wins: 0.447443
106+
pushes: 0.086111
107+
losses: 0.495896
108+
total_money_waged: 1.13708e+06
109+
blackjacks_player: 0.047392
110+
blackjacks_dealer: 0.047318
111+
variance: 1.34853
112+
deviation: 1.16126
113+
...
114+
```
115+
116+
By default, the results are written in the standard error, as the standard output is typically used to send dealer's messages to the player.
117+
Therefore, if you are not using stdout (e.g. because you used the internal player `-i`) and want to use the results with Unix pipes, you have to redirect the standard error to the standard output:
118+
119+
```terminal
120+
$ blackjack -i 2>&1 | yq .
121+
{
122+
"result": "(-0.8 ± 0.3)",
123+
"rules": "ahc h17 das doa 3rsp 0decks",
124+
"mean": -0.007579,
125+
"error": 0.00348416,
126+
"hands": 1000000.0,
127+
"bankroll": -7579,
128+
"busts_player": 0.139308,
129+
"busts_dealer": 0.239262,
130+
"wins": 0.447834,
131+
"pushes": 0.085761,
132+
"losses": 0.495561,
133+
"total_money_waged": 1136900.0,
134+
"blackjacks_player": 0.047427,
135+
"blackjacks_dealer": 0.047433,
136+
"variance": 1.34882,
137+
"deviation": 1.16139
138+
}
139+
```
94140

95-
In YAML
141+
The YAML results can be written to a file by setting the variable `report` in the configuration file, where `stdout` is a valid file name.
142+
So the redirection above can be also performed as
96143

97-
`yq`
144+
```terminal
145+
$ blackjack -i --report=stdout | yq .
146+
{
147+
"result": "(-0.9 ± 0.3)",
148+
"rules": "ahc h17 das doa 3rsp 0decks",
149+
"mean": -0.00889,
150+
"error": 0.00348549,
151+
"hands": 1000000.0,
152+
"bankroll": -8890,
153+
"busts_player": 0.139248,
154+
"busts_dealer": 0.239346,
155+
"wins": 0.447292,
156+
"pushes": 0.085985,
157+
"losses": 0.495988,
158+
"total_money_waged": 1136880.0,
159+
"blackjacks_player": 0.047253,
160+
"blackjacks_dealer": 0.047674,
161+
"variance": 1.34985,
162+
"deviation": 1.16183
163+
}
164+
```
165+
166+
## Progress
167+
168+
If the number of played hands exceeds a couple dozen million, one might want to track the progress.
169+
In that case, pass the option `-p` (or `--progress`) to get an ASCII progress bar in the standard error (remember standard output is used to play blackack).
170+
171+
172+
```terminal
173+
$ blackjack -i --progress
174+
[==================> ] 36 %
175+
```
98176

99177
## Interactive game {#sec:interactive}
100178

doc/commands-inf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ character $s$ gives the suit.
135135
| `S` | ♠ Spades |
136136
: Suit (second) character of a card {#tbl:suit}
137137

138-
The optional argument $h$ indicates the id of the player's hand
138+
The optional argument $h$ indicates the id of the player's hand
139139
being dealt. If it not present, that means the base hand.
140140
When performing a splitting on the base hand, the original hand
141141
has id equal to zero and the new hand has id equal to one.

doc/conf.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* `penetration_sigma` (@sec:penetration_sigma)
1616
* `player` (@sec:player)
1717
* `quit_when_arranged_cards_run_out` (@sec:quit_when_arranged_cards_run_out)
18+
* `resplits` (@sec:resplits)
1819
* `rng_seed` (@sec:rng_seed)
1920
* `rules` (@sec:rules)
2021
* `shuffle_every_hand` (@sec:shuffle_every_hand)
@@ -337,6 +338,21 @@ quit_when_arranged_cards_run_out = false
337338
quit_when_arranged_cards_run_out = true
338339
~~~
339340

341+
# `resplits = ` $n$ {#sec:resplits}
342+
343+
Sets the maximum number of re-split hands.
344+
Default is three, meaning the dealer allows the player to play up to four hands.
345+
346+
**Default**
347+
$3$
348+
349+
**Examples**
350+
351+
~~~
352+
resplits = 1
353+
resplits = 8
354+
~~~
355+
340356
# `rng_seed = ` $n$ {#sec:rng_seed}
341357

342358
This option sets the seed of the random number generator used by the dealer to draw cards.

doc/help-extra.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
If no configuration file is given, a file named blackjack.conf in the
2-
current directory is used, provided it exists.
3-
4-
See the full documentation for the available options and the default
5-
values.
2+
current directory is used, provided it exists. See the full
3+
documentation for the available options and the default values.

doc/help-options-base.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
-n<n> or --hands=n Specify the number of hands to play. Corresponds to the hands variable in the configuration file.
33
-d<n> or --decks=n Specify the number of decks to use in the shoe. Corresponds to the decks variable in the configuration file.
44
-f or --flatbet Do not ask for the amount to bet before starting a new hand and use a flat unit bet. Corresponds to the flat_bet variable in the configuration file.
5-
-i or --internal -p or --progressUse the internal player to play against the dealer. See the manual for details and instructions to define the rules and optionally, the playing strategy and/or arranged shoes. Show a progress bar.
5+
-i or --internal Use the internal player to play against the dealer. See the manual for details and instructions to define the rules and optionally, the playing strategy and/or arranged shoes.
6+
-p or --progress Show a progress bar when playing a fixed number of hands.
67
-h or --help Print this informative help message into standard output and exit successfully.
78
-v or --version Print the version number and licensing information into standard output and then exit successfully.
89
--configuration_variable[=value]Any configuration variable from the configuration file can be set from the command line. For example, passing --no_insurance is like setting no_insurance = 1 in the configuration file. Command-line options override setting in the configuration file.

doc/help.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ Corresponds to the `flat_bet` variable in the configuration file.
2424

2525

2626
`-i` or `--internal`
27-
`-p` or `--progress`
2827

2928
: Use the internal player to play against the dealer. See the manual for details
3029
and instructions to define the rules and optionally, the playing strategy and/or arranged shoes.
31-
Show a progress bar.
30+
31+
32+
`-p` or `--progress`
33+
34+
: Show a progress bar when playing a fixed number of hands.
3235

3336

3437
`-h` or `--help`
@@ -50,6 +53,5 @@ Command-line options override setting in the configuration file.
5053

5154
If no configuration file is given, a file named `blackjack.conf`
5255
in the current directory is used, provided it exists.
53-
5456
See the full documentation for the available options and the default values.
5557

doc/help.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@
2121
a flat unit bet. Corresponds to the flat_bet variable in the
2222
configuration file.
2323

24-
-i or --internal -p or --progress
24+
-i or --internal
2525

26-
: Use the internal player to play against the dealer. See the manual for
27-
details and instructions to define the rules and optionally, the playing
28-
strategy and/or arranged shoes. Show a progress bar.
26+
Use the internal player to play against the dealer. See the manual
27+
for details and instructions to define the rules and optionally, the
28+
playing strategy and/or arranged shoes.
29+
30+
-p or --progress
31+
32+
Show a progress bar when playing a fixed number of hands.
2933

3034
-h or --help
3135

@@ -45,7 +49,5 @@ strategy and/or arranged shoes. Show a progress bar.
4549
options override setting in the configuration file.
4650

4751
If no configuration file is given, a file named blackjack.conf in the
48-
current directory is used, provided it exists.
49-
50-
See the full documentation for the available options and the default
51-
values.
52+
current directory is used, provided it exists. See the full
53+
documentation for the available options and the default values.

0 commit comments

Comments
 (0)