//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); }
//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); }
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); }