API Reference

whist_backend.round_simulator.deal_hands(number_of_players, hand_size, deck)[source]
Parameters:
  • number_of_players (int) –

  • hand_size (int) –

  • deck (list[Card]) –

Return type:

list[list[Card]]

whist_backend.round_simulator.determine_trump_suit_and_hand_sizes(card)[source]
Parameters:

card (Card) –

Return type:

tuple[Suit, int]

whist_backend.round_simulator.cyclic_shift(items, shift_amount)[source]
Parameters:
  • items (list[TypeVar(T)]) –

  • shift_amount (int) –

Return type:

list[TypeVar(T)]

whist_backend.round_simulator.find_trick_winner(cards_and_players, trump_suit, initial_suit)[source]
Parameters:
  • cards_and_players (list[tuple[_Player, Card]]) –

  • trump_suit (Suit) –

  • initial_suit (Suit) –

Return type:

_Player

class whist_backend.round_simulator.RoundSimulator(strategies, *, event_listeners=None)[source]
Parameters:
__init__(strategies, *, event_listeners=None)[source]
Parameters:
play_round()[source]
Return type:

list[tuple[PlayerStrategy, int]]

make_move_on_player(player, initial_suit)[source]
Parameters:
  • player (_Player) –

  • initial_suit (Optional[Suit]) –

Return type:

Card

on_trick_win(player)[source]
Parameters:

player (_Player) –

Return type:

None

ask_player_for_bet(player, disallowed_bet=None)[source]
Parameters:
  • player (_Player) –

  • disallowed_bet (Optional[int]) –

Return type:

Bet

gather_bets_for_round(player_order)[source]
Parameters:

player_order (list[_Player]) –

Return type:

list[Bet]

play_trick()[source]
Return type:

None

class whist_backend.cards.Suit(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

An enum for each card suit.

__str__()[source]

Return a single character representing the suit, eg .

Return type:

str

SPADES = 0
HEARTS = 1
DIAMONDS = 2
CLUBS = 3
class whist_backend.cards.Rank(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

An Enum for each card rank.

Note that ACE has value 1.

You can use the > operator on Ranks.

__str__()[source]

Return a short string representation of the rank, eg A or 10.

Return type:

str

__lt__(other)[source]

Given self < other, return True if other is strictly better.

Parameters:

other (Rank) –

Return type:

bool

__gt__(value, /)

Return self>value.

__le__(value, /)

Return self<=value.

__ge__(value, /)

Return self>=value.

value: int
ACE = 1
TWO = 2
THREE = 3
FOUR = 4
FIVE = 5
SIX = 6
SEVEN = 7
EIGHT = 8
NINE = 9
TEN = 10
JACK = 11
QUEEN = 12
KING = 13
whist_value()[source]
Return type:

int

class whist_backend.cards.Card(rank, suit)[source]

Represents a card object.

This is implemented as a frozen dataclass, so magic methods such as __hash__ and __eq__ are automatically defined on it.

__str__()[source]

Return a 3 character representation of the card, eg ` A♠`.

Return type:

str

Parameters:
rank: Rank
suit: Suit
__init__(rank, suit)
Parameters:
whist_backend.cards.new_deck()[source]

Return a full, new, sorted deck of cards.

Return type:

list[Card]

whist_backend.cards.new_shuffled_deck()[source]

Return a full, new, shuffled deck of cards.

Return type:

list[Card]