OpenSpiel
latest

Getting started

  • What is OpenSpiel?
  • Installation
    • Python-only installation via pip
      • Python-only installation via pip (from source).
    • Installation from Source
    • Summary
    • Installing via Docker
    • Running the first examples
    • Detailed steps
      • Configuring conditional dependencies
      • Installing system-wide dependencies
      • Installing Python dependencies
        • Required dependencies
        • Optional dependencies
      • Building and running tests
      • Setting Your PYTHONPATH environment variable

Core OpenSpiel

  • First examples
  • Concepts
    • The tree representation
  • Loading a game
    • Creating sequential games from simultaneous games
  • Playing a trajectory
  • OpenSpiel Core API Reference
    • Core Functions
    • State methods
    • Game methods
  • Available algorithms
  • Available games
    • Details
      • 2048
      • Amazons
      • Atari
      • Backgammon
      • Bargaining
      • Battleship
      • Blackjack
      • Breakthrough
      • Bridge
      • (Uncontested) Bridge bidding
      • Catch
      • Checkers
      • Cliff Walking
      • Clobber
      • Coin Game
      • Colored Trails
      • Connect Four
      • Cooperative Box-Pushing
      • Chess
      • Crazy Eights
      • Dark Hex
      • Deep Sea
      • Dou Dizhu
      • Euchre
      • First-price Sealed-Bid Auction
      • Gin Rummy
      • Go
      • Goofspiel
      • Hanabi
      • Havannah
      • Hearts
      • Hex
      • Kriegspiel
      • Kuhn poker
      • Laser Tag
      • Leduc poker
      • Lewis Signaling
      • Liar’s Dice
      • Liar’s Poker
      • Mensch Aergere Dich Nicht
      • Mancala
      • Markov Soccer
      • Matching Pennies (Three-player)
      • Mean Field Game : routing
      • Mean Field Game : Linear-Quadratic
      • Morpion Solitaire (4D)
      • Negotiation
      • Nim
      • Oh Hell
      • Oshi-Zumo
      • Oware
      • Pathfinding
      • Pentago
      • Phantom Go
      • Phantom Tic-Tac-Toe
      • Pig
      • Poker (Hold ‘em)
      • Quoridor
      • Reconnaissance Blind Chess
      • Routing game
      • Sheriff
      • Slovenian Tarok
      • Skat (simplified bidding)
      • Solitaire (K+)
      • Tic-Tac-Toe
      • Tiny Bridge
      • Tiny Hanabi
      • Trade Comm
      • Ultimate Tic-Tac-Toe
      • Y

Evaluation

  • Alpha-Rank
    • Importing the Alpha-Rank module
    • Running Alpha-Rank on various games
      • Example: symmetric 2-player game rankings
      • Example: multi-population game rankings
    • Visualizing and reporting results
      • Basic Ranking Outputs
      • Markov Chain Visualization
      • Alpha-sweep plots

Julia OpenSpiel

  • OpenSpiel on Julia
    • Install
    • Known Problems
    • Example
    • Q&A

AlphaZero

  • AlphaZero
    • Background
    • Overview:
      • Model
      • MCTS
      • MCTS Evaluator
      • Actors
      • Learner
      • Evaluators
      • Output
    • Usage:
      • Python
      • C++
      • Analysis
      • Playing vs checkpoints

Developer guide

  • The code structure
  • C++ and Python implementations.
  • Adding a game
  • Conditional dependencies
  • Debugging tools
  • Adding Game-Specific Functionality
  • Language APIs
  • Guidelines
  • Support expectations
    • Bugs
    • Pull requests
  • Roadmap and Call for Contributions

Using OpenSpiel as a C++ Library

  • Using OpenSpiel as a C++ Library
    • Compiling OpenSpiel as a Shared Library
    • Compiling and Running the Example

Extra information

  • Authors
    • OpenSpiel contributors
    • OpenSpiel with Swift for Tensorflow (now removed)
    • External contributors
OpenSpiel
  • Docs »
  • OpenSpiel state methods: legal_actions
  • Edit on GitHub

OpenSpiel state methods: legal_actions¶

Back to Core API reference

  1. legal_actions()

  2. legal_actions(player: int)

Returns the list of legal actions (integers between 0 and game.num_distinct_actions() - 1) for (1) the current player, or (2) the specified player.

When called on a chance node, returns the legal chance outcomes without their corresponding probabilities.

When called on a simultaneous node, returns the set of legal joint actions represented as flat integers, which can then be passed to apply_action.

Examples:¶

import pyspiel

game = pyspiel.load_game("tic_tac_toe")
state = game.new_initial_state()
print(state.legal_actions())
# Output: [0, 1, 2, 3, 4, 5, 6, 7, 8]

game = pyspiel.load_game("matrix_pd")
state = game.new_initial_state()
print(state.legal_actions(0))   # row player
print(state.legal_actions(1))   # column player
# Output:
# [0, 1]
# [0, 1]

© Copyright 2019, DeepMind Technologies Ltd Revision f7a43409.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.