OpenSpiel#
Installation#
pip install shimmy[pettingzoo]
Usage#
import pyspiel
from shimmy.openspiel_compatibility import OpenspielCompatibilityV0
env = pyspiel.load_game("2048")
env = OpenspielCompatibilityV0(game=env, render_mode=None)
Class Description#
- class shimmy.openspiel_compatibility.OpenspielCompatibilityV0(game: pyspiel.Game, render_mode: str | None)#
This compatibility wrapper that converts an openspiel environment into a pettingzoo environment.
OpenSpiel is a collection of environments and algorithms for research in general reinforcement learning and search/planning in games. OpenSpiel supports n-player (single- and multi- agent) zero-sum, cooperative and general-sum, one-shot and sequential, strictly turn-taking and simultaneous-move, perfect and imperfect information games, as well as traditional multiagent environments such as (partially- and fully- observable) grid worlds and social dilemmas.
- metadata: Dict[str, Any] = {'render_modes': []}#
- possible_agents: List[AgentID]#
- observation_space(agent: str)#
observation_space.
We get the observation space from the underlying game. OpenSpiel possibly provides information and observation in several forms. This wrapper chooses which one to use depending on the following precedence:
Observation Tensor
Information Tensor
Observation String
Information String
- Parameters:
agent (AgentID) – agent
- action_space(agent: str)#
action_space.
- Parameters:
agent (AgentID) – agent
- render()#
render.
- observe(agent: str)#
observe.
- Parameters:
agent (AgentID) – agent
- close()#
close.
- reset(seed: int | None = None, return_info: bool | None = False, options: dict | None = None)#
reset.
- Parameters:
seed (Optional[int]) – seed
return_info (Optional[bool]) – return_info
options (Optional[Dict]) – options
- step(action: int)#
Steps the environment.
- Parameters:
action (int) – action
- agents: List[AgentID]#
- observation_spaces: Dict[AgentID, gymnasium.spaces.Space]#
- action_spaces: Dict[AgentID, gymnasium.spaces.Space]#
- terminations: Dict[AgentID, bool]#
- truncations: Dict[AgentID, bool]#
- rewards: Dict[AgentID, float]#
- infos: Dict[AgentID, Dict[str, Any]]#
- agent_selection: AgentID#