Simple terminal-based blackjack game
Project description
pyblackjack
pyblackjack is a fun way to waste time at the terminal playing blackjack with a computerized dealer.
Installation
pyblackjack is available on PyPI
as a pre-release version. To install, type the following into the
terminal, assuming that the appropriate pip
is on your PATH:
pip install pyblackjack
Getting Started
Type blackjack
at the terminal to launch the game. At the first
prompt, you may press q
to jump straight into the action, using a
default player name, six-deck shoe, and 1,000 starting chips, with the
dealer hitting on soft 17.
You can also configure the game to your liking by going through the prompts. The first prompt asks you for the number of players (human; CPU players may come in the future but are not available yet). You can select from one to six players, and enter a name for each. Next, you will be asked for the number of starting chips per player, followed by the number of decks in the shoe (up to eight). The last prompt will ask you if the dealer should hit on a soft 17 (which increases the house edge slightly). After this, you're ready to start playing!
Playing
Your first task for every hand is to enter your bet. After all players have placed a bet, the cards will be dealt and displayed. At this point, if the dealer is showing an Ace, each player will be asked whether they wish to buy insurance, the cost of which is one-half of your bet.
After this, or if the dealer is not showing an Ace, blackjacks will be checked. If the dealer has a blackjack, it will be revealed, the hand ends immediately, and all players lose unless they also have blackjack, in which case it is a push. If anyone bought insurance, they will lose their bet but be paid 2:1 on the insurance.
If the dealer does not have blackjack, but a player does, that player is paid at 3:2 and takes no further part in the hand.
After this, if any active players remain, the first player in turn order will be shown their hand and asked for an action. Available actions are listed below. Except for hit and stand, all actions are only available as your first action before doing anything else, and then sometimes only under certain circumstances as noted.
-
Hit (
h
): Deal another card to your hand. If this results in a hard total over 21, the game will display a message that you busted, and your turn will end and you will lose your bet. -
Stand (
s
): End your turn. -
Double down (
d
): Double your bet, deal one (and only one) additional card to the hand, and end your turn. This option is only available when your first two cards total 9, 10, or 11. -
Split (
p
): Split your two starting cards into two separate hands, placing a second bet identical to your original bet on the second hand. This is only available if both starting cards form a pair (e.g. two sixes or two queens). A second card will then be dealt to each hand, which will be played separately from the other. After splitting, the only actions available on the split hands will be to hit or stand, except that if you split a pair of aces, your turn will end immediately after the second card is dealt to each hand (i.e. you cannot hit split aces). -
Surrender (
u
): Give up and drop out of the hand, with half your bet being returned.
Once the first player has completed their turn, the next player will be asked for actions, and so on until all players have played. At this point, the dealer will reveal the downcard and play their hand. The dealer will hit on 16 or below and stand on 17 or higher, except that if the option for the dealer to hit on soft 17 was enabled in setup (or the quickstart option was chosen), the dealer will do so.
Once the dealer has played their hand, the dealer pays the winners. If the dealer busts, all players who did not also bust are paid 1:1. If the dealer did not bust, players with a higher total than the dealer are paid 1:1, players with the same total push (receive their bet back), and players with a lower total lose their bet.
The game will then return to the prompt to enter a bet. At this prompt,
any player wishing to quit may enter q
to do so and will be removed
from the game. If the last player in the game quits, the program will
terminate.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyblackjack-0.1.1a3.tar.gz
.
File metadata
- Download URL: pyblackjack-0.1.1a3.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4ae7eabf272a3c2552e7070cd802d69b74028298fcbc6a554c0742fef3e6800 |
|
MD5 | f635910d4535cf47cd5459d71cd1b7c1 |
|
BLAKE2b-256 | 3ab47f12687831d798bf5734257e5fcf800e7d84fec14a2636584bc8bfda8a81 |
File details
Details for the file pyblackjack-0.1.1a3-py3-none-any.whl
.
File metadata
- Download URL: pyblackjack-0.1.1a3-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 442a673806ce4b1b9b0c2eb047101f3baa337ecde4dac0ada8cbd932543049d0 |
|
MD5 | 2aee3dd1f737f1b92047ac0a13ee6993 |
|
BLAKE2b-256 | 44d11071600444abe9a769ad04f4a1efbc6cd1c697387473101c0b3a2f49f115 |