Package search.mcts
Class MCTSNode
java.lang.Object
search.mcts.MCTSNode
Represents a node in the Monte Carlo Tree Search (MCTS) tree.
Each node holds information about the move that lead to the current situation, its parent, children,
the color of the player that moves next, the number of visits and wins, and whether there is a win
in this Move or in this position.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWinAndIncrementVisit(int winValue) Increments the number of visits and adds a win to the node.doubleCalculates the node's value using the UCB1 formula.booleanChecks if the node's move is on the baseline of the enemy.voidupdateNode(MoveGenerator moveGenerator) Updates the node to determine if it has won in its position.
-
Constructor Details
-
MCTSNode
-
MCTSNode
Constructs an MCTSNode Root node only needing the Color as a parameter- Parameters:
color- The color of the player making the next move.
-
-
Method Details
-
addWinAndIncrementVisit
public void addWinAndIncrementVisit(int winValue) Increments the number of visits and adds a win to the node.- Parameters:
winValue- The value of the win to add (1 for win, 0 for loss).
-
getNodeValue
public double getNodeValue()Calculates the node's value using the UCB1 formula. Returns a high value if the node has not been visited.- Returns:
- The value of the node.
-
updateNode
Updates the node to determine if it has won in its position.- Parameters:
moveGenerator- The move generator used to check for win conditions.
-
isOnBaseLineForColor
public boolean isOnBaseLineForColor()Checks if the node's move is on the baseline of the enemy.- Returns:
trueif the move is on the baseline for the color,falseotherwise.
-