private void Start(TileBoard inputBoard) { //initialize new solution solution = new Solution(); solution.StartBoard = inputBoard.Copy(); solution.StartTime(); //initialize new visited nodes table visitedNodes = new Dictionary <string, BoardNode>(); //add input board to open node list var startNode = new BoardNode(null, inputBoard, '!'); visitedNodes.Add(inputBoard.ToString(), startNode); solution.ExpandedNodes++; openNodes.Push(startNode); //for bidirectional search, add end node to reverse open list if (bidirectional) { var endBoard = new TileBoard("_12345678"); var endNode = new BoardNode(null, endBoard, '!'); endNode.Reverse = true; visitedNodes.Add(endBoard.ToString(), endNode); solution.ExpandedNodes++; openNodesReverse.Push(endNode); } //start solving while (true) { if (Solve()) { break; } if (bidirectional) { if (Solve(true)) { break; } } } }
public bool Equals(TileBoard otherBoard) { return(ToString().Equals(otherBoard.ToString())); }