コード例 #1
0
        private Node getNodeToPlay(BasicChessboard chessboard, int totalPlayedTimes)
        {
            Node nodeToPlay = null;

            if (PositionsAvailable.Count > 0)
            {
                nextNodeLock.EnterWriteLock();
                if (PositionsAvailable.Count > 0)
                {
                    nodeToPlay = new Node(PositionsAvailable.Dequeue(), chessboard.NextMoveKind);
                    NextNodes.Add(nodeToPlay);
                }
                nextNodeLock.ExitWriteLock();
            }
            if (nodeToPlay == null)
            {
                nextNodeLock.EnterReadLock();
                nodeToPlay = NextNodes.Aggregate((n1, n2) =>
                {
                    return(n1.GetUCB(totalPlayedTimes) > n2.GetUCB(totalPlayedTimes) ? n1 : n2);
                });
                nextNodeLock.ExitReadLock();
            }

            return(nodeToPlay);
        }
コード例 #2
0
        public static SearchingChessboard MakeCopy(this BasicChessboard chessboard)
        {
            SearchingChessboard newChessboard = new SearchingChessboard();

            chessboard.CopyTo(newChessboard);
            newChessboard.GenerateAvailablePositions();
            return(newChessboard);
        }
コード例 #3
0
ファイル: BasicChessboard.cs プロジェクト: zhc0757/FiveInARow
 public void CopyTo(BasicChessboard chessboard)
 {
     for (int i = 0; i < LineNum; i++)
     {
         for (int j = 0; j < LineNum; j++)
         {
             chessboard.positions[i, j] = positions[i, j];
         }
     }
     chessboard.NextMoveKind = NextMoveKind;
     chessboard.Result       = Result;
 }