Skip to content

Varun-39/gambit-efg-fix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EFG Non-Terminal Payoffs Fix for OpenSpiel

The Problem

OpenSpiel's export_gambit() in gambit.py only handles payoffs at terminal nodes via state.returns(). Games with intermediate (non-terminal) rewards — supported by both OpenSpiel and Gambit's .efg format — are silently exported incorrectly.

The Fix

Modified build_tree() to check state.rewards() at chance and player nodes. Non-zero intermediate rewards are now encoded as outcome blocks in the .efg output.

How to Run & Known Complications

OpenSpiel includes a high-performance C++ backend. Because of this, running the Python code requires either a pre-compiled pyspiel wheel or a full C++ build environment. Running this locally depends heavily on your OS and Python version:

Method 1: Linux or WSL (Recommended)

This is the smoothest path, as OpenSpiel has extensive support for Linux environments.

  1. Create a virtual environment with Python 3.9 - 3.11: python3 -m venv venv
  2. Activate it: source venv/bin/activate
  3. Install OpenSpiel: pip install open_spiel
  4. Run the exporter:
    import pyspiel
    from open_spiel.python.algorithms.gambit import export_gambit
    game = pyspiel.load_game("catch")
    print(export_gambit(game))

Method 2: Native Windows (The Complication)

OpenSpiel does NOT publish pre-compiled .whl files for Windows on PyPI. regardless of your Python version.

If you attempt to run pip install open_spiel naively on Windows Command Prompt or PowerShell, pip will forcibly download the raw C++ .tar.gz source and attempt to natively compile compiling over 1GB of C++ code locally.

This will instantly crash unless you have fully installed and configured:

  • CMake
  • Visual Studio C++ Build Tools (MSVC)
  • Clang / LLVM

Workaround for Windows Users: If you want to use OpenSpiel locally on a Windows machine rapidly without an arduous 2-hour native C++ compilation setup, you must use Method 1 (WSL). Alternatively, you can follow the official Windows Native Compilation Guide.

Note: The included gambit_test.py strictly tests the Python logic and will pass flawlessly in any CI environment (like GitHub Actions) where the OpenSpiel C++ backend is properly built.

Related GSoC Idea

https://www.gambit-project.org/gsoc_2026/#idea-8

Status

This is a pre-GSoC proof-of-concept. A full PR to OpenSpiel will include tests, NFG exporter fixes, and documentation.

About

Pre-GSoC PoC: Fix for OpenSpiel EFG exporter to support non-terminal payoffs (Gambit GSoC 2026 Idea 8)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages