Crate postflop_solver
source ·Expand description
An open-source postflop solver library.
Examples
See the examples directory.
Implementation details
- Algorithm: The solver uses the state-of-the-art Discounted CFR algorithm. Currently, the value of γ is set to 3.0 instead of the 2.0 recommended in the original paper. Also, the solver resets the cumulative strategy when the number of iterations is a power of 4.
- Performance: The solver engine is highly optimized for performance with maintainable code. The engine supports multithreading by default, and it takes full advantage of unsafe Rust in hot spots. The developer reviews the assembly output from the compiler and ensures that SIMD instructions are used as much as possible. Combined with the algorithm described above, the performance surpasses paid solvers such as PioSOLVER and GTO+.
- Isomorphism: The solver does not perform any abstraction. However, isomorphic chances (turn and river deals) are combined into one. For example, if the flop is monotone, the three non-dealt suits are isomorphic, allowing us to skip the calculation for two of the three suits.
- Precision: 32-bit floating-point numbers are used in most places. When calculating summations, temporary values use 64-bit floating-point numbers. There is also a compression option where each game node stores the values by 16-bit integers with a single 32-bit floating-point scaling factor.
- Bunching effect: At the time of writing, this is the only implementation that can handle the bunching effect. It supports up to four folded players (6-max game). The implementation correctly counts the number of card combinations and does not rely on heuristics such as manipulating the probability distribution of the deck. Note, however, that enabling the bunching effect increases the time complexity of the evaluation at the terminal nodes and slows down the computation significantly.
Crate features
bincode
: Uses bincode crate (2.0.0-rc.3) to serialize and deserialize thePostFlopGame
struct. This feature is required to save and load the game tree. Enabled by default.custom-alloc
: Uses custom memory allocator in solving process (only available in nightly Rust). It significantly reduces the number of calls of the default allocator, so it is recommended to use this feature when the default allocator is not so efficient. Note that this feature assumes that, at most, only one instance ofPostFlopGame
is available when solving in a program. Disabled by default.rayon
: Uses rayon crate for parallelization. Enabled by default.zstd
: Uses zstd crate to compress and decompress the game tree. This feature is required to save and load the game tree with compression. Disabled by default.
Structs
- A struct representing an abstract game tree.
- Bet size options for the first bets and raises.
- A configuration for computing the bunching effect.
- A struct containing the card configuration.
- Bet size options for the donk bets.
- Smart pointer like wrapper that is returned when
MutexLike
is “locked”. - Mutex-like wrapper, but it actually does not perform any locking.
- A struct representing a postflop game.
- A struct representing a node in a postflop game tree.
- A struct representing a player’s range.
- A struct containing the game tree configuration.
Enums
- Available actions of the postflop game.
- Bet size specification.
- An enum representing the board state.
Constants
- Constant representing that the card is not yet dealt.
Traits
- A trait for data that can be saved into a file.
- The trait representing a game.
- The trait representing a node in game tree.
Functions
- Attempts to read the next card from a char iterator.
- Attempts to convert a string into a card.
- Attempts to convert a card into a string.
- Computes the average with given weights.
- Computes the expected values of the current strategy of each player.
- Computes the exploitability of the current strategy.
- Computes the expected values of the MES (Maximally Exploitative Strategy) of each player.
- Finalizes the solving process.
- Attempts to convert an optionally space-separated string into a sorted flop array.
- Attempts to convert hole cards into a string.
- Attempts to convert a list of hole cards into a list of strings.
- Loads data from a file.
- Loads data from a standard reader.
- Saves data into a standard writer.
- Saves data into a file.
- Performs Discounted CFR algorithm until the given number of iterations or exploitability is satisfied.
- Proceeds Discounted CFR algorithm for one iteration.
Type Aliases
- A type representing a card, defined as an alias of
u8
.