public void ExecuteAction(TekMoves moves)
        {
            switch (Action)
            {
            case HeuristicAction.haNone:
                break;

            case HeuristicAction.haSetValue:
                SetValue(moves, AffectedFields[0], HeuristicValues[0]);
                break;

            case HeuristicAction.haExcludeValue:
                foreach (TekField field in AffectedFields)
                {
                    ExcludeValues(moves, field);
                    if (field.PossibleValues.Count == 1)
                    {
                        SetValue(moves, field, field.PossibleValues[0]);
                    }
                }
                break;

            case HeuristicAction.haExcludeComplement:
                foreach (TekField field in AffectedFields)
                {
                    ExcludeComplementValues(moves, field);
                }
                break;
            }
        }
Example #2
0
 private void _toggleFieldNoteValue(TekFieldView view, int value, TekMoves Moves)
 {
     if (view != null)
     {
         Moves.PlayNote(view.Row, view.Col, value);
         view.Refresh();
     }
 }
 public void ExcludeValues(TekMoves moves, TekField field)
 {
     foreach (int value in HeuristicValues)
     {
         if (field.ValuePossible(value))
         {
             moves.ExcludeValue(field, value);
         }
     }
 }
Example #4
0
        public void ToggleSelectedNoteValue(int value, TekMoves Moves)
        {
            switch (CurrentMode)
            {
            case SelectMode.smSingle:
                _toggleFieldNoteValue(CurrentFieldView, value, Moves);
                break;

            case SelectMode.smMultiple:
                foreach (TekFieldView fieldView in MultiselectFieldView)
                {
                    _toggleFieldNoteValue(fieldView, value, Moves);
                }
                break;
            }
        }
        public void ExcludeComplementValues(TekMoves moves, TekField field)
        {
            List <int> excludingValues = new List <int>();

            foreach (int value in field.PossibleValues)
            {
                if (!HeuristicValues.Contains(value))
                {
                    excludingValues.Add(value);
                }
            }
            foreach (int value in excludingValues)
            {
                if (field.ValuePossible(value))
                {
                    moves.ExcludeValue(field, value);
                }
            }
        }
        public bool HeuristicSolve(TekBoard board, TekMoves moves)
        {
            TekHeuristic heuristic = FindHeuristic(board);
            bool         Paused    = false;

            while (heuristic != null && !Paused)
            {
                AfterHeuristicFoundHandler?.Invoke(heuristic);
                StoreResult(heuristic);
                if (BeforeExecutionHandler != null && !BeforeExecutionHandler(heuristic))
                {
                    return(false);
                }
                heuristic.ExecuteAction(moves);
                AfterExecutionHandler?.Invoke(heuristic);
                heuristic = FindHeuristic(board);
            }
            return(board.IsSolved());
        }
 protected override void BeforeProcessingBoard(TekBoard board)
 {
     temMoves         = new TekMoves(board);
     temStoredResults = new List <TekHeuristicResult>();
 }
        public void SetValue(TekMoves moves, TekField field, int value)
        {
            bool result = field.Value == 0;

            moves.PlayValue(field, value);
        }
Example #9
0
 public void SetBoard(TekBoard board)
 {
     _view.Board = board;
     Moves       = new TekMoves(board);
 }