Socket
Socket
Sign inDemoInstall

blackjack-gui

Package Overview
Dependencies
2
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    blackjack-gui

A game of Blackjack with graphical user interface.


Maintainers
1

Readme

blackjack-gui

Downloads

Single-player Blackjack including GUI and CLI interfaces, written in Python. Can be used to simulate games with or without card counting and to practise basic strategy.

Installation

blackjack-gui requires Python 3.8 or newer and uses tkinter. Make sure it's installed in your system:

$ sudo apt install python3-tk

or similar (otherwise, you'll see ModuleNotFoundError: No module named 'tkinter').

Then:

$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install blackjack-gui

Usage

GUI version

blackjack [OPTION...]

CLI version

blackjack --gui=False [OPTION...]

Options

NameDefaultCLI onlyDescription
--stack1000Initial stack.
--bet1Initial bet size.
--n_games10xNumber of rounds to be played.
--aiFalsexIf True, computer plays instead of you.
--countFalsexIf True, ai uses card counting.
--loglevelDEBUGxAdjust amount of logging: DEBUG or INFO.
--cardsDetermine the first player cards, e.g. --cards=A,8,K. Shuffles the shoe after every hand.
--dealer_cardsDetermine the first dealer cards. Useful for testing.

Examples

Open the GUI version:

$ blackjack

With the default settings, play 10 rounds of Blackjack without GUI:

$ blackjack --gui=False

Let the computer play perfect basic game and use card counting technique to bring down the house:

$ blackjack --n_games=100000 --ai=True --count=True --loglevel=INFO --gui=False

Simulate soft 19 starting hand only:

$ blackjack --n_games=10000 --ai=True --loglevel=INFO --gui=False --cards=A,8

Rules

Blackjack rules vary depending on the casino. In this application they follow: https://casinohelsinki.fi/en/games/blackjack-eng/, i.e.:

  • 6 decs
  • Blackjack pays 3 to 2
  • Dealer must stand on soft 17
  • Any two cards can be doubled
  • Max. 4 hands can be achieved by splitting
  • Aces can be split but they receive only one extra card
  • Doubling after splitting is allowed
  • Surrender is allowed but not against Ace

Optimal basic strategy

  • Note that 16 vs 10 with 3 or more cards = Stay

Tests

Install blackjack-gui from GitHub and pytest:

$ git clone https://github.com/tukiains/blackjack-gui
$ cd blackjack-gui/
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install .
$ pip3 install pytest

Run unit and integration tests:

$ pytest-3 tests/unit.py
$ pytest-3 tests/integration.py

Notes

  • Card images taken from here.

Licence

MIT

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc