Exemplo n.º 1
0
        private void PopChoice()
        {
            CurrentStates[0].ClearState();
            CurrentStates.Clear();
            if (_statesStack.Count == 0)
            {
                throw new Exception("Choice stack is empty. Unable to fallback to another state.");
            }

            StateMemento memento = _statesStack.Pop();

            _inx  = memento.TokenIndex;
            _move = memento.Move + 1;
            CurrentStates.Add(memento.State);
        }
Exemplo n.º 2
0
        public void PerformStep()
        {
            ProcessedWord += Word[CurrentPosition];

            char symbol = Word[CurrentPosition];

            var possibleNextStates = new List <State>();

            foreach (var state in CurrentStates)
            {
                var nextStates = state.PossibleNextStates
                                 .Where(x => x.Value.Invoke(symbol))
                                 .Select(pair => pair.Key);

                nextStates
                .ForEach(s => possibleNextStates.Add(s));
            }


            CurrentStates.Clear();

            foreach (var state in possibleNextStates)
            {
                CurrentStates.Add(state);
            }

            //foreach (var state in CurrentStates)
            //{
            //    for (int i = 0; i < StateTraces.Count; i++)
            //    {
            //        var trace = StateTraces[i];
            //        var brandNewTrace = new StateTrace(trace);
            //        brandNewTrace.Add(state);

            //        if (!StateTraces.Contains(brandNewTrace))
            //            StateTraces.Add(trace);
            //    }
            //}

            CurrentPosition++;
        }
Exemplo n.º 3
0
 public void PrepareState()
 {
     CurrentStates.Clear();
     CurrentSpeed  = Speed;
     CurrentDamage = Damage;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Reset the the start states to its origin
 /// </summary>
 public void ResetStartStates()
 {
     CurrentStates.Clear();
     CurrentStates.AddRange(
         States.FindAll(st => st.StateType == StateType.StartState));
 }