Skip to main content

SolverGame

Struct SolverGame 

Source
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

Source

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());
Source

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.

Source

pub fn tree(&self) -> &Node

The betting tree this trainer is solving, e.g. to look up node ids by walking its structure.

Source

pub fn board(&self) -> &[Card]

The board the tree starts from (Tree::board).

Source

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.

Source

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).

Source

pub fn abstraction(&self) -> CardAbstraction

The card abstraction this game was built with.

Source

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.

Source

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.

Source

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.

Source

pub fn num_decision_nodes(&self) -> usize

Number of decision nodes (valid node_ids are 0..num_decision_nodes).

Trait Implementations§

Source§

impl Debug for SolverGame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

A summary: board, tree size, range sizes, and abstraction.

Auto Trait Implementations§

§

impl Forget for SolverGame

§

impl Freeze for SolverGame

§

impl Move for SolverGame

§

impl RefUnwindSafe for SolverGame

§

impl Send for SolverGame
where RawVecInner: Send, RawTable<(Vec<Card>, Arc<[Vec<u32>; 2]>)>: Send, RawTable<((Card, Card), usize)>: Send, RawTable<(Vec<Card>, Arc<BoardOrder>)>: Send, RawTable<(Vec<Card>, Arc<[Vec<usize>; 2]>)>: Send, RawTable<(Vec<Card>, Arc<[Vec<Vec<usize>>; 2]>)>: Send, Arc<[Vec<u32>; 2]>: Send, Arc<BoardOrder>: Send, Arc<[Vec<usize>; 2]>: Send, Arc<[Vec<Vec<usize>>; 2]>: Send,

§

impl Sync for SolverGame
where RawVecInner: Sync, RawTable<(Vec<Card>, Arc<[Vec<u32>; 2]>)>: Sync, RawTable<((Card, Card), usize)>: Sync, RawTable<(Vec<Card>, Arc<BoardOrder>)>: Sync, RawTable<(Vec<Card>, Arc<[Vec<usize>; 2]>)>: Sync, RawTable<(Vec<Card>, Arc<[Vec<Vec<usize>>; 2]>)>: Sync, Arc<[Vec<u32>; 2]>: Sync, Arc<BoardOrder>: Sync, Arc<[Vec<usize>; 2]>: Sync, Arc<[Vec<Vec<usize>>; 2]>: Sync,

§

impl Unpin for SolverGame
where *const u8 is !null: Unpin, Arc<[Vec<u32>; 2]>: Unpin, Arc<BoardOrder>: Unpin, Arc<[Vec<usize>; 2]>: Unpin, Arc<[Vec<Vec<usize>>; 2]>: Unpin,

§

impl UnsafeUnpin for SolverGame

§

impl UnwindSafe for SolverGame

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.