Kuhn Poker¶
An implement of Kuhn Poker game.
We have two players. We have three cards: Jack, Queen, King, where King beats Queen and Queen beats Jack. In this game, each player gets a random card. On a turn, a player can either
pass: do nothing. The opponent wins all chip in the pot.
bet: place a chip in the pot.
After two passes or two bets (not necessarily consecutive), the game ends. Player with the highest card wins.
The Maximum depth of the game tree is 3. The game tree is as follows. Game tree:
[chance]
|
assign cards
|
[player1]
/ \
[pass] [bet]
| |
[player2] [player2]
/ \ / \
pass bet pass bet
| | | |
(h) [player1] (1) (h)
/ \
pass bet
| |
(2) (h)
- Leaf nodes notation:
(h): player has highest card wins!
(1): player 1 wins! (player 2 chickens out)
(2): player 2 wins! (player 1 chickens out)
In this game, we have 12 info-sets. Each info-set has 2 states since the opponent can have any of the two cards that I’m not already holding. We have 4 decision nodes (excluding the chance’s action), and a player’s private information consists of their own card, which takes 3 possible values so we have 3 * 4 = 12 info sets.
Note
There’s a subtle difference between the number of info sets and the number of nodes per info set (the size of the info set). The size of the info set tells us how many worlds are consistent with the player’s observations so far. The number of info sets is more “meta”. A player, without entering into a game / trajectory, can reason ahead about the different info sets that they can be in once some partial observations are available to them when the game starts.
- class imperfecto.games.kuhn_poker.KUHN_POKER_ACTIONS(value)[source]¶
Bases:
imperfecto.misc.utils.lessVerboseEnum
,enum.IntEnum
Available actions in Kuhn Poker.
- PASS = 0¶
- BET = 1¶
- class imperfecto.games.kuhn_poker.KUHN_POKER_CHANCE_ACTIONS(value)[source]¶
Bases:
imperfecto.misc.utils.lessVerboseEnum
,enum.IntEnum
Availble chance actions in Kuhn Poker.
We have 3 cards J, Q, K dealt randomly to 2 players.
- JQ = 0¶
- JK = 1¶
- QK = 2¶
- QJ = 3¶
- KJ = 4¶
- KQ = 5¶
- class imperfecto.games.kuhn_poker.KuhnPokerGame(players)[source]¶
Bases:
imperfecto.games.game.ExtensiveFormGame
A Kuhn Poker (https://en.wikipedia.org/wiki/Kuhn_poker) game class.
- Payoff:
The winner wins whatever is in the pot. A player can win either in showdown by having the highest card or win by having their opponent chickens out.
- Nash equilibrium:
There are infinitely many Nash equilibria. Player one can choose any probability
alpha
in [0, 1/3] to bet when having Jack, and pass when the other play bets. They should bet with probability3 * alpha
when having a King, and if the other player bets, they should bet. They should always pass when having a Queen, and if the other player bets, they should pass. The second player should always bet when having a King; when having a Queen, check if possible otherwise call with probability 1/3. When they have a Jack, they should never call and bet with probability 1/3. The first player’s expected payoff under Nash equilibria is -1/18.
- actions¶
- chance_actions¶
alias of
imperfecto.games.kuhn_poker.KUHN_POKER_CHANCE_ACTIONS
- has_chance_player = True¶
- get_active_player(history)[source]¶
Get the active player of the game at the current decision point.
- get_winner(chance_action)[source]¶
Return the winner of the game given a chance action.
- Parameters
chance_action (
KUHN_POKER_CHANCE_ACTIONS
) – the chance action- Return type
- Returns
the winner (player_id) of the game
- showdown(history)[source]¶
Return the payoff value of the game in the showdown case given a history.
Winner is the player with the highest card. We don’t take into account the amount of chips in the pot. Winner gets +1 point while loser gets -1 point.
- Parameters
history – the history of the game
- Return type
- Returns
the payoff value of the game in the showdown case
- get_payoffs(history)[source]¶
Return the payoff for each player at the current node.
Note
history must be a terminal node.
- Parameters
history – The history of the game.
- Returns
The payoffs of the players at the end of the game.
- get_card(chance_action, player_id)[source]¶
Return the card that a chance action has dealt to a player.
- Parameters
chance_action (
KUHN_POKER_CHANCE_ACTIONS
) – a chance actionplayer_id (
int
) – the player who receives the card
- Return type
- Returns
the card that the chance action has dealt to the player