io-chess
UCI chess engine
Loading...
Searching...
No Matches
MCTSNode Struct Reference

Represents a single node in the Monte Carlo Search Tree. More...

#include <MCTS.h>

Collaboration diagram for MCTSNode:

Public Member Functions

 MCTSNode ()=default
 MCTSNode (Move m, MCTSNode *p)
float ucb (float explorationConstant) const
 Calculates the Upper Confidence Bound (UCB1) for this node.
float meanValue () const
 Calculates the mean expected value of the node.

Public Attributes

Move move
 Move that led to this node.
MCTSNodeparent = nullptr
 Pointer to the parent node.
std::vector< std::unique_ptr< MCTSNode > > children
 Child nodes.
int visits = 0
 Number of times this node has been visited.
float valueSum = 0.0f
 Cumulative value from all rollouts/evaluations passing through this node.
bool expanded = false
 True if the node's children have been generated.

Detailed Description

Represents a single node in the Monte Carlo Search Tree.

Constructor & Destructor Documentation

◆ MCTSNode() [1/2]

MCTSNode::MCTSNode ( )
default
Here is the caller graph for this function:

◆ MCTSNode() [2/2]

MCTSNode::MCTSNode ( Move m,
MCTSNode * p )
inline
Here is the call graph for this function:

Member Function Documentation

◆ meanValue()

float MCTSNode::meanValue ( ) const
inline

Calculates the mean expected value of the node.

Returns
The average value score.
Here is the caller graph for this function:

◆ ucb()

float MCTSNode::ucb ( float explorationConstant) const
inline

Calculates the Upper Confidence Bound (UCB1) for this node.

Parameters
explorationConstantThe exploration weight (e.g., sqrt(2)).
Returns
The UCB score used for selection.

Member Data Documentation

◆ children

std::vector<std::unique_ptr<MCTSNode> > MCTSNode::children

Child nodes.

◆ expanded

bool MCTSNode::expanded = false

True if the node's children have been generated.

◆ move

Move MCTSNode::move

Move that led to this node.

◆ parent

MCTSNode* MCTSNode::parent = nullptr

Pointer to the parent node.

◆ valueSum

float MCTSNode::valueSum = 0.0f

Cumulative value from all rollouts/evaluations passing through this node.

◆ visits

int MCTSNode::visits = 0

Number of times this node has been visited.


The documentation for this struct was generated from the following file: