示例#1
0
        //This returns all walls adjacent to the wall move made in
        public List <WallDiffNode> GetChildren()
        {
            List <WallDiffNode> children      = new List <WallDiffNode>();
            List <string>       adjacentWalls = DictionaryLookup.PerformWallsOfInterestLookup(MoveMade);

            foreach (string wall in adjacentWalls)
            {
                AIBoard tempBoard = new AIBoard(Board);
                tempBoard.MakeMove(wall);
                if (BoardAnalysis.CheckPathExists(tempBoard, true) && BoardAnalysis.CheckPathExists(tempBoard, false))
                {
                    children.Add(new WallDiffNode(this, wall));
                }
            }
            return(children);
        }
示例#2
0
        //Constructs a list of treenodes that result from every move made that is possible.
        //Pruning function (SetNodesOfInterest) will cut of many nodes that are not of interest.
        public List <TreeNode> GetChildren()
        {
            List <TreeNode> children = new List <TreeNode>();

            foreach (string move in Board.GetPawnMoves())
            {
                //This checks to make sure walls are valid
                AIBoard tempBoard = new AIBoard(Board);
                tempBoard.MakeMove(move);
                children.Add(new TreeNode(tempBoard, move));
            }

            //This gets only valid walls but is done here so that it will only check walls of interest.
            //This avoids checking if a ton of walls are valid that we don't care about.
            //This is why we do not just call GetWallMoves()
            if ((Board.GetIsPlayerOneTurn() && Board.GetPlayerOneNumWalls() == 0) ||
                (!Board.GetIsPlayerOneTurn() && Board.GetPlayerTwoNumWalls() == 0))
            {
            }
            else
            {
                HashSet <string> wallMoves = Board.GetAllValidWalls();
                SetNodesOfInterest(ref wallMoves);
                foreach (string wall in wallMoves)
                {
                    //This checks to make sure walls are valid
                    AIBoard tempBoard = new AIBoard(Board);
                    tempBoard.MakeMove(wall);
                    if (BoardAnalysis.CheckPathExists(tempBoard, true) && BoardAnalysis.CheckPathExists(tempBoard, false))
                    {
                        children.Add(new TreeNode(tempBoard, wall));
                    }
                }
            }

            //end of wall selection

            return(children);
        }
示例#3
0
        public List <string> GetWallMoves()
        {
            List <string> possibleMoves = new List <string>();

            if ((IsPlayerOneTurn && PlayerOneNumWalls == 0) || (!IsPlayerOneTurn && PlayerTwoNumWalls == 0))
            {
            }
            else
            {
                foreach (string wall in ValidWallPlacements)
                {
                    //This checks to make sure walls are valid
                    AIBoard tempBoard = new AIBoard(this);
                    tempBoard.MakeMove(wall);

                    if (BoardAnalysis.CheckPathExists(tempBoard, true) && BoardAnalysis.CheckPathExists(tempBoard, false))
                    {
                        possibleMoves.Add(wall);
                    }
                }
            }
            return(possibleMoves);
        }