Pure CFR+ core over a 169-class abstraction, push/fold and open/call/3-bet games, Nash/Kuhn/plausibility/lookup tests, chartgen binary, frozen equity and charts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
1.3 KiB
Rust
28 lines
1.3 KiB
Rust
//! Game value, best-response gains and exploitability of a fixed strategy.
|
|
//!
|
|
//! Units are those of the payoffs (big blinds per deal for the poker spots). For a zero-sum game
|
|
//! `exploitability = gain(player 0) + gain(player 1) >= 0`, and it is 0 exactly at a Nash
|
|
//! equilibrium. `gain(p)` is what player `p` wins by best-responding to the other's fixed
|
|
//! strategy, over what `p` gets from the strategy itself.
|
|
|
|
use super::strategy::Strategy;
|
|
use super::tree::Tree;
|
|
use super::value_walk::{root_values, Responder};
|
|
|
|
/// Expected result for player 0.
|
|
pub fn game_value(tree: &Tree, strategy: &Strategy) -> f64 {
|
|
root_values(tree, strategy, Responder::Follow, 0, &mut |_| {}).iter().sum()
|
|
}
|
|
|
|
/// Best-response value minus strategy value for `player` (0 or 1), against the other's strategy.
|
|
pub fn best_response_gain(tree: &Tree, strategy: &Strategy, player: usize) -> f64 {
|
|
let player = player.min(1);
|
|
let best: f64 = root_values(tree, strategy, Responder::Best, player, &mut |_| {}).iter().sum();
|
|
let own: f64 = root_values(tree, strategy, Responder::Follow, player, &mut |_| {}).iter().sum();
|
|
best - own
|
|
}
|
|
|
|
pub fn exploitability(tree: &Tree, strategy: &Strategy) -> f64 {
|
|
best_response_gain(tree, strategy, 0) + best_response_gain(tree, strategy, 1)
|
|
}
|