Exemplo n.º 1
0
 public UCTNode(UCTNode parent, Move m, Board boardState)
 {
     if (m == null || boardState == null)
         throw new ArgumentNullException("m");
     BoardState = boardState.Clone();
     Parent = parent;
     Children = null;
     Position = new Move(m);
     Wins = 0;
     Visits = 0;
 }
Exemplo n.º 2
0
 public UCTNode(UCTNode parent, Move m, Board boardState)
 {
     if (m == null || boardState == null)
     {
         throw new ArgumentNullException("m");
     }
     BoardState = boardState.Clone();
     Parent     = parent;
     Children   = null;
     Position   = new Move(m);
     Wins       = 0;
     Visits     = 0;
 }
Exemplo n.º 3
0
 public void CreateChildren()
 {
     lock (this)
     {
         int   size = Board.Size;
         Board b    = BoardState;
         if (Children != null)
         {
             return;
         }
         if (Parent == null || Parent.Children == null)
         {
             Children = new List <UCTNode>(size * size);
         }
         else
         {
             Children = new List <UCTNode>(Parent.Children.Count);
         }
         for (int i = 0; i < size; i++)
         {
             for (int j = 0; j < size; j++)
             {
                 //is on empty space on the board
                 if (b[i, j] == 0 && b.IsEye(i, j) != b.ActivePlayer)
                 {
                     Board anotherCloneBoard = b.Clone();
                     Move  m = new Move(i, j);
                     if (anotherCloneBoard.PlaceStone(m) == true)
                     {
                         Children.Add(new UCTNode(this, m, anotherCloneBoard));
                     }
                 }
             }
         }
         Children.Shuffle();
         HasChildren = true;
     }
 }