pub struct MonteCarloBot<R: Rng> { /* private fields */ }Expand description
A determinized Monte Carlo player
At every decision the bot samples hidden worlds consistent with its
View — the opponent holds every card they are known to have taken,
and the remaining unseen cards are distributed between their hand and
the stock, biased toward the meld-rich hands a real opponent collects —
plays each world out with the greedy policy on both seats, and picks
the action with the best expected value for the game: each rollout’s
result lands on the running game scores, a
result that reaches game_target counts as the
win or loss of the game it is, and anything short of one counts its
round points. The same worlds are reused across candidate actions
(common random numbers), and the bot deviates from the greedy baseline
only when the paired samples show a statistically clear gain.
The bot owns its random number generator, so a seeded generator makes its play reproducible.
Implementations§
Source§impl<R: Rng> MonteCarloBot<R>
impl<R: Rng> MonteCarloBot<R>
Sourcepub const fn new(rng: R) -> Self
pub const fn new(rng: R) -> Self
A bot with default strength: 128 worlds per decision, 4 candidate discards
Sourcepub const fn samples(self, samples: u32) -> Self
pub const fn samples(self, samples: u32) -> Self
Set how many worlds each decision samples
More samples play stronger and slower. At the default of 128 the
bot wins about 65% of decisive rounds against the default
HeuristicBot — which is tuned for whole-game play and so concedes
single rounds — at ~10 ms per turn in release builds; 32 keeps a
smaller edge at a quarter of the cost.
Sourcepub const fn max_candidates(self, max_candidates: usize) -> Self
pub const fn max_candidates(self, max_candidates: usize) -> Self
Set how many candidate discards play_turn evaluates