public void AddTargets(JumpTreeNode targetNode, IEnumerable<BoardPosition> targets) { foreach (BoardPosition pos in targets) { GameBoard board = targetNode.Board.Copy(); SimpleMove move = new SimpleMove(board[targetNode.Position].Occupation, targetNode.Position, pos, board[targetNode.Position].Piece == PieceType.King, true); board.SetCapture(move); board.DoMove(move, true); targetNode.Children.Add(new JumpTreeNode { Board = board, Depth = targetNode.Depth + 1, Parent = targetNode, Position = pos, CheckAgain = !move.IsUpgrade }); ++NodeCount; } }
public JumpTree(BoardPosition root, IEnumerable<BoardPosition> targets, GameBoard board) { _root = new JumpTreeNode { Depth = 0, Position = root, Board = board }; NodeCount = 1; foreach (BoardPosition pos in targets) { GameBoard boardCopy = _root.Board.Copy(); SimpleMove move = new SimpleMove(boardCopy[_root.Position].Occupation, _root.Position, pos, boardCopy[_root.Position].Piece == PieceType.King); boardCopy.SetCapture(move); boardCopy.DoMove(move, true); _root.Children.Add(new JumpTreeNode { Board = boardCopy, Depth = _root.Depth + 1, Parent = _root, Position = pos, CheckAgain = !move.IsUpgrade }); ++NodeCount; } }