public void SolveAll() { SolverUtilities.PrintBoard(board); while (board.CheckVictory() != true) { SingleStep(); Console.ReadKey(); SolverUtilities.PrintBoard(board); } }
public void SingleStep() { if (possibleMoves.Count == 0) { possibleMoves.Push(SolverUtilities.GetPossibleMoves(board)); } List <GameMove> moves = possibleMoves.Peek(); while (moves.Count == 0) { possibleMoves.Pop(); board.UndoMove(); boardStates.Pop(); moves = possibleMoves.Peek(); stepCount--; } GameMove move = moves[moves.Count - 1]; moves.Remove(move); boardStates.Push(board.GetBoardState()); board.DoMove(move); BoardState newState = board.GetBoardState(); if (boardStates.Contains(newState, BoardStateCompare.Comparer)) { board.UndoMove(); boardStates.Pop(); stepCount--; return; } List <GameMove> newPossibleMoves = SolverUtilities.GetPossibleMoves(board); possibleMoves.Push(newPossibleMoves); stepCount++; return; }