示例#1
0
 public bool IsValidInput()
 {
     heuristic = new BestPositionHeuristic(this);
     for (int i = 0; i < 81; i++)
     {
         if (numbers[i] != "" && !heuristic.UtkozesCsekk(i))
         {
             return(false);
         }
     }
     return(true);
 }
示例#2
0
        public void RunGenerate()
        {
            solutionNumber = maxSolutonsNumber + 1;
            state          = State.GenerateRunning;
            startTimer();
            while (solutionNumber > maxSolutonsNumber && state != State.NotValidInput)
            {
                solutionsList.Clear();
                for (int i = 0; i < 81; i++)
                {
                    if (!isFixed[i])
                    {
                        numbers[i] = "";
                    }
                }
                isPaused       = false;
                isStopped      = false;
                solutionNumber = 0;
                state          = State.GenerateRunning;
                switch (heur)
                {
                case HeruisticEnum.FromIndex: heuristic = new FromIndexHeuristic(this); break;

                case HeruisticEnum.RandomIndex: heuristic = new RandomIndexHeuristic(this); break;

                case HeruisticEnum.BestPos: heuristic = new BestPositionHeuristic(this); break;
                }
                setWaitTime(wait);
                solutionNumber = 0;
                state          = heuristic.Run();
            }
            finishTime = GetTime();
            int ff = 0;

            for (int i = 0; i < 81; i++)
            {
                if (!isFixed[i])
                {
                    numbers[i] = ""; ff++;
                }
            }
            if (heuristic.state != State.GenerateStop)
            {
                MessageBox.Show("Filled fields: " + (81 - ff).ToString() + Environment.NewLine + "Solutions: " + solutionNumber.ToString(), "Table generated ");
            }
        }
示例#3
0
        public void Run()
        {
            isPaused = false;
            solutionsList.Clear();
            isStopped      = false;
            solutionNumber = 0;
            state          = State.Running;
            startTimer();
            switch (heur)
            {
            case HeruisticEnum.FromIndex: heuristic = new FromIndexHeuristic(this); break;

            case HeruisticEnum.RandomIndex: heuristic = new RandomIndexHeuristic(this); break;

            case HeruisticEnum.BestPos: heuristic = new BestPositionHeuristic(this); break;
            }
            setWaitTime(wait);
            state      = heuristic.Run();
            finishTime = GetTime();
        }