Protocols
- class whist_backend.player_strategy_protocol.PlayerStrategy(*args, **kwargs)[source]
Dictates a strategy for a bot.
If you inherit from this class, then the only methods that have to be implemented are make_move and make_bet. In these methods, you must obey the rules of whist (this will be checked). All other methods don’t expect any return value, and are only there so that your strategy can monitor the progress of the game.
See the docstrings of each method for more information.
-
name:
str
- notify_round_start(hand, trump_suit, player_id, revealed_card, number_of_players)[source]
Notifies when a round is about to start (i.e. cards have been dealt).
- abstract make_move(allowed_cards)[source]
Return the Card to play on this move. Must be one of allowed_cards.
- notify_new_move(player_id, card)[source]
Notify that player_id just played card.
- Parameters:
player_id (
int) –card (
Card) –
- Return type:
None
- abstract make_bet(disallowed_bet=None)[source]
Return a Bet, with number_of_tricks different to disallowed_bet.
- Parameters:
disallowed_bet (
Optional[int]) –- Return type:
Bet
- notify_new_bet(player_id, bet)[source]
Notify that player_id made a bet bet.
- Parameters:
player_id (
int) –bet (
Bet) –
- Return type:
None
- notify_trick_won(player_id)[source]
Notify that a trick has just been won by player_id.
- Parameters:
player_id (
int) –- Return type:
None
- notify_new_trick(player_id)[source]
Notify that a new trick is about to start, starting with player_id.
- Parameters:
player_id (
int) –- Return type:
None
- notify_round_end(results)[source]
Notify that the round has ended.
Can be used for teardown code.
- Parameters:
results (
list[tuple[int,int]]) –- Return type:
None
- __init__(*args, **kwargs)
-
name:
- class whist_backend.event_listener_protocol.WhistEventListener(*args, **kwargs)[source]
- notify_round_start(revealed_card, trump_suit, hand_size, players)[source]
Called when a new round starts.
- notify_card_played(player, played_card)[source]
Called when a player plays any card.
- Parameters:
player (
_Player) –played_card (
Card) –
- Return type:
None
- notify_trick_won(player)[source]
Called when a trick is won.
- Parameters:
player (
_Player) –- Return type:
None
- notify_bets_made(bets)[source]
Called when all bets have been finalised.
- Parameters:
bets (
Iterator[tuple[_Player,Bet]]) –- Return type:
None
- notify_new_trick(player_id)[source]
Called when a trick is about to start (starting with player_id).
- Parameters:
player_id (
int) –- Return type:
None
- __init__(*args, **kwargs)