//queque stuff (done by xytrix) // Looks through a list of playfields from previous moves to find one that matches our current board state. // If any is found, we "rollback" our bestactions list to that point in time. public bool restoreBestMoves(Playfield currentField, List<Playfield> oldMoveGuesses) { for (int i = oldMoveGuesses.Count - 1; i >= 0; i--) // work backwards { if (currentField.isEqualf(oldMoveGuesses[i])) { // We need to re-queue moves from this point. So re-populate the "bestActions" list. for (int j = oldMoveGuesses.Count - 1; j > i; j--) { this.bestActions.Insert(0, oldMoveGuesses[j].playactions.Last()); } this.nextMoveGuess = oldMoveGuesses[i]; this.bestmove = nextMoveGuess.playactions.LastOrDefault(); // null if empty (i.e. no moves performed) return true; } } return false; }