Skip to main content

Ismcts

Struct Ismcts 

Source
pub struct Ismcts { /* private fields */ }
Expand description

Single-observer information-set MCTS for hidden-information games.

Standard Mcts cheats at hidden information: it searches the one true state, so it sees opponents’ secret cards. ISMCTS instead searches from a player’s information set. Each simulation asks the game for a fresh determinization (Determinize::determinize) — a full world consistent with what the searcher can see, but with the hidden parts resampled — and runs one UCT iteration in that world. Averaging over many sampled worlds yields a move that is good on expectation without ever peeking.

A single tree is shared across determinizations. Because different worlds offer different legal moves, selection uses an availability count (how many simulations a move was legal for) in the UCB denominator, and only moves legal in the current world are considered. Values are backed up as a vector, one entry per seat, and each node selects to maximize the mover’s own entry (max^n), so this handles three- and four-player games, not just two-player zero-sum. Rollouts are uniform-random. All randomness comes from an internal seeded generator, so a run is reproducible.

Implementations§

Source§

impl Ismcts

Source

pub const fn new(iterations: u32, seed: u64) -> Self

Creates a search running iterations simulations per move, seeded from seed. Uses the standard UCT exploration constant (sqrt 2).

Source

pub const fn with_exploration(self, exploration: f64) -> Self

Sets the UCT exploration constant (higher explores more).

Source

pub fn evaluate<G>( &mut self, game: &G, state: &G::State, player: PlayerId, ) -> f64
where G: Determinize, G::State: Clone, G::Action: Clone,

Estimates player’s value of state as the mean rollout reward over sampled worlds, searching from player’s information set.

Trait Implementations§

Source§

impl<G> Bot<G> for Ismcts
where G: Determinize, G::State: Clone, G::Action: Clone,

Source§

fn choose( &mut self, game: &G, state: &G::State, player: PlayerId, ) -> Option<G::Action>

Returns the action to play for player in state, or None if there is nothing to do (no legal actions, e.g. a terminal state).
Source§

impl<G> RankedBot<G> for Ismcts
where G: Determinize, G::State: Clone, G::Action: Clone,

Source§

fn rank( &mut self, game: &G, state: &G::State, player: PlayerId, ) -> Vec<(G::Action, f64)>

Ranks the searcher’s moves by visit share (the ISMCTS policy). Scores are the fraction of simulations spent on each move and sum to 1.

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.