|
io-chess
UCI chess engine
|
Monte Carlo Tree Search engine. More...
#include <MCTS.h>


Public Member Functions | |
| MCTS (IEvaluator &eval) | |
| Move | startSearch (Board &root, const SearchParams ¶ms) override |
| Starts the search process on the given root board. | |
| void | stop () override |
| Asynchronously signals the search to stop immediately. | |
| bool | isSearching () const override |
| Checks if the search algorithm is currently running. | |
| void | setInfoCallback (InfoCallback callback) override |
| Sets the callback function for periodic information updates. | |
| uint64_t | getNodes () const override |
| Retrieves the total number of nodes evaluated by the search algorithm. | |
| void | setExplorationConstant (float c) |
| Sets the exploration constant (Cp) used in the UCB calculation. | |
| Public Member Functions inherited from ISearch | |
| virtual | ~ISearch ()=default |
Private Member Functions | |
| MCTSNode * | selection (MCTSNode *node, Board &board) |
| void | expansion (MCTSNode *node, Board &board) |
| float | simulation (Board &board) |
| void | backpropagation (MCTSNode *node, float value) |
| MCTSNode * | selectBestChild (MCTSNode *node) const |
| MCTSNode * | selectUCBChild (MCTSNode *node) const |
Private Attributes | |
| IEvaluator & | evalCtx_ |
| The evaluator used for leaf node evaluation. | |
| std::unique_ptr< MCTSNode > | root_ |
| Root node of the search tree. | |
| std::atomic< bool > | stopFlag_ {false} |
| Signals the search to stop. | |
| std::atomic< bool > | searching_ {false} |
| True while a search is active. | |
| std::atomic< uint64_t > | nodes_ {0} |
| Total nodes visited. | |
| float | explorationConstant_ = 1.41f |
| Weight of exploration in UCB formula. | |
| int | maxPlayouts_ = 100000 |
| Hard limit on search iterations. | |
| InfoCallback | infoCallback_ |
| Callback for UCI info updates. | |
Monte Carlo Tree Search engine.
Implements the ISearch interface. Explores the game tree asymmetrically by repeatedly selecting, expanding, simulating, and backpropagating.
| MCTS::MCTS | ( | IEvaluator & | eval | ) |
|
private |



|
inlineoverridevirtual |
Retrieves the total number of nodes evaluated by the search algorithm.
Implements ISearch.
|
inlineoverridevirtual |
Checks if the search algorithm is currently running.
Implements ISearch.




|
inline |
Sets the exploration constant (Cp) used in the UCB calculation.
|
inlineoverridevirtual |
Sets the callback function for periodic information updates.
| callback | The function to call with depth, score, node count, NPS, and PV. |
Implements ISearch.
|
private |

|
overridevirtual |
Starts the search process on the given root board.
This is a blocking call that will execute the search algorithm until the stopping conditions in params (or stop()) are met.
| root | The starting board position. |
| params | The time and depth constraints for the search. |
Implements ISearch.

|
inlineoverridevirtual |
Asynchronously signals the search to stop immediately.
This method must be thread-safe.
Implements ISearch.
|
private |
The evaluator used for leaf node evaluation.
|
private |
Weight of exploration in UCB formula.
|
private |
Callback for UCI info updates.
|
private |
Hard limit on search iterations.
|
private |
Total nodes visited.
|
private |
Root node of the search tree.
|
private |
True while a search is active.
|
private |
Signals the search to stop.