Code Monkey home page Code Monkey logo

cpp-cfr's Introduction

Cpp CFR

This repository is C++ implementations of Counterfactual Regret Minimization (CFR) [1] algorithms for an extensive-form game with imperfect information. CFR is an iterative algorithm that is proven to converge to a Nash equilibrium in two-player zero-sum games. Currently, this repository provides the following variants of CFR implementation:

  • vanilla CFR [1]
  • Chance-Sampling Monte Carlo CFR [2]
  • External-Sampling Monte Carlo CFR [2]
  • Outcome-Sampling Monte Carlo CFR [2]

Dependencies

  • C++ compiler supporting C++14
  • CMake 3.5 or higher
  • Boost 1.68.0 or higher

Getting start

Computing an approximate Nash equilibrium

In order to compute an approximate Nash equilibrium in an imperfect information game, first, you should build the project:

$ sh build.sh
$ cd build

Next, execute the following commands to run an experiment:

$ ./RegretMinimization/run_cfr --iteration=1000000

This command requires an argument that specifies the number of iterations of CFR.

In addition to this argument, the following options can be selected:

  • -a, --algorithm: A variant of CFR algorithm computing an equilibrium. You must specify "vanilla", "chance", "external" or "outcome". The default value is "vanilla".
  • -i, --iteration: A number of iterations of CFR.
  • -s, --seed: A random seed used to initialize the random generator. If you don't specify this argument, the random seed will be set to the random number generated by std::random_device.

Once the experiment is completed, you should have a binary file that represents the average strategy, like strategies/kuhn/strategy_vanilla.bin.

Evaluating average strategies

If you have finished computing an approximate Nash equilibrium, you can compute the expected payoffs and exploitability of the obtained average strategy profile:

$ ./Game/game --strategy-path-0="../strategies/kuhn/strategy_vanilla.bin" --strategy-path-1="../strategies/kuhn/strategy_vanilla.bin"

This command requires arguments that the paths to the binary files that represent the average strategies for players. You should specify the path for each player as strategy-path-0, strategy-path-1 and so on.

As a result of executing these commands, the command-line interface will output the expected payoffs and exploitability of the given strategy profile:

expected payoffs: (-0.0555556,0.0555556,)
exploitability: 6.59955e-06

Running with Docker

This repository also provides Dockerfile for docker users. If you want to run with Docker, build the container:

$ docker build -t cpp-cfr .

After build finished, run the container:

$ docker run -it cpp-cfr

References

[1] Martin Zinkevich, Michael Johanson, Michael Bowling, and Carmelo Piccione. Regret minimization in games with incomplete information. In Advances in neural information processing systems, pp. 1729โ€“1736, 2008.

[2] Marc Lanctot, Kevin Waugh, Martin Zinkevich, and Michael Bowling. Monte carlo sampling for regret minimization in extensive games. In Advances in neural information processing systems, pp. 1078โ€“1086, 2009.

cpp-cfr's People

Contributors

bakanaouji avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.