Name | blackjack-gui JSON |
Version |
1.3.0
JSON |
| download |
home_page | None |
Summary | A game of Blackjack with graphical user interface. |
upload_time | 2024-12-24 21:01:16 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT License |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# blackjack-gui
[![Blackjack GUI CI](https://github.com/tukiains/blackjack-gui/actions/workflows/test.yml/badge.svg)](https://github.com/tukiains/blackjack-gui/actions/workflows/test.yml)
[![Downloads](https://pepy.tech/badge/blackjack-gui)](https://pepy.tech/project/blackjack-gui)
Single-player Blackjack including graphical and command line interfaces, written in Python. Can be used to simulate games with or without card counting
and to practise basic strategy.
<img src="https://github.com/tukiains/blackjack-gui/blob/main/blackjack_gui/images/bj-shot.png?raw=true" alt="" width="600"/>
## Installation
`blackjack-gui` requires Python 3.10 or newer and uses [tkinter](https://en.wikipedia.org/wiki/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
```
blackjack [-h] [--no-gui] [--ai] [--count] [--bet BET] [--stack STACK]
[--n-games N_GAMES] [--loglevel LOGLEVEL] [--cards CARDS]
[--dealer-cards DEALER_CARDS] [--subset {hard,soft,pairs,hard/soft}]
```
### Options
| Name | Default | Description |
| :--------------- | :------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--no-gui` | `False` | Use command line version. |
| `--ai` | `False` | If True, computer plays instead of you. Only with `--no-gui`. |
| `--count` | `False` | If True, `ai` uses card counting. Only with `--no-gui` and `--ai`. |
| `--bet` | 1 | Bet size (max 10). |
| `--stack` | 1000 | Initial stack. |
| `--n-games` | 10 | Number of rounds to be played. Only with `--no-gui`. |
| `--loglevel` | `DEBUG` | Adjust amount of logging: DEBUG or INFO. Only with `--no-gui`. |
| `--cards` | | Determine the first player cards, e.g. `--cards=A,8,K`. Shuffles the shoe after every hand. Multiple options (one will be randomly selected) can be defined like this: `"A,7;9,9;10,2"`. |
| `--subset` | | Instead of `--cards`, practice with one of the subsets: `hard`, `soft`, `pairs`, `hard/soft`, or `soft/pairs` |
| `--dealer-cards` | | Determine the first dealer cards. Useful for testing. |
## Examples
Open the GUI version:
```
$ blackjack
```
With the default settings, play 10 rounds of Blackjack with the command line interface:
```
$ blackjack --no-gui
```
Let the computer play perfect basic game and use card counting technique to bring down the house:
```
$ blackjack --no-gui --ai --count --n-games=100000 --loglevel=INFO
```
Simulate soft 19 starting hand only:
```
$ blackjack --no-gui --ai --n-games=10000 --loglevel=INFO --cards=A,8
```
Practise to play "hard" starting hands:
```
$ blackjack --subset hard
```
## Rules
Blackjack rules vary depending on the casino. In this application they follow the rules of Casino Helsinki,
explained in Finnish [here](http://www.rahapeliopas.fi/kasinopelit/blackjack/), 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
- A 7-7-7 with the first three cards (not in a split game) pays 3 to 1 directly
See overview of the most common rule variations [here](rule-variations.md).
### Optimal basic strategy for Casino Helsinki
<img src="https://raw.githubusercontent.com/tukiains/blackjack-gui/main/blackjack_gui/images/chart-helsinki.png" alt="" width="400"/>
<img src="https://raw.githubusercontent.com/tukiains/blackjack-gui/main/blackjack_gui/images/helsinki-symbols.png" alt="" width="218"/>
- Note that 16 vs 10 with 3 or more cards = Stay
- 7,7 would be normally Surrender, but not in Helsinki because of the 7-7-7 rule
### Optimal basic strategy for a typical U.S. casino
The rules in the U.S. typically include:
- Dealer must hit on soft 17
- Dealer peek is in use
- Late surrender is allowed
<img src="https://raw.githubusercontent.com/tukiains/blackjack-gui/main/blackjack_gui/images/chart-usa.png" alt="" width="400"/>
<img src="https://raw.githubusercontent.com/tukiains/blackjack-gui/main/blackjack_gui/images/usa-symbols.png" alt="" width="320"/>
## Development
Install `blackjack-gui` with dev-dependencies from GitHub:
```sh
git clone https://github.com/tukiains/blackjack-gui
cd blackjack-gui/
python3 -m venv venv
source venv/bin/activate
pip3 install --upgrade pip
pip3 install .[dev,test]
pre-commit install
```
Run unit and integration tests:
```sh
pytest tests/unit.py
pytest tests/integration.py
```
Run `pre-commit` checks:
```
pre-commit run --all
```
## Notes
- Deviations from the basic strategy are not yet implemented.
- Card images taken from [here](https://code.google.com/archive/p/vector-playing-cards/).
## Licence
MIT
Raw data
{
"_id": null,
"home_page": null,
"name": "blackjack-gui",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Simo Tukiainen <tukiains@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/b3/f5/21280380c15c4f86449100b931b676500dd9cf0f518a2d7bc3c6a63c2f1f/blackjack_gui-1.3.0.tar.gz",
"platform": null,
"description": "# blackjack-gui\n\n[![Blackjack GUI CI](https://github.com/tukiains/blackjack-gui/actions/workflows/test.yml/badge.svg)](https://github.com/tukiains/blackjack-gui/actions/workflows/test.yml)\n[![Downloads](https://pepy.tech/badge/blackjack-gui)](https://pepy.tech/project/blackjack-gui)\n\nSingle-player Blackjack including graphical and command line interfaces, written in Python. Can be used to simulate games with or without card counting\nand to practise basic strategy.\n\n<img src=\"https://github.com/tukiains/blackjack-gui/blob/main/blackjack_gui/images/bj-shot.png?raw=true\" alt=\"\" width=\"600\"/>\n\n## Installation\n\n`blackjack-gui` requires Python 3.10 or newer and uses [tkinter](https://en.wikipedia.org/wiki/Tkinter). Make sure it's installed in your system:\n\n```\n$ sudo apt install python3-tk\n```\n\nor similar (otherwise, you'll see `ModuleNotFoundError: No module named 'tkinter'`).\n\nThen:\n\n```\n$ python3 -m venv venv\n$ source venv/bin/activate\n$ pip3 install blackjack-gui\n```\n\n## Usage\n\n```\nblackjack [-h] [--no-gui] [--ai] [--count] [--bet BET] [--stack STACK]\n [--n-games N_GAMES] [--loglevel LOGLEVEL] [--cards CARDS]\n [--dealer-cards DEALER_CARDS] [--subset {hard,soft,pairs,hard/soft}]\n\n```\n\n### Options\n\n| Name | Default | Description |\n| :--------------- | :------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `--no-gui` | `False` | Use command line version. |\n| `--ai` | `False` | If True, computer plays instead of you. Only with `--no-gui`. |\n| `--count` | `False` | If True, `ai` uses card counting. Only with `--no-gui` and `--ai`. |\n| `--bet` | 1 | Bet size (max 10). |\n| `--stack` | 1000 | Initial stack. |\n| `--n-games` | 10 | Number of rounds to be played. Only with `--no-gui`. |\n| `--loglevel` | `DEBUG` | Adjust amount of logging: DEBUG or INFO. Only with `--no-gui`. |\n| `--cards` | | Determine the first player cards, e.g. `--cards=A,8,K`. Shuffles the shoe after every hand. Multiple options (one will be randomly selected) can be defined like this: `\"A,7;9,9;10,2\"`. |\n| `--subset` | | Instead of `--cards`, practice with one of the subsets: `hard`, `soft`, `pairs`, `hard/soft`, or `soft/pairs` |\n| `--dealer-cards` | | Determine the first dealer cards. Useful for testing. |\n\n## Examples\n\nOpen the GUI version:\n\n```\n$ blackjack\n```\n\nWith the default settings, play 10 rounds of Blackjack with the command line interface:\n\n```\n$ blackjack --no-gui\n```\n\nLet the computer play perfect basic game and use card counting technique to bring down the house:\n\n```\n$ blackjack --no-gui --ai --count --n-games=100000 --loglevel=INFO\n```\n\nSimulate soft 19 starting hand only:\n\n```\n$ blackjack --no-gui --ai --n-games=10000 --loglevel=INFO --cards=A,8\n```\n\nPractise to play \"hard\" starting hands:\n\n```\n$ blackjack --subset hard\n```\n\n## Rules\n\nBlackjack rules vary depending on the casino. In this application they follow the rules of Casino Helsinki,\nexplained in Finnish [here](http://www.rahapeliopas.fi/kasinopelit/blackjack/), i.e.:\n\n- 6 decs\n- Blackjack pays 3 to 2\n- Dealer must stand on soft 17\n- Any two cards can be doubled\n- Max. 4 hands can be achieved by splitting\n- Aces can be split but they receive only one extra card\n- Doubling after splitting is allowed\n- Surrender is allowed but not against Ace\n- A 7-7-7 with the first three cards (not in a split game) pays 3 to 1 directly\n\nSee overview of the most common rule variations [here](rule-variations.md).\n\n### Optimal basic strategy for Casino Helsinki\n\n<img src=\"https://raw.githubusercontent.com/tukiains/blackjack-gui/main/blackjack_gui/images/chart-helsinki.png\" alt=\"\" width=\"400\"/>\n<img src=\"https://raw.githubusercontent.com/tukiains/blackjack-gui/main/blackjack_gui/images/helsinki-symbols.png\" alt=\"\" width=\"218\"/>\n\n- Note that 16 vs 10 with 3 or more cards = Stay\n- 7,7 would be normally Surrender, but not in Helsinki because of the 7-7-7 rule\n\n### Optimal basic strategy for a typical U.S. casino\n\nThe rules in the U.S. typically include:\n\n- Dealer must hit on soft 17\n- Dealer peek is in use\n- Late surrender is allowed\n\n<img src=\"https://raw.githubusercontent.com/tukiains/blackjack-gui/main/blackjack_gui/images/chart-usa.png\" alt=\"\" width=\"400\"/>\n<img src=\"https://raw.githubusercontent.com/tukiains/blackjack-gui/main/blackjack_gui/images/usa-symbols.png\" alt=\"\" width=\"320\"/>\n\n## Development\n\nInstall `blackjack-gui` with dev-dependencies from GitHub:\n\n```sh\ngit clone https://github.com/tukiains/blackjack-gui\ncd blackjack-gui/\npython3 -m venv venv\nsource venv/bin/activate\npip3 install --upgrade pip\npip3 install .[dev,test]\npre-commit install\n```\n\nRun unit and integration tests:\n\n```sh\npytest tests/unit.py\npytest tests/integration.py\n```\n\nRun `pre-commit` checks:\n\n```\npre-commit run --all\n```\n\n## Notes\n\n- Deviations from the basic strategy are not yet implemented.\n- Card images taken from [here](https://code.google.com/archive/p/vector-playing-cards/).\n\n## Licence\n\nMIT\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A game of Blackjack with graphical user interface.",
"version": "1.3.0",
"project_urls": {
"Changelog": "https://github.com/tukiains/blackjack-gui/CHANGELOG.md",
"Documentation": "https://github.com/tukiains/blackjack-gui",
"Homepage": "https://github.com/tukiains/blackjack-gui",
"Repository": "https://github.com/tukiains/blackjack-gui"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0706fc9a2ada4edbbd43b6abcd385d8d048177ebebb9ab8053f4c0c155fa8acc",
"md5": "48bb23ea49ec819c1466625a640f89de",
"sha256": "eadaebe9eacda8916720e831528b6b102e139e1dfe4fd6b202232632a7092093"
},
"downloads": -1,
"filename": "blackjack_gui-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "48bb23ea49ec819c1466625a640f89de",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 5894911,
"upload_time": "2024-12-24T21:01:12",
"upload_time_iso_8601": "2024-12-24T21:01:12.170341Z",
"url": "https://files.pythonhosted.org/packages/07/06/fc9a2ada4edbbd43b6abcd385d8d048177ebebb9ab8053f4c0c155fa8acc/blackjack_gui-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b3f521280380c15c4f86449100b931b676500dd9cf0f518a2d7bc3c6a63c2f1f",
"md5": "a81d3739fe31f27079a83f46b15d6ada",
"sha256": "2cf020b453a491aef13a87a5dd782816610c51659d0650b20333e835ba2872fa"
},
"downloads": -1,
"filename": "blackjack_gui-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "a81d3739fe31f27079a83f46b15d6ada",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 5889565,
"upload_time": "2024-12-24T21:01:16",
"upload_time_iso_8601": "2024-12-24T21:01:16.218404Z",
"url": "https://files.pythonhosted.org/packages/b3/f5/21280380c15c4f86449100b931b676500dd9cf0f518a2d7bc3c6a63c2f1f/blackjack_gui-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-24 21:01:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tukiains",
"github_project": "blackjack-gui",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "blackjack-gui"
}