public EquationFinderArgs(BigInteger targetValue, ResultPredicate targetValuePredicate, int numOperations, List <int> termPool, string operatorPool)
        {
            if (termPool == null || termPool.Count < 1)
            {
                throw new ArgumentException("termPool may not be empty or null.", "termPool");
            }
            if (string.IsNullOrWhiteSpace(operatorPool))
            {
                throw new ArgumentException("operatorPool may not be empty or null.", "operatorPool");
            }
            if (numOperations < 1)
            {
                throw new ArgumentException("numOperations must be one or greater.", "numOperations");
            }

            TargetValuePredicate = targetValuePredicate;

            Rand = StaticRandom.Factory.Random();

            TargetValue        = targetValue;
            NumberOfOperations = numOperations;

            TermPool     = termPool;
            OperatorPool = operatorPool;
        }
Example #2
0
        private void BeginSearch()
        {
            if (TermPool == null || TermPool.Count < 1)
            {
                MessageBox.Show("Term cannot be empty.", "Input missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrWhiteSpace(OperatorPool))
            {
                MessageBox.Show("You must select at least one operation.", "Input missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ResultPredicate resultCondition = ResultPredicate.IsDivisibleBy;

            if (radioGoalDivisibleaBy.Checked)
            {
                resultCondition = ResultPredicate.IsDivisibleBy;
            }
            else if (radioGoalEqual.Checked)
            {
                resultCondition = ResultPredicate.IsEqualTo;
            }

            equationArgs = new EquationFinderArgs(targetValue, resultCondition, numberOfOperations, TermPool, OperatorPool);

            string[] previousResults = GetOutputLines();
            if (previousResults != null && previousResults.Length > 0)
            {
                threadArgs = new ThreadSpawnerArgs(previousResults.ToList(), null, timeToLive, numberOfThreads, numberOfRounds, equationArgs);
            }
            else
            {
                threadArgs = new ThreadSpawnerArgs(null, timeToLive, numberOfThreads, numberOfRounds, equationArgs);
            }

            if (backgroundWorker_ThreadSpawner.IsBusy == false)
            {
                ToggleControlsVisibility(false);
                timerCollectResults.Start();
                backgroundWorker_ThreadSpawner.RunWorkerAsync(threadArgs);
            }
        }
Example #3
0
        internal void Add(ResultPredicate <TResult> predicate)
        {
            _predicates = _predicates ?? new List <ResultPredicate <TResult> >(); // The ?? pattern here is sufficient; only a deliberately contrived example would lead to the same PolicyBuilder instance being used in a multi-threaded way to define policies simultaneously on multiple threads.

            _predicates.Add(predicate);
        }
Example #4
0
 public string ToString(List <House> houses)
 {
     return($"{ToString()} {(ResultPredicate.Function(new Game {Houses = houses}) == false ? " НАРУШЕНО !" : " ПОДТВЕРЖДЕНО !")}");
 }