Exemple #1
0
 public bool TakeSnapshot(string name)
 {
     if (Moves != null)
     {
         Moves.TakeSnapshot(name);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private HeuristicAction TryValue(TekBoard board, TekField field, int value)
        {
            bool            prev   = board.EatExceptions;
            HeuristicAction result = HeuristicAction.haNone;

            try
            {
                board.EatExceptions = false;
                this.Enabled        = false; // make sure FindHeuristic doesnt call this recursively!
                if ((result = _tryValue(field, value)) == HeuristicAction.haNone)
                {
                    temStoredResults.Clear();
                    temMoves.TakeSnapshot(_ssDescription(field));
                    try {
                        do
                        {
                            try
                            {
                                result = _tryHeuristic(heuristics.FindHeuristic(board), board);
                            }
                            catch (ETekFieldInvalid)
                            {
                                result = HeuristicAction.haImpossible;
                            }
                        } while (result == HeuristicAction.haNone);
                    }
                    finally
                    {
                        temMoves.RestoreSnapshot(_ssDescription(field));
                        _ssIndex++;
                    }
                }
            }
            finally
            {
                board.EatExceptions = prev;
                this.Enabled        = true;
                field.Value         = 0; // backtracking
            }
            return(result);
        }