Example #1
0
        /// <inheritdoc/>
        public bool GetNextBooleanChoice(AsyncOperation current, int maxValue, out bool next)
        {
            NondetBooleanChoice        nextChoice = null;
            List <NondetBooleanChoice> ncs        = null;

            if (this.NondetIndex < this.BoolNondetStack.Count)
            {
                ncs = this.BoolNondetStack[this.NondetIndex];
            }
            else
            {
                ncs = new List <NondetBooleanChoice>
                {
                    new NondetBooleanChoice(false),
                    new NondetBooleanChoice(true)
                };

                this.BoolNondetStack.Add(ncs);
            }

            nextChoice = ncs.FirstOrDefault(val => !val.IsDone);
            if (nextChoice is null)
            {
                next = false;
                return(false);
            }

            if (this.NondetIndex > 0)
            {
                var previousChoice = this.BoolNondetStack[this.NondetIndex - 1].Last(val => val.IsDone);
                previousChoice.IsDone = false;
            }

            next = nextChoice.Value;
            nextChoice.IsDone = true;
            this.NondetIndex++;

            this.ScheduledSteps++;

            return(true);
        }
Example #2
0
        /// <summary>
        /// Returns the next boolean choice.
        /// </summary>
        /// <param name="maxValue">The max value.</param>
        /// <param name="next">Next</param>
        /// <returns>Boolean</returns>
        public bool GetNextBooleanChoice(int maxValue, out bool next)
        {
            NondetBooleanChoice        nextChoice = null;
            List <NondetBooleanChoice> ncs        = null;

            if (NondetIndex < BoolNondetStack.Count)
            {
                ncs = BoolNondetStack[NondetIndex];
            }
            else
            {
                ncs = new List <NondetBooleanChoice>();
                ncs.Add(new NondetBooleanChoice(false));
                ncs.Add(new NondetBooleanChoice(true));

                BoolNondetStack.Add(ncs);
            }

            nextChoice = ncs.FirstOrDefault(val => !val.IsDone);
            if (nextChoice == null)
            {
                next = false;
                return(false);
            }

            if (NondetIndex > 0)
            {
                var previousChoice = BoolNondetStack[NondetIndex - 1].Last(val => val.IsDone);
                previousChoice.IsDone = false;
            }

            next = nextChoice.Value;
            nextChoice.IsDone = true;
            NondetIndex++;

            ScheduledSteps++;

            return(true);
        }