pub struct SolverGame { /* private fields */ }Expand description
Everything about a solve that training does not change.
It holds the tree, the ranges, board caches, card abstraction, and
suit-symmetry groups. Its read methods (evaluate, exploitability,
average_strategy) take a Policy, so they can run while a Trainer
keeps training. Get one from Trainer::game.
Implementations§
Source§impl SolverGame
impl SolverGame
Sourcepub fn evaluate(&self, policy: &Policy) -> Evaluation
pub fn evaluate(&self, policy: &Policy) -> Evaluation
Values at every decision node under policy.
Reads only the game and policy, so it can run while training continues and
always describes the iteration policy was taken at. One call walks the
whole tree, so call it once and index the result rather than once per node.
§Examples
trainer.train(100);
let evaluation = trainer.game().evaluate(&trainer.policy());
assert_eq!(evaluation.nodes.len(), trainer.game().num_decision_nodes());
// Root values are zero-sum.
let [oop, ip] = evaluation.root_values;
assert!((oop + ip).abs() < 1e-6);
// EV of each OOP combo at the root, in chips.
let root_ev = &evaluation.nodes[0].ev;
assert_eq!(root_ev.len(), trainer.game().combos(Player::Oop).len());Sourcepub fn exploitability(&self, policy: &Policy) -> Exploitability
pub fn exploitability(&self, policy: &Policy) -> Exploitability
How much a best response could gain against policy, in chips.
Runs one best-response pass for each player against the other’s policy; see
Exploitability for the definition.
Sourcepub fn tree(&self) -> &Node
pub fn tree(&self) -> &Node
The betting tree this trainer is solving, e.g. to look up node ids by walking its structure.
Sourcepub fn board(&self) -> &[Card]
pub fn board(&self) -> &[Card]
The board the tree starts from (Tree::board).
Sourcepub fn node_board(&self, node_id: usize) -> &[Card]
pub fn node_board(&self, node_id: usize) -> &[Card]
The community cards dealt so far at decision node node_id (e.g.
for display, or to label which card a Chance branch led through).
§Panics
Panics if node_id is not below num_decision_nodes.
Sourcepub fn combos(&self, player: Player) -> &[Combo]
pub fn combos(&self, player: Player) -> &[Combo]
player’s combos, in the order of every per-combo result (the combo
axis of average_strategy, NodeEvaluation::ev, and so on).
Sourcepub fn abstraction(&self) -> CardAbstraction
pub fn abstraction(&self) -> CardAbstraction
The card abstraction this game was built with.
Sourcepub fn average_strategy(&self, policy: &Policy, node_id: usize) -> Vec<Vec<f64>>
pub fn average_strategy(&self, policy: &Policy, node_id: usize) -> Vec<Vec<f64>>
The strategy at node_id under policy, as [action][combo] probabilities.
Combos follow the acting player’s range order. With card abstraction, every combo in a bucket reports the bucket’s shared probabilities.
§Panics
Panics if node_id is not below num_decision_nodes
or policy was taken from a different game.
Sourcepub fn policy_from_rows(
&self,
rows: Vec<Vec<Vec<f64>>>,
) -> Result<Policy, PolicyError>
pub fn policy_from_rows( &self, rows: Vec<Vec<Vec<f64>>>, ) -> Result<Policy, PolicyError>
Restores a policy saved from Policy::rows.
The rows must fit this game: one row set per decision node, one row per
action, one entry per bucket, each bucket a probability distribution, and
suit-equivalent buckets identical. Rows are used as given, so reads match
the saved policy bit for bit. See Policy for an example.
§Errors
Returns a PolicyError naming the first node whose rows have the
wrong count or shape, are not distributions, or are not symmetric.
Sourcepub fn bucket_assignments(&self) -> Vec<(&[Card], &[Vec<usize>; 2])>
pub fn bucket_assignments(&self) -> Vec<(&[Card], &[Vec<usize>; 2])>
Each combo’s bucket, per board and player, sorted by board.
Empty when no street is bucketed. A saved policy can use it to check that its rows still describe the same hands.
Sourcepub fn num_decision_nodes(&self) -> usize
pub fn num_decision_nodes(&self) -> usize
Number of decision nodes (valid node_ids are 0..num_decision_nodes).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SolverGame
impl RefUnwindSafe for SolverGame
impl Send for SolverGame
impl Sync for SolverGame
impl Unpin for SolverGame
impl UnsafeUnpin for SolverGame
impl UnwindSafe for SolverGame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more