A decorator that consults an opening book before falling back to the wrapped algorithm.
The book maps a canonical key (see OpeningBook.key) to the chosen continuation, a comma-separated list of long-algebraic micro-moves (e.g. "e2e4,f1c4"). On a book-key hit, if any legal turn path captures the enemy king, the decorator plays the shortest such immediate win path instead of the booked continuation. Otherwise, when the key is present, it plays the booked turn instantly — without spending the underlying bot's search budget — which is exactly where a heuristic or rollout-based engine is weakest and where empirical data is richest. In summary, the precedence order is capture > book > underlying. When the position's key is absent from book, it delegates to underlying.
The booked moves are matched against the position's legal turn paths by move multiset, so the order stored in the book does not matter and an entry that cannot be realised legally (a stale or corrupt book) is silently ignored in favour of the underlying bot rather than played illegally.
Construct via OpeningBookBot.decorate, which preserves the underlying bot's time-budget capability: wrapping a TimeBudgetedSearch yields a TimeBudgetedOpeningBookBot (the deadline reaches the underlying), while wrapping a plain bot yields a plain decorator — so a host's getBestMove does not advertise a time budget for a bot that ignores it.
The decorator delegates all doubling and draw policy queries (shouldOfferDouble, shouldAcceptDouble, shouldOfferDraw, shouldAcceptDraw) unconditionally to underlying, preserving the wrapped bot's custom policies, DrawOfferLogic mix-ins, and default SearchAlgorithm heuristics.
Finds the best full-turn path, drawing any randomness (e.g. tie-breaking among equally-valued turns) from the supplied random. Lets a caller make a whole game reproducible from one seed — most importantly the bot arena, which otherwise gets a fresh unseeded Random per move and so is non-deterministic.
Finds the best full-turn path, drawing any randomness (e.g. tie-breaking among equally-valued turns) from the supplied random. Lets a caller make a whole game reproducible from one seed — most importantly the bot arena, which otherwise gets a fresh unseeded Random per move and so is non-deterministic.
The default ignores random and delegates to the no-arg findBestMove; randomised strategies override it to route their tie-breaking through the given source.
Determines whether the bot should accept (Take) or decline (Drop) a double from the opponent, evaluated from the perspective of responder.
Determines whether the bot should accept (Take) or decline (Drop) a double from the opponent, evaluated from the perspective of responder.
This is the single policy point for the take/drop decision: strategies that want their own threshold or estimator override this overload. The two-argument form below only delegates here, so a policy written against it is bypassed whenever a caller names the responder explicitly (which every caller holding a doubleDecision state must, see the hazard note there).
Value parameters
currentStake
the proposed double stake (e.g. 2, 4...)
responder
the colour of the player responding to the double offer
state
current game state (dice pool is empty); its active colour is the side to move, which in a double decision is the offerer, not the responder
Attributes
Returns
true to accept the double (Take), false to resign the current stake (Drop)
Determines whether the bot should accept (Take) or decline (Drop) a double from the opponent, taking the side to move as the responder. Kept for source and binary compatibility; it delegates to the three-argument overload.
Determines whether the bot should accept (Take) or decline (Drop) a double from the opponent, taking the side to move as the responder. Kept for source and binary compatibility; it delegates to the three-argument overload.
Value parameters
currentStake
the proposed double stake (e.g. 2, 4...)
state
current game state (dice pool is empty)
Attributes
Returns
true to accept the double (Take), false to resign the current stake (Drop)
Note
Perspective hazard: this overload evaluates the win probability of state.activeColor. In a double decision state, state.activeColor is the player who offered the double, NOT the responder, so a caller that feeds the delivered position here asks whether the offerer should take. Callers must prefer shouldAcceptDouble(state, currentStake, responder); strategies must override that overload, not this one.
Estimates the winning probability in [0.0, 1.0] for the side to move. Convenience over winProbability for offer decisions, where the deciding side is the active colour; do not override it, override winProbability.
Estimates the winning probability in [0.0, 1.0] for the side to move. Convenience over winProbability for offer decisions, where the deciding side is the active colour; do not override it, override winProbability.
Estimates the winning probability in [0.0, 1.0] of color, whichever side is to move.
Estimates the winning probability in [0.0, 1.0] of color, whichever side is to move.
This is the estimator hook: a strategy with its own equity model (for example a Monte-Carlo rollout) overrides this method, so that both the offer decision (active colour) and the take/drop decision (responder colour) see the same estimate. The default maps the centipawn evaluation to a probability with a logistic sigmoid.