rlcard.games.uno¶
rlcard.games.uno.card¶
- class rlcard.games.uno.card.UnoCard(card_type, color, trait)¶
Bases:
object
- get_str()¶
Get the string representation of card
- Returns
The string of card’s color and trait
- Return type
(str)
- info = {'color': ['r', 'g', 'b', 'y'], 'trait': ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'skip', 'reverse', 'draw_2', 'wild', 'wild_draw_4'], 'type': ['number', 'action', 'wild']}¶
rlcard.games.uno.dealer¶
- class rlcard.games.uno.dealer.UnoDealer(np_random)¶
Bases:
object
Initialize a uno dealer class
- deal_cards(player, num)¶
Deal some cards from deck to one player
- flip_top_card()¶
Flip top card when a new game starts
- Returns
The object of UnoCard at the top of the deck
- Return type
(object)
- shuffle()¶
Shuffle the deck
rlcard.games.uno.game¶
- class rlcard.games.uno.game.UnoGame(allow_step_back=False, num_players=2)¶
Bases:
object
- configure(game_config)¶
Specifiy some game specific parameters, such as number of players
- get_legal_actions()¶
Return the legal actions for current player
- Returns
A list of legal actions
- Return type
(list)
- static get_num_actions()¶
Return the number of applicable actions
- Returns
The number of actions. There are 61 actions
- Return type
(int)
- get_num_players()¶
Return the number of players in Limit Texas Hold’em
- Returns
The number of players in the game
- Return type
(int)
- get_payoffs()¶
Return the payoffs of the game
- Returns
Each entry corresponds to the payoff of one player
- Return type
(list)
- get_state(player_id)¶
Return player’s state
- init_game()¶
Initialize players and state
- Returns
Tuple containing:
(dict): The first state in one game (int): Current player’s id
- Return type
(tuple)
- is_over()¶
Check if the game is over
- Returns
True if the game is over
- Return type
(boolean)
- step(action)¶
Get the next state
rlcard.games.uno.judger¶
rlcard.games.uno.player¶
rlcard.games.uno.round¶
- class rlcard.games.uno.round.UnoRound(dealer, num_players, np_random)¶
Bases:
object
- flip_top_card()¶
Flip the top card of the card pile
- Returns
the top card in game
- Return type
(object of UnoCard)
- get_legal_actions(players, player_id)¶
- get_state(players, player_id)¶
Get player’s state
- perform_top_card(players, top_card)¶
Perform the top card
- proceed_round(players, action)¶
Call other Classes’s functions to keep one round running
- replace_deck()¶
Add cards have been played to deck
rlcard.games.uno.utils¶
- rlcard.games.uno.utils.cards2list(cards)¶
Get the corresponding string representation of cards
- Parameters
cards (list) – list of UnoCards objects
- Returns
string representation of cards
- Return type
(string)
- rlcard.games.uno.utils.encode_hand(plane, hand)¶
Encode hand and represerve it into plane
- Parameters
plane (array) – 3*4*15 numpy array
hand (list) – list of string of hand’s card
- Returns
3*4*15 numpy array
- Return type
(array)
- rlcard.games.uno.utils.encode_target(plane, target)¶
Encode target and represerve it into plane
- Parameters
plane (array) – 1*4*15 numpy array
target (str) – string of target card
- Returns
1*4*15 numpy array
- Return type
(array)
- rlcard.games.uno.utils.hand2dict(hand)¶
Get the corresponding dict representation of hand
- rlcard.games.uno.utils.init_deck()¶
Generate uno deck of 108 cards