Esempio n. 1
0
 int GetAvailableMoves(Board b)
 {
     if (_availableMoves == null)
         _availableMoves = new Move[Size*Size+1];
     int moveCount = 0;
     for (int i = 0; i < Size; i++)
     {
         for (int j = 0; j < Size; j++)
         {
             //is on empty space on the board and not a friendly eye
             if (b[i, j] == 0 && b.IsEye(i, j) != b.ActivePlayer)
             {
                 _availableMoves[moveCount++] = new Move(i, j);
             }
         }
     }
     return moveCount;
 }
Esempio n. 2
0
        private int GetAvailableMoves(Board b)
        {
            if (_availableMoves == null)
            {
                _availableMoves = new Move[Size * Size + 1];
            }
            int moveCount = 0;

            for (int i = 0; i < Size; i++)
            {
                for (int j = 0; j < Size; j++)
                {
                    //is on empty space on the board and not a friendly eye
                    if (b[i, j] == 0 && b.IsEye(i, j) != b.ActivePlayer)
                    {
                        _availableMoves[moveCount++] = new Move(i, j);
                    }
                }
            }
            return(moveCount);
        }
Esempio 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;
     }
 }