roomai.sevenking package¶
Submodules¶
roomai.sevenking.SevenKingAction module¶
-
class
roomai.sevenking.SevenKingAction.
SevenKingAction
(key)[source]¶ Bases:
roomai.common.common.AbstractAction
The SevenKing action. The SevenKing action contains some cards. Examples of usages:
>> import roomai.sevenking
>> action = roomai.sevenking.SevenKingAction.lookup(“A_Spade,A_Heart”)
>> ## We strongly recommend you to get an action with the lookup function.
>> action.key
“A_Heart, A_Spade”
>> action.cards[0].point “A”
>> action.cards[0].suit “Heart”
>> action.pattern
p_2 # 2 cards in this action
-
cards
¶ The cards in this action. For example, cards=[roomai.sevenking.SevenKingPokerCards.lookup(“A_Spade”)]
-
key
¶ The key of this action. For example, key = “3_Heart,3_Spade”. The check action’s key = “”
-
classmethod
lookup
(key)[source]¶ lookup a SevenKing action with the specified key
Parameters: key – The specified key Returns: The action
-
pattern
¶ The pattern of the action
-
roomai.sevenking.SevenKingEnv module¶
-
class
roomai.sevenking.SevenKingEnv.
SevenKingEnv
[source]¶ Bases:
roomai.common.common.AbstractEnv
The SevenKing game environment
-
classmethod
compete
(env, players)[source]¶ Use the game environment to hold a compete for the players
Parameters: - env – The game environment
- players – The players
Returns: scores for the players
-
forward
(action)[source]¶ The SevenKing game environment steps with the action taken by the current player
Parameters: action – Returns:
-
init
(params={})[source]¶ Initialize the SevenKing game environment with the initialization params.
The initialization is a dict with some options
- allcards: the order of all poker cards appearing
- record_history: whether to record all history states. if you need call the backward function, please set it to True. default False
- num_players: how many players are in the game
An example of the initialization param is {“num_players”:2,”record_history”:True}
Parameters: params – the initialization params Returns: infos, public_state, person_states, private_state
-
classmethod
roomai.sevenking.SevenKingInfo module¶
-
class
roomai.sevenking.SevenKingInfo.
SevenKingPersonState
[source]¶ Bases:
roomai.common.common.AbstractPersonState
The person state of SevenKing
-
hand_cards
¶ The hand cards of the person state. For example, hand_cards = [roomai.sevenking.SevenKingPokerCard.lookup(“A_Spade”)]
-
hand_cards_key
¶ The hand cards key of the person state. For example, hand_cards_key = “3_Spade,A_Spade”
-
hand_cards_keyset
¶ The set of the poker cards’ key in the hand cards. For example, hand_cards_keyset={“A_Spade”}
-
-
class
roomai.sevenking.SevenKingInfo.
SevenKingPrivateState
[source]¶ Bases:
roomai.common.common.AbstractPrivateState
The private state of SevenKing
-
keep_cards
¶ The keep cards
-
-
class
roomai.sevenking.SevenKingInfo.
SevenKingPublicState
[source]¶ Bases:
roomai.common.common.AbstractPublicState
-
is_fold
¶ is_fold is an array of which player has take the fold action. For example, is_fold = [true,true,false] denotes the player0 and player1 have taken the fold action
-
license_action
¶ Generally, the player need takes an action with the same pattern as the license action. Unless the player takes an action at the beginning of a round
-
num_fold
¶ The number of players who has taken the fold action
-
num_hand_cards
¶ The number of cards in different players. For example, num_hand_cards = [3,5,2] denotes the player0 has 3 poker cards, the player1 has 5 poker cards and the player2 has 2 poker cards
-
num_players
¶ The number of players in this game
-
num_showed_cards
¶ The number of showed poker cards
-
showed_cards
¶ The poker cards have been thrown by the players and are public to all now.For example, showed_cards = [roomai.sevenking.SevenKingPokerCards.lookup(“A_Spade”),roomai.sevenking.SevenKingPokerCards.lookup(“3_Heart”)]
-
stage
¶ There are two stages in SevenKing. In the first stage(stage = 0), the player gets the same number of the poker cards after he takes an action (throws some cards).In the second stage (stage=1), the player doesn’t get the supplement. The player who firstly throws all his hand cards is the winner.
-
roomai.sevenking.SevenKingUtils module¶
-
class
roomai.sevenking.SevenKingUtils.
SevenKingPokerCard
(point, suit=None)[source]¶ Bases:
roomai.common.common.PokerCard
A poker card used in SevenKing game
The suit ranks in the common poker card(roomai.common.PokerCard) and the SevenKing poker card(roomai.SevenKing.SevenKingPokerCard) are different:
The common poker card: ‘Spade’: ‘Spade’:0, ‘Heart’:1, ‘Diamond’:2, ‘Club’:3, ‘ForKing’:4
The SevenKing poker card:’Spade’: 3, ‘Heart’: 2, ‘Club’: 1, ‘Diamond’:0, ‘ForKing’:4