TexasSolver is a free open-source C++17 library for solving poker subgames and computing exploitability/value metrics with DCFR-style algorithms.
This repository is a C++ port of the Rust implementation from amaster97/poker_solver
The code and layout here are organized so the project can be consumed as a normal CMake dependency from another C++ project.
- Kuhn poker solver
- Leduc poker solver
- Hold'em game-state logic
- HUNL postflop and preflop solver code
- Exploitability and game-value evaluation
- Preflop equity helpers
- Vendored
pokerHandEvaluatorsubmodule for fast 5-card, 6-card, and 7-card hand ranking - Abstraction / layout / SIMD / suit-isomorphism utilities
The main library target is:
TexasSolver::texas_core
When installed, the package exports a CMake config file so another project can use find_package(TexasSolver CONFIG REQUIRED).
- CMake 3.20 or newer
- A C++17 compiler
- A working build toolchain for your platform
On Windows the project builds with Visual Studio/MSBuild. On other platforms a normal CMake generator is fine.
The repository includes external/pokerHandEvaluator as a Git submodule. The top-level CMake build wires that vendored library into texas_core so fixed-size hand evaluation can use the faster evaluate_5cards, evaluate_6cards, and evaluate_7cards paths.
cmake -S . -B buildcmake --build build --config Releasectest --test-dir build -C Release --output-on-failureYou can install the library and export its CMake package files:
cmake -S . -B build
cmake --build build --config Release
cmake --install build --config Release --prefix <install-prefix>This installs:
- headers under
<prefix>/include - the library archive / import library under
<prefix>/libor the platform equivalent - CMake package files under
<prefix>/lib/cmake/TexasSolver
When building from the repository, the vendored hand evaluator is also configured through CMake. If you need to turn it off for debugging or portability work, set TEXASSOLVER_USE_POKER_HAND_EVALUATOR=OFF during configuration.
Add this repository as a Git submodule inside your own project:
git submodule add https://github.com/ArtemIyX/TexasSolverLib
git submodule update --init --recursiveThen in your top-level CMakeLists.txt:
add_subdirectory(external/TexasSolver)
target_link_libraries(your_target PRIVATE TexasSolver::texas_core)If the library has been installed to a prefix, consume it from another project like this:
find_package(TexasSolver CONFIG REQUIRED)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE TexasSolver::texas_core)If CMake cannot find the package automatically, set one of:
TexasSolver_DIR=<prefix>/lib/cmake/TexasSolveror:
CMAKE_PREFIX_PATH=<prefix>#include "solver/solver.hpp"
#include <iostream>
int main() {
const auto out = core::solve_kuhn(200, 1.5, 0.0, 2.0);
std::cout << "iterations: " << out.iterations << '\n';
std::cout << "game value: " << out.game_value << '\n';
std::cout << "exploitability: " << out.exploitability << '\n';
}#include "solver/solver.hpp"
int main() {
const auto out = core::solve_leduc(50, 1.5, 0.0, 2.0);
return out.average_strategy.empty() ? 1 : 0;
}#include "core/lib.hpp"
int main() {
const auto out = core::lib::solve_kuhn(200, 1.5, 0.0, 2.0);
return out.iterations == 200 ? 0 : 1;
}- The namespace used by the C++ code is still
core::. - The repository structure has been grouped by module so the include paths stay readable.
This project is distributed under the MIT License. See LICENSE.