rlcard.envs

rlcard.envs.env

class rlcard.envs.env.Env(config)

Bases: object

The base Env class

get_payoffs()

Get the payoffs of players. Must be implemented in the child class.

Returns

A list of payoffs for each player.

Return type

(list)

Note: Must be implemented in the child class.

get_perfect_information()

Get the perfect information of the current state

Returns

A dictionary of all the perfect information of the current state

Return type

(dict)

Note: Must be implemented in the child class.

get_player_id()

Get the current player id

Returns

The id of the current player

Return type

(int)

get_state(player_id)

Get the state given player id

Parameters

player_id (int) – The player id

Returns

The observed state of the player

Return type

(numpy.array)

init_game()
is_over()

Check whether the curent game is over

Returns

True is current game is over

Return type

(boolean)

reset()

Reset environment in single-agent mode Call _init_game if not in single agent mode

run(is_training=False)

Run a complete game, either for evaluation or training RL agent.

Parameters

is_training (boolean) – True if for training purpose.

Returns

(list): A list of trajectories generated from the environment. (list): A list payoffs. Each entry corresponds to one player.

Return type

(tuple) Tuple containing

Note: The trajectories are 3-dimension list. The first dimension is for different players.

The second dimension is for different transitions. The third dimension is for the contents of each transiton

set_agents(agents)

Set the agents that will interact with the environment

Parameters

agents (list) – List of Agent classes

step(action, raw_action=False)

Step forward

Parameters
  • action (int) – The action taken by the current player

  • raw_action (boolean) – True if the action is a raw action

Returns

Tuple containing:

(dict): The next state (int): The ID of the next player

Return type

(tuple)

step_back()

Take one step backward.

Returns

Tuple containing:

(dict): The previous state (int): The ID of the previous player

Return type

(tuple)

Note: Error will be raised if step back from the root node.

rlcard.envs.registration

class rlcard.envs.registration.EnvRegistry

Bases: object

Register an environment (game) by ID

make(env_id, config={'active_player': 0, 'allow_raw_data': False, 'allow_step_back': False, 'env_num': 1, 'record_action': False, 'seed': None, 'single_agent_mode': False})

Create and environment instance

Parameters
  • env_id (string) – The name of the environment

  • config (dict) – A dictionary of the environment settings

register(env_id, entry_point)

Register an environment

Parameters
  • env_id (string) – The name of the environent

  • entry_point (string) – A string the indicates the location of the envronment class

class rlcard.envs.registration.EnvSpec(env_id, entry_point=None)

Bases: object

A specification for a particular instance of the environment.

make(config={'active_player': 0, 'allow_raw_data': False, 'allow_step_back': False, 'env_num': 1, 'record_action': False, 'seed': None, 'single_agent_mode': False})

Instantiates an instance of the environment

Returns

An instance of the environemnt config (dict): A dictionary of the environment settings

Return type

env (Env)

rlcard.envs.registration.make(env_id, config={})

Create and environment instance

Parameters
  • env_id (string) – The name of the environment

  • config (dict) – A dictionary of the environment settings

  • env_num (int) – The number of environments

rlcard.envs.registration.register(env_id, entry_point)

Register an environment

Parameters
  • env_id (string) – The name of the environent

  • entry_point (string) – A string the indicates the location of the envronment class

rlcard.envs.blackjack

class rlcard.envs.blackjack.BlackjackEnv(config)

Bases: rlcard.envs.env.Env

Blackjack Environment

get_payoffs()

Get the payoff of a game

Returns

list of payoffs

Return type

payoffs (list)

rlcard.envs.doudizhu

class rlcard.envs.doudizhu.DoudizhuEnv(config)

Bases: rlcard.envs.env.Env

Doudizhu Environment

get_payoffs()

Get the payoffs of players. Must be implemented in the child class.

Returns

a list of payoffs for each player

Return type

payoffs (list)

rlcard.envs.limitholdem

class rlcard.envs.limitholdem.LimitholdemEnv(config)

Bases: rlcard.envs.env.Env

Limitholdem Environment

get_payoffs()

Get the payoff of a game

Returns

list of payoffs

Return type

payoffs (list)

get_perfect_information()

Get the perfect information of the current state

Returns

A dictionary of all the perfect information of the current state

Return type

(dict)

rlcard.envs.gin_rummy

File name: envs/gin_rummy.py Author: William Hale Date created: 2/12/2020

class rlcard.envs.gin_rummy.GinRummyEnv(config)

Bases: rlcard.envs.env.Env

GinRummy Environment

get_payoffs()

Get the payoffs of players. Must be implemented in the child class.

Returns

a list of payoffs for each player

Return type

payoffs (list)

rlcard.envs.leducholdem

class rlcard.envs.leducholdem.LeducholdemEnv(config)

Bases: rlcard.envs.env.Env

Leduc Hold’em Environment

get_payoffs()

Get the payoff of a game

Returns

list of payoffs

Return type

payoffs (list)

get_perfect_information()

Get the perfect information of the current state

Returns

A dictionary of all the perfect information of the current state

Return type

(dict)

rlcard.envs.mahjong

class rlcard.envs.mahjong.MahjongEnv(config)

Bases: rlcard.envs.env.Env

Mahjong Environment

get_payoffs()

Get the payoffs of players. Must be implemented in the child class.

Returns

a list of payoffs for each player

Return type

payoffs (list)

rlcard.envs.nolimitholdem

class rlcard.envs.nolimitholdem.NolimitholdemEnv(config)

Bases: rlcard.envs.env.Env

Limitholdem Environment

get_payoffs()

Get the payoff of a game

Returns

list of payoffs

Return type

payoffs (list)

get_perfect_information()

Get the perfect information of the current state

Returns

A dictionary of all the perfect information of the current state

Return type

(dict)

rlcard.envs.simpledoudizhu

class rlcard.envs.simpledoudizhu.SimpleDoudizhuEnv(config)

Bases: rlcard.envs.env.Env

SimpleDoudizhu Environment

get_payoffs()

Get the payoffs of players. Must be implemented in the child class.

Returns

a list of payoffs for each player

Return type

payoffs (list)

rlcard.envs.uno

class rlcard.envs.uno.UnoEnv(config)

Bases: rlcard.envs.env.Env

get_payoffs()

Get the payoffs of players. Must be implemented in the child class.

Returns

A list of payoffs for each player.

Return type

(list)

Note: Must be implemented in the child class.