title: Libre Blackjack, a free blackjack back end lang: en-US ...
Libre 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
- the standard input and/or output,
- named pipes,
- POSIX message queues,
- TCP (web)sockets (using
netcat
orgwsocket
), or - dynamically loaded arbitrary routines from shared objects.
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:
<asciinema-player src="doc/libreblackjack.cast" cols="89" rows="28" preload="true" poster="npt:0:20"></asciinema-player>
:::{.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} :::
With Libre Blackjack you do not have to trust other people anymore. You have a free blackjack engine which you can
- run as you wish, to see the results of billions of blackjack hands,
- study to see how it works and change it if you do not like it,
- share it with your friends and colleagues, and
- 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 is free software.
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 from scratch to convince yourself there is no flaw.
The main objective is research and optimization of playing and betting strategies depending on
- particular table rules (number of decks, hit on soft 17, double after split, etc.),
- card counting strategies
- risk of ruin
- removal of cards
- arranged shoes
These automatic players can range from simple no-bust or mimic-the-dealer hitters or standers, up to neural-networks trained players taking into account every card being dealt passing through basic strategy modified by traditional card counting mechanisms.
sudo apt-get install git autoconf make gcc
git clone https://github.com/seamplex/libreblackjack.git
cd libreblackjack
./autogen.sh
./configure
make
sudo make install
Note that Libre Blackjack depends on two optional GNU libraries:
- GNU Scientific Library for an improved random number generator
- GNU Readline for an improved interactive stdin prompt
Run as test suite to check the code work as expected.
$ make check
The subdirectory players
contains some automatic players that play against Libre Blackjack. These players are coded in different languages and communicate with Libre Blackjack in a variety of ways in order to illustrate the design basis:
- 00-internal uses the internal player that defaults to playing one million hands of basic strategy
- 02-always-stand, using the UNIX tool
yes
this player always says “stand” into the standard output (which is piped toblackjack
’s standard input) no matter what the cards are - 05-no-bust is a PERL-based player does not bust (i.e. hits if the hard total is less than twelve) that receives the cards through the standard input but draws or stands using a FIFO to talk back to the dealer
- 08-mimic-the-dealer follows what the dealer does (i.e. hits soft seventeens). It is implemented in AWK using two FIFOs.
- 20-basic-strategy derives the basic strategy from scratch in less than one minute by creating all the possible combination of hitting/standing/doubling/pairing strategies in an ASCII text file that the internal player can read and use.
Run Libre Blackjack with no arguments to play Blackjack interactively in ASCII (actually UTF-8) mode.
<asciinema-player src="doc/libreblackjack2.cast" cols="89" rows="28" preload="true" poster="npt:0:20"></asciinema-player>
Edit the file blackjack.conf
in the same directory where the executable is run to set up rules, arranged shoes and other options. Type help
at the prompt to get it.
The differential value of Libre Blackjack is that players can be programmed to play employing different strategies, card-counting techniques or even state-of-the-art AI algorithms.
See the directory players
for examples of how to write players in
- a pure UNIX way using the
yes
tool - Perl
- Awk
- Bash
- C
- Python
To play through a TCP socket, call blackjack
from netcat
. On one host, do
nc -l -p1234 -e blackjack
On the other one, connect to the first host on port 1234:
nc host 1234
Libre Blackjack is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
Home page: https://www.seamplex.com/blackjack
Repository: https://github.com/seamplex/blackjack
Mailing list and bug reports: wasora@seamplex.com (you need to subscribe first at wasora+subscribe@seamplex.com)
Follow us: Twitter YouTube LinkedIn GitHub
Libre Blackjack is copyright (C) 2016,2020 Jeremy Theler
Libre Blackjack is licensed under GNU GPL version 3 or (at your option) any later version.
Libre Blackjack is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
See the file COPYING
for copying conditions.