gtheler 5 роки тому
джерело
коміт
61f317ad42
9 змінених файлів з 4153 додано та 2578 видалено
  1. +4
    -2
      README.md
  2. +2
    -3
      doc/blackjack.md
  3. +2461
    -551
      doc/blackjack.texi
  4. +17
    -4
      doc/md2texi.sh
  5. +13
    -17
      doc/overview.md
  6. +935
    -1279
      doc/players.md
  7. +712
    -712
      players/20-basic-strategy/README.md
  8. +6
    -6
      players/check.md
  9. +3
    -4
      players/check.sh

+ 4
- 2
README.md Переглянути файл

@@ -21,7 +21,9 @@ These players can be actual human players playing in real-time through a front e



## Why
## Background

The casino game known as Blackjack has converged to the current mainstream rules since the beginning of the 20th century. Assuming the cards are infinite, the best strategy for the player yields approximately a house edge which is in the order of\ 0.5%. This is a remarkable result, because the rules of the game are not trivial and the overall combination gives a very little margin for the dealer, more than five times smaller than standard single-zero roulette. In 1963, Edward Thorp published his seminal book _Beat the dealer_ where he showed---with the help of the mainframes available at that time---that it is possible to flip the margin to the player's side by taking into account that the chances of dealing the next card of a finite shoe depends on the cards that were already dealt. This was the beginning of the card counting era, and a lot of mathematicians have devoted to the analysis of probabilities in the Blackjack game---and its variations.

:::{.alert .alert-light}
> “I am often surprised that when people drive down two-lane roads, they will trust complete strangers in the oncoming lane not to swerve into their lane causing a head-on collision; but they will not trust mathematicians to create the correct strategy for Blackjack.”
@@ -41,7 +43,7 @@ If you do not know how to program, you have the _freedom_ to hire a programmer t

## How

Once you trust the blackjack engine is fair, you can model and simulate any blackjack situation you want, playing millions of times a certain hand (say a sixteen against a ten) in different ways (say hitting or standing) to obtain you own conclusions. You can even build the [basic strategy charts](https://wizardofodds.com/games/blackjack/strategy/4-decks/) from scratch to convince yourself there is no [flaw](https://wizardofodds.com/ask-the-wizard/blackjack/).
Once you trust the blackjack engine is fair, you can model and simulate any blackjack situation you want, playing millions of times a certain hand (say a sixteen against a ten) in different ways (say hitting or standing) to obtain you own conclusions. You can even build the [basic strategy charts](https://wizardofodds.com/games/blackjack/strategy/4-decks/) from scratch to convince yourself there is no [flaw.”](https://wizardofodds.com/ask-the-wizard/blackjack/#question-4)

The main objective is research and optimization of playing and betting strategies depending on


+ 2
- 3
doc/blackjack.md Переглянути файл

@@ -173,11 +173,10 @@ include(../players/check.md)
The columns are

1. Case name, as discussed below.
2. Expected theoretical result in absolute units (i.e. -0.004 means -0.4%)
2. Expected theoretical result in absolute units (i.e. -0.01 means -1%)
3. Actual result obtained by Libre Blackjack in absolute units
4. Estimated error equal to the standard deviation of the result
5. Number of played hands per second
6. Whether the result coincides or not with the theoretical value
5. Whether the result coincides or not with the theoretical value


include(players.md)

+ 2461
- 551
doc/blackjack.texi
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 17
- 4
doc/md2texi.sh Переглянути файл

@@ -9,12 +9,25 @@ for i in $(cat players); do
echo $i
# grep 'define(case_title' ../players/${i}/README.m4 >> players.md
# awk '/> Difficulty.*/{t=1}t' ../players/${i}/README.m4 | grep -v Difficulty >> players.md
sed 's/title:/title_case:/' ../players/${i}/README.md |\
grep -v ':::' |\

# sed 's/title:/title_case:/' ../players/${i}/README.md |\
# grep -v ':::' |\
# grep -v '> Difficulty:' |\
# grep -v 'Index' |\
# grep -vw '\-\-\-\-\-\-\-' |\
# pandoc --shift-heading-level-by=1 --markdown-headings=atx -f markdown+pipe_tables -t markdown+pipe_tables >> players.md

# sed 's/title:/title_case:/' ../players/${i}/README.md |\
grep -wv 'title:' ../players/${i}/README.md |\
grep -v '> Difficulty:' |\
grep -v 'Index' |\
grep -vw '\-\-\-\-\-\-\-' |\
pandoc --shift-heading-level-by=1 --markdown-headings=atx -t markdown >> players.md
grep -ve ':::' |\
grep -vw -E '^\-\-\-$' |\
grep -vw -E '^\-\-\-\-\-\-\-$' |\
grep -vw '\.\.\.' |\
sed 's/\$n\$/Hands needed/' |\
sed 's/#/##/' >> players.md
echo >> players.md
echo >> players.md
done

+ 13
- 17
doc/overview.md Переглянути файл

@@ -1,20 +1,18 @@
> A [free](https://www.gnu.org/philosophy/free-sw.html) [Blackjack](https://en.wikipedia.org/wiki/Blackjack) back end inspired by [GNU Chess](https://www.gnu.org/software/chess/).

[Libre Blackjack](https://www.seamplex.com/blackjack) is a blackjack engine that emulates a dealer, deals (digital) cards and understands plain-text commands such as `hit` or `stand`. The basic idea is that one or more players can talk to Libre Blackjack either in an interactive or in an automated way through
Libre Blackjack is a blackjack engine that emulates a dealer, deals (digital) cards and understands plain-text commands such as `hit` or `stand`. It's inspired by GNU\ Chess. The basic idea is that one or more players can talk to Libre Blackjack either in an interactive or in an automated way through
* the standard input and/or output (optionally using named pipes or TCP (web)sockets with `netcat` or `gwsocket`), or
* C++ methods (optionally loaded at runtime from shared objects TBD).
* the standard input/output (optionally using named pipes or TCP (web)sockets with `netcat` or `gwsocket`), or
* C++ methods (optionally loaded at runtime from shared objects---TBD).
These players can be actual human players playing in real-time through a front end (a GUI application, a web-based interface, a mobile app, etc.) or robots that implement a certain betting and playing strategy playing (i.e. card counting) as fast as possible to study and analyze game statistics. There is an internal player that reads the strategy from a text file and plays accordingly. It can also be used to play interactive [ASCII blackjack].
These players can be actual human players playing in real-time through a front end (a GUI application, a web-based interface, a mobile app, etc.) or robots that implement a certain betting and playing strategy playing (i.e. card counting) as fast as possible to study and analyze game statistics. There is an internal player that reads the strategy from a text file and plays accordingly. Libre Blackjack can also be used to play interactive ASCII blackjack.

## Background

## Why
The casino game known as Blackjack has converged to the current mainstream rules since the beginning of the 20th century. Assuming the cards are infinite, the best strategy for the player yields approximately a house edge which is in the order of\ 0.5%. This is a remarkable result, because the rules of the game are not trivial and the overall combination gives a very little margin for the dealer, more than five times smaller than standard single-zero roulette. In 1963, Edward Thorp published his seminal book _Beat the dealer_ where he showed---with the help of the mainframes available at that time---that it is possible to flip the margin to the player's side by taking into account that the chances of dealing the next card of a finite shoe depends on the cards that were already dealt. This was the beginning of the card counting era, and a lot of mathematicians have devoted to the analysis of probabilities in the Blackjack game---and its variations.

:::{.alert .alert-light}
> “I am often surprised that when people drive down two-lane roads, they will trust complete strangers in the oncoming lane not to swerve into their lane causing a head-on collision; but they will not trust mathematicians to create the correct strategy for Blackjack.”
>
> [Norman Wattenberger, Modern Blackjack, 2009]{.blockquote-footer}
:::
> Norman Wattenberger, Modern Blackjack, 2009

With Libre Blackjack you do not have to trust other people anymore. You have a free blackjack engine which you can

@@ -23,12 +21,10 @@ With Libre Blackjack you do not have to trust other people anymore. You have a
2. share it with your friends and colleagues, and
3. distribute copies of your modified versions.

If you do not know how to program, you have the _freedom_ to hire a programmer to do it for you. That is why [Libre Blackjack](https://www.seamplex.com/blackjack) is [free software](https://www.gnu.org/philosophy/free-sw.html).
If you do not know how to program, you have the _freedom_ to hire a programmer to do it for you. That is why Libre Blackjack is _free software_.


## How

Once you trust the blackjack engine is fair, you can model and simulate any blackjack situation you want, playing millions of times a certain hand (say a sixteen against a ten) in different ways (say hitting or standing) to obtain you own conclusions. You can even build the [basic strategy charts](https://wizardofodds.com/games/blackjack/strategy/4-decks/) from scratch to convince yourself there is no [flaw](https://wizardofodds.com/ask-the-wizard/blackjack/).
Once you trust the blackjack engine is fair, you can model and simulate any blackjack situation you want, playing millions of times a certain hand (say a sixteen against a ten) in different ways (say hitting or standing) with different rules (does the dealer have to hit soft seventeens?) to obtain you own conclusions. You can even build the basic strategy charts from scratch to convince yourself there is no “flaw.”

The main objective is research and optimization of playing and betting strategies depending on

@@ -46,10 +42,10 @@ The first Libre Blackjack version (v0.1) was written in C. This version (v0.2)

* the inheritance mechanisms of C++ and virtual methods allows to have generic dealer and player classes from which particular games (dealers) and strategies (players) can be instantiated. This way, Blackjack variations like
- [Spanish 21](https://wizardofodds.com/games/spanish-21/)
- [Down under Blackjack](https://wizardofodds.com/games/down-under-blackjack/)
- [Free Bet Blackjack](https://wizardofodds.com/games/free-bet-blackjack/)
- [Blackjack Switch](https://wizardofodds.com/games/blackjack/switch/)
- Spanish 21
- Down under Blackjack
- Free Bet Blackjack
- Blackjack Switch
or even the Spanish “Siete y medio” could be also implemented in the same framework (the card deck should also be changed though). But also playing variations like a dealer that exposes the hole card a certain amount of the time (say 1% or 2% of the hands) could also be studied by extending the base blackjack dealer class.


+ 935
- 1279
doc/players.md
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 712
- 712
players/20-basic-strategy/README.md
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 6
- 6
players/check.md Переглянути файл

@@ -1,6 +1,6 @@
Case | Expected | Result | Error | Status
----------------------- | ------------- | -------------- | ------------- | -------
Internal player | -0.0065 | -0.008294 | 0.00348423 | ok
Always stand | -0.150 | -0.155945 | 0.0094198 | ok
No-bust strategy | -0.075 | -0.078935 | 0.00943574 | ok
Mimic the dealer | -0.055 | -0.056205 | 0.0092778 | ok
Case | Expected | Result | Error | Status
------------------------|---------------|--------------- |---------------|---------
Internal player | -0.0065 | -0.0075415 | 0.00348656 | ok
Always stand | -0.150 | -0.15393 | 0.00941969 | ok
No-bust strategy | -0.075 | -0.077645 | 0.00944109 | ok
Mimic the dealer | -0.055 | -0.063785 | 0.00926715 | ok

+ 3
- 4
players/check.sh Переглянути файл

@@ -41,8 +41,8 @@ else
player=${cases}
fi

echo 'Case | Expected | Result | Error | Status' | tee check.md
echo '----------------------- | ------------- | -------------- | ------------- | -------' | tee -a check.md
echo 'Case | Expected | Result | Error | Status ' | tee check.md
echo '------------------------|---------------|--------------- |---------------|---------' | tee -a check.md
for i in ${player}; do
if test -d ${i} -a -x ${i}/run.sh; then
cd ${i}
@@ -56,9 +56,8 @@ for i in ${player}; do
return=$(grep mean ../${i}.yaml | awk '{print $2}')
error=$(grep error ../${i}.yaml | awk '{print $2}')
hands_per_second=$(grep hands_per_second ../${i}.yaml | awk '{print $2}')
echo -ne ${return}\\t' | '${error}\\t' | '${hands_per_second}' | '
echo -ne ${return}\\t' | '${error}\\t' | '
status=$(echo ${return} | awk -v e=${expected["${i}"]} -v s=${sigma} 'END {ok = ($1>(e-s)&&$1<(e+s)); print ok?"ok":"failed"; exit !ok }')
result=$?
cd ..

Завантаження…
Відмінити
Зберегти