Utilities

Card counting utilities

utils.get_hilo_true_count(shoe)

Get the true count from the shoe.

Parameters:

shoe (list[int]) – The shoe (cards we haven’t seen).

Returns:

The true count of the shoe.

Return type:

float

utils.get_hilo_running_count(cards_seen)

Get the running count from the cards we have seen.

Parameters:

cards_seen (list[int]) – The cards we have seen.

Returns:

The running count of the shoe.

Return type:

int

Deck utilities

utils.SUIT: list[int] = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11]

The cards that a deck contains.

utils.DECK: list[int] = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

Shoe utilities

utils.get_cards_seen(deck_number, shoe)

Get the cards that we have already seen from the umber of decks and the shoe.

Parameters:
  • deck_number (int) – How many decks the shoe started with

  • shoe (list[int]) – The cards that are still in the shoe.

Returns:

The cards that we have seen.

Return type:

list[int]

Action utilities

utils.short_to_long_action(action)

Convert a shorthand to the name of the action.

Parameters:

action (str) – A shorthand for each possible action. s for stand, h for hit, d for double, p for split, u for surrender, and i for insurance.

Returns:

The name of the action. (e.g. returns stand for s and split for p)

Return type:

str

utils.long_to_short_action(action)

Convert the action to its shorthand.

Parameters:

action (str) – The name of each action. split, hit, double, split, surrender, and insurance.

Returns:

The shorthand for each action. (e.g. returns h for hit and u for surrender)

Return type:

str

Beautification utilities

utils.readable_number(number)

Turn a number into a more readable format.

Parameters:

number (int) – An integer.

Returns:

An easier-to-read format for the number (e.g. 15_000_000 becomes 15.0M).

Return type:

str

Type hinting utilities

utils.list_range_str(start, end, step=1)

Return a list of string numbers.

Parameters:
  • start (int) – The starting number (inclusive) for the range generator.

  • end (int) – The ending number (exclusive) for the range generator.

  • step (int) – The step parameter for the range generator.

Returns:

A list with the results of range(start, end, step) converted to strings.

Return type:

list[str]