blackjack package

Submodules

blackjack.py Author: Cole Howard

A simple implementation of the game of blackjack.

The user is tasked with defining the number of decks of 52 cards to be used in the shoe. The game can then be played until the shoe runs out or the user opts out. Dealer always wins ties.

Usage

Copy the folder Blackjack (capital B) and run the script:

>>>python3 blackjack/bj_main.py

All interaction will be via stdout on the command line.

Tests can be run from the same directory via

>>>nosetests

or

>>>py.test

Dependencies:
Python 3.0 or newer random.shuffle Card class from card.py Shoe class from shoe.py User and Dealer (subclasses of Player) from player.py
class Blackjack

An environment for playing blacjack. User will define the size of the deck shoe (in numbers of 52 card decks) and can then play hands of blackjack until the shoe runs out, or they opt ou

dealer_victories

int

Number of hands won by the dealer

player_victories

int

Number of hands won by the player

sitting()
class Game(shoe)

Initialize game of blackjack

shoe : Instance of Shoe Class
The current shoe initialized in Blackjack.sitting()
dealer

instance of Player class

player

instance of Player class

initial_hand_size

int

Number of cards initially dealt

max_target_score

int

A constant set to 21 per the rules of blackjack

dealer_trigger

int

A constant set to 17, the score at which the dealer will stop accepting additional cards, per the rules of blackjack

deal()

Deals the set # of starting cards (defined in the init)

eval_state()

Evaluates the status of the game to the stdout on command line

Returns:“d”, “p”, or None (if out of cards or unresolved)
Return type:string
get_winner()

Determines the winner if both players pass

Returns:“d” (dealer) or “p” (player) for victor
Return type:string
play()

Plays a single round of blackjack

Returns:
Return type:instance of Player object
report(finished=False)

Reports the status of the game to the stdout on command line

report_results()

Report final outcome of the hand

Returns:As notification of execution
Return type:True

Module contents