예제 #1
0
        public static BoardNode GetChild(Board b, PossibleMove pm, int trn)
        {
            var nb = new Board(b._size);

            Board.CopyBoard(nb, b);
            var item = new BoardNode(nb, pm);

            item._bData.AddPiece(pm.x, pm.y, trn);
            AI.TakeTurn(pm.x, pm.y, trn, item._bData);
            return(item);
        }
예제 #2
0
        public static List <BoardNode> GetChildren(BoardNode bn, int trn)
        {
            List <PossibleMove> moves = AI.CheckLegalMoves(bn._bData, bn._turn);
            var childs = new List <BoardNode>();

            foreach (PossibleMove pos in moves)
            {
                var b = new Board(bn._bData._size);
                Board.CopyBoard(b, bn._bData);
                var item = new BoardNode(b, pos);
                item._bData.AddPiece(pos.x, pos.y, trn);
                AI.TakeTurn(pos.x, pos.y, trn, item._bData);
                childs.Add(item);
                item._parent = bn;
            }
            bn._children = childs;
            return(childs);
        }
예제 #3
0
 public static int GetHeuristicValue(BoardNode bn, int turn)
 {
     int[] scores = bn._bData.GetScores();
     return(scores[turn]);
 }