Skip to main content

An open-source Python implementation of GPU-accelerated counterfactual regret minimization

Project description

GPUGT

GPU parallelizable implementation of counterfactual regret minimization.

Scripts

Convert games from OpenSpiel.

python scripts/open-spiel-game.py kuhn_poker | python scripts/compress.py > games/kuhn-poker.json
python scripts/open-spiel-game.py leduc_poker | python scripts/compress.py > games/leduc-poker.json
python scripts/open-spiel-game.py liars_dice | python scripts/compress.py > games/liars-dice.json
python scripts/open-spiel-game.py 'battleship(board_height=2,board_width=2,ship_sizes=[2],ship_values=[1],num_shots=3)' | python scripts/compress.py > games/battleship-tiny.json
python scripts/open-spiel-game.py 'battleship(board_height=3,board_width=2,ship_sizes=[2],ship_values=[1],num_shots=3)' | python scripts/compress.py > games/battleship-small.json
python scripts/open-spiel-game.py 'battleship(board_height=4,board_width=4,ship_sizes=[1],ship_values=[1],num_shots=2)' | python scripts/compress.py > games/battleship-medium.json
python scripts/open-spiel-game.py 'battleship(board_height=3,board_width=3,ship_sizes=[1;2],ship_values=[1;1],num_shots=2)' | python scripts/compress.py > games/battleship-large.json
python scripts/open-spiel-game.py 'battleship(board_height=3,board_width=2,ship_sizes=[2],ship_values=[1],num_shots=4)' | python scripts/compress.py > games/battleship-huge.json

Solve games using GPUGT.

python scripts/solve.py \
    games/kuhn-poker.json \
    gpugt.games.TwoPlayerZeroSumExtensiveFormGame \
    gpugt.regret_minimizers.CounterfactualRegretMinimization \
    1024 \
    -a \
    -e figures/gpugt/exploitabilities/kuhn-poker.pdf \
    -v figures/gpugt/values/kuhn-poker.pdf \
    -n "Kuhn poker" \
    > data/gpugt/kuhn-poker.json
python scripts/solve.py \
    games/leduc-poker.json \
    gpugt.games.TwoPlayerZeroSumExtensiveFormGame \
    gpugt.regret_minimizers.CounterfactualRegretMinimization \
    1024 \
    -a \
    -e figures/gpugt/exploitabilities/leduc-poker.pdf \
    -v figures/gpugt/values/leduc-poker.pdf \
    -n "Leduc poker" \
    > data/gpugt/leduc-poker.json
python scripts/solve.py \
    games/liars-dice.json \
    gpugt.games.TwoPlayerZeroSumExtensiveFormGame \
    gpugt.regret_minimizers.CounterfactualRegretMinimization \
    1024 \
    -a \
    -e figures/gpugt/exploitabilities/liars-dice.pdf \
    -v figures/gpugt/values/liars-dice.pdf \
    -n "liar's dice" \
    > data/gpugt/liars-dice.json
python scripts/solve.py \
    games/battleship-tiny.json \
    gpugt.games.TwoPlayerZeroSumExtensiveFormGame \
    gpugt.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/gpugt/values/battleship-tiny.pdf \
    -n "battleship (tiny)" \
    > data/gpugt/battleship-tiny.json
python scripts/solve.py \
    games/battleship-small.json \
    gpugt.games.TwoPlayerZeroSumExtensiveFormGame \
    gpugt.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/gpugt/values/battleship-small.pdf \
    -n "battleship (small)" \
    > data/gpugt/battleship-small.json
python scripts/solve.py \
    games/battleship-medium.json \
    gpugt.games.TwoPlayerZeroSumExtensiveFormGame \
    gpugt.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/gpugt/values/battleship-medium.pdf \
    -n "battleship (medium)" \
    > data/gpugt/battleship-medium.json
python scripts/solve.py \
    games/battleship-large.json \
    gpugt.games.TwoPlayerZeroSumExtensiveFormGame \
    gpugt.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/gpugt/values/battleship-large.pdf \
    -n "battleship (large)" \
    > data/gpugt/battleship-large.json
python scripts/solve.py \
    games/battleship-huge.json \
    gpugt.games.TwoPlayerZeroSumExtensiveFormGame \
    gpugt.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/gpugt/values/battleship-huge.pdf \
    -n "battleship (huge)" \
    > data/gpugt/battleship-huge.json

Solve games using NoRegret.

python scripts/solve.py \
    games/kuhn-poker.json \
    noregret.games.TwoPlayerZeroSumExtensiveFormGame \
    noregret.regret_minimizers.CounterfactualRegretMinimization \
    1024 \
    -a \
    -e figures/noregret/exploitabilities/kuhn-poker.pdf \
    -v figures/noregret/values/kuhn-poker.pdf \
    -n "Kuhn poker" \
    > data/noregret/kuhn-poker.json
python scripts/solve.py \
    games/leduc-poker.json \
    noregret.games.TwoPlayerZeroSumExtensiveFormGame \
    noregret.regret_minimizers.CounterfactualRegretMinimization \
    1024 \
    -a \
    -e figures/noregret/exploitabilities/leduc-poker.pdf \
    -v figures/noregret/values/leduc-poker.pdf \
    -n "Leduc poker" \
    > data/noregret/leduc-poker.json
python scripts/solve.py \
    games/liars-dice.json \
    noregret.games.TwoPlayerZeroSumExtensiveFormGame \
    noregret.regret_minimizers.CounterfactualRegretMinimization \
    1024 \
    -a \
    -e figures/noregret/exploitabilities/liars-dice.pdf \
    -v figures/noregret/values/liars-dice.pdf \
    -n "liar's dice" \
    > data/noregret/liars-dice.json
python scripts/solve.py \
    games/battleship-tiny.json \
    noregret.games.TwoPlayerZeroSumExtensiveFormGame \
    noregret.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/noregret/values/battleship-tiny.pdf \
    -n "battleship (tiny)" \
    > data/noregret/battleship-tiny.json
python scripts/solve.py \
    games/battleship-small.json \
    noregret.games.TwoPlayerZeroSumExtensiveFormGame \
    noregret.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/noregret/values/battleship-small.pdf \
    -n "battleship (small)" \
    > data/noregret/battleship-small.json
python scripts/solve.py \
    games/battleship-medium.json \
    noregret.games.TwoPlayerZeroSumExtensiveFormGame \
    noregret.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/noregret/values/battleship-medium.pdf \
    -n "battleship (medium)" \
    > data/noregret/battleship-medium.json
python scripts/solve.py \
    games/battleship-large.json \
    noregret.games.TwoPlayerZeroSumExtensiveFormGame \
    noregret.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/noregret/values/battleship-large.pdf \
    -n "battleship (large)" \
    > data/noregret/battleship-large.json
python scripts/solve.py \
    games/battleship-huge.json \
    noregret.games.TwoPlayerZeroSumExtensiveFormGame \
    noregret.regret_minimizers.CounterfactualRegretMinimization \
    8 \
    -a \
    -v figures/noregret/values/battleship-huge.pdf \
    -n "battleship (huge)" \
    > data/noregret/battleship-huge.json

Solve games using OpenSpiel (C++).

python scripts/open-spiel-solve.py \
    kuhn_poker \
    pyspiel.CFRSolver \
    1024 \
    -e figures/pyspiel/exploitabilities/kuhn-poker.pdf \
    > data/pyspiel/kuhn-poker.json
python scripts/open-spiel-solve.py \
    leduc_poker \
    pyspiel.CFRSolver \
    1024 \
    -e figures/pyspiel/exploitabilities/leduc-poker.pdf \
    > data/pyspiel/leduc-poker.json
python scripts/open-spiel-solve.py \
    liars_dice \
    pyspiel.CFRSolver \
    1024 \
    -e figures/pyspiel/exploitabilities/liars-dice.pdf \
    > data/pyspiel/liars-dice.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=2,board_width=2,ship_sizes=[2],ship_values=[1],num_shots=3)' \
    pyspiel.CFRSolver \
    8 \
    > data/pyspiel/battleship-tiny.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=3,board_width=2,ship_sizes=[2],ship_values=[1],num_shots=3)' \
    pyspiel.CFRSolver \
    8 \
    > data/pyspiel/battleship-small.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=4,board_width=4,ship_sizes=[1],ship_values=[1],num_shots=2)' \
    pyspiel.CFRSolver \
    8 \
    > data/pyspiel/battleship-medium.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=3,board_width=3,ship_sizes=[1;2],ship_values=[1;1],num_shots=2)' \
    pyspiel.CFRSolver \
    8 \
    > data/pyspiel/battleship-large.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=3,board_width=2,ship_sizes=[2],ship_values=[1],num_shots=4)' \
    pyspiel.CFRSolver \
    8 \
    > data/pyspiel/battleship-huge.json

Solve games using OpenSpiel (Python).

python scripts/open-spiel-solve.py \
    kuhn_poker \
    open_spiel.python.algorithms.cfr.CFRSolver \
    8 \
    > data/open-spiel/kuhn-poker.json
python scripts/open-spiel-solve.py \
    leduc_poker \
    open_spiel.python.algorithms.cfr.CFRSolver \
    8 \
    > data/open-spiel/leduc-poker.json
python scripts/open-spiel-solve.py \
    liars_dice \
    open_spiel.python.algorithms.cfr.CFRSolver \
    8 \
    > data/open-spiel/liars-dice.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=2,board_width=2,ship_sizes=[2],ship_values=[1],num_shots=3)' \
    open_spiel.python.algorithms.cfr.CFRSolver \
    8 \
    > data/open-spiel/battleship-tiny.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=3,board_width=2,ship_sizes=[2],ship_values=[1],num_shots=3)' \
    open_spiel.python.algorithms.cfr.CFRSolver \
    8 \
    > data/open-spiel/battleship-small.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=4,board_width=4,ship_sizes=[1],ship_values=[1],num_shots=2)' \
    open_spiel.python.algorithms.cfr.CFRSolver \
    8 \
    > data/open-spiel/battleship-medium.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=3,board_width=3,ship_sizes=[1;2],ship_values=[1;1],num_shots=2)' \
    open_spiel.python.algorithms.cfr.CFRSolver \
    8 \
    > data/open-spiel/battleship-large.json
python scripts/open-spiel-solve.py \
    'battleship(board_height=3,board_width=2,ship_sizes=[2],ship_values=[1],num_shots=4)' \
    open_spiel.python.algorithms.cfr.CFRSolver \
    8 \
    > data/open-spiel/battleship-huge.json

Summarize results.

python scripts/summary.py \
    8 \
    data/gpugt/kuhn-poker.json \
    data/gpugt/leduc-poker.json \
    data/gpugt/liars-dice.json \
    data/gpugt/battleship-tiny.json \
    data/gpugt/battleship-small.json \
    data/gpugt/battleship-medium.json \
    data/gpugt/battleship-large.json \
    data/gpugt/battleship-huge.json \
    data/noregret/kuhn-poker.json \
    data/noregret/leduc-poker.json \
    data/noregret/liars-dice.json \
    data/noregret/battleship-tiny.json \
    data/noregret/battleship-small.json \
    data/noregret/battleship-medium.json \
    data/noregret/battleship-large.json \
    data/noregret/battleship-huge.json \
    data/pyspiel/kuhn-poker.json \
    data/pyspiel/leduc-poker.json \
    data/pyspiel/liars-dice.json \
    data/pyspiel/battleship-tiny.json \
    data/pyspiel/battleship-small.json \
    data/pyspiel/battleship-medium.json \
    data/pyspiel/battleship-large.json \
    data/pyspiel/battleship-huge.json \
    data/open-spiel/kuhn-poker.json \
    data/open-spiel/leduc-poker.json \
    data/open-spiel/liars-dice.json \
    data/open-spiel/battleship-tiny.json \
    data/open-spiel/battleship-small.json \
    data/open-spiel/battleship-medium.json \
    data/open-spiel/battleship-large.json \
    data/open-spiel/battleship-huge.json \
    > data/summary.csv
python scripts/plot.py figures/plot.pdf < data/summary.csv
python scripts/latex.py < data/summary.csv > data/latex.tex

Citing

If you use GPUGT in your research, please cite our preprint:

@misc{kim2024gpuacceleratedcounterfactualregretminimization,
      title={GPU-Accelerated Counterfactual Regret Minimization},
      author={Juho Kim},
      year={2024},
      eprint={2408.14778},
      archivePrefix={arXiv},
      primaryClass={cs.GT},
      url={https://arxiv.org/abs/2408.14778},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpugt-0.0.0.dev2.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gpugt-0.0.0.dev2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file gpugt-0.0.0.dev2.tar.gz.

File metadata

  • Download URL: gpugt-0.0.0.dev2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for gpugt-0.0.0.dev2.tar.gz
Algorithm Hash digest
SHA256 e864e277c9e6f3990e3c28d113c43d5073a01c5c653499a59c8867fdd53912d5
MD5 0a2360d3a320fbd153c0070b91457589
BLAKE2b-256 970a2723591cb3e29ba4a4a1870503abd7f2dc973ab529af7d2b4a1b212aac7d

See more details on using hashes here.

File details

Details for the file gpugt-0.0.0.dev2-py3-none-any.whl.

File metadata

  • Download URL: gpugt-0.0.0.dev2-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for gpugt-0.0.0.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 7603b16390ac6a5005e95068fba89c18bc9e56a7e06bf99a850179358be093be
MD5 7f8ed626000e23cd7e6b508e009380f9
BLAKE2b-256 be1d9beb14b4c1e378220e6c0620089aa75ee65fa3d5661958cea6195719e159

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page