Click or drag to resize
Node Class
The Node class defines a node within an MCTS tree.
Inheritance Hierarchy
SystemObject
  VikingChess.ModelNode

Namespace: VikingChess.Model
Assembly: VikingChess (in VikingChess.exe) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
internal class Node

The Node type exposes the following members.

Constructors
  NameDescription
Public methodNode(Board)
Constructs a new Node. This constructor is used to form the root of the Node tree.
Public methodNode(Node)
Copy Constructor
Public methodNode(Board, Node)
Constructs a new Node. This constructor is used to create a child Node.
Top
Methods
  NameDescription
Public methodAddChild
Adds a new child Node to this Node.
Public methodEquals (Inherited from Object.)
Public methodExpandNode
Expands this Node by creating new child Node
Protected methodFinalize (Inherited from Object.)
Public methodgetBestChild
Finds the best child Node of this Node
Public methodGetBoard
Returns the Board object contained in this Node.
Public methodGetChildren
Returns the children of this Node.
Public methodGetHashCode (Inherited from Object.)
Public methodGetLastMove
Returns the lastMoveTuple of this Node
Public methodGetParent
Returns the parent of this Node.
Public methodGetScore
Returns the score of this Node.
Public methodGetType (Inherited from Object.)
Public methodGetVisits
Returns the number of times this Node has been visited.
Public methodgetWin
Returns the win status of this Node
Public methodgetWinChance
Returns the chance that this Node will lead to a win.
Public methodisLeaf
Checks to see if this is a leaf Node.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodsetLastMove
Sets the lastMoveTuple of this Node.
Public methodsetWin
Sets the win status of this Node
Public methodToString (Overrides ObjectToString.)
Public methodUCTSelectBest
Uses the UCT formula to select the most promising child Node to explore.
// UCT Formula
            uctVal = (child.GetScore() / (child.GetVisits() + EPSILON)) + Math.Sqrt(2) * Math.Sqrt((Math.Log(GetVisits() + 1)) / (child.GetVisits() + EPSILON)) + x + EPSILON;
Public methodupdateScore
Updates the score of this Node.
Public methodupdateStats
A method that updates the score and visitCount of this Node
Public methodupdateVisitCount
Updates the visitCount of this Node
Top
Fields
  NameDescription
Private fieldboard
The Board object representing the game board and position of pieces.
Private fieldchildren
An [!:List] containing any and all child [!:States] of this Node
Private fieldStatic memberEPSILON
A constant to protect against divide by zero errors in the UCT algorithm.
Private fieldhasWon
Defines whether or not the board contained within this node is a terminal state or not.
Private fieldlastMoveTuple
The last move made that resulted in the board of this node.
Private fieldparent
The parent Node of this Node
Private fieldscore
The score of this Node
Private fieldvisitCount
The number of times this Node has been visited.
Top
See Also