Example #1
0
        private IntermediateState CreateIntermediateState(ISet <TreeNode> nodeSet)
        {
            var state = new IntermediateState(
                new SortedSet <TreeNode>(nodeSet, nodeComparer),
                Dstates.Count);

            // DumpState(state);        // This is very verbose in the unit tests
            return(state);
        }
Example #2
0
        private IntermediateState CreateIntermediateState(ISet <TreeNode> nodeSet)
        {
            var state = new IntermediateState(
                new SortedSet <TreeNode>(nodeSet, nodeComparer),
                Dstates.Count);

            DumpState(state);
            return(state);
        }
Example #3
0
 private void DumpState(IntermediateState state)
 {
     Debug.Print("Created state {0}{1}{2}", state.Number, state.Starts ? " Starts" : "", state.Accepts ? " Accepts" : "");
     Debug.Print("    {0}", string.Join(",", state.Nodes.Select(n => n.Number.ToString())));
     Debug.Print("    {0}", string.Join(",", state.Nodes.Select(
                                            n => string.Format(
                                                Char.IsControl((char)n.Value)
                 ? "\\x{0:X2}"
                 : "{0}",
                                                Char.IsControl((char)n.Value)
                 ? (object)(int)n.Value
                 : (object)(char)n.Value))));
 }
Example #4
0
        public static FSM GenerateTestSequenceAutomaton(string testcaseName, Sequence <Sequence <CompoundTerm> > testseqs, Set <Symbol> actionSymbols)
        {
            Set <Term> acceptingStates = Set <Term> .EmptySet;
            Set <Term> states          = Set <Term> .EmptySet;

            Symbol  testCaseActionSymbol = new Symbol(testcaseName);
            Literal initialState         = new Literal(0);

            states = states.Add(initialState);

            #region generate transitions and accepting states
            Set <Triple <Term, CompoundTerm, Term> > transitions =
                Set <Triple <Term, CompoundTerm, Term> > .EmptySet;
            for (int i = 0; i < testseqs.Count; i++)
            {
                //the i'th test sequence start action
                CompoundTerm startTestAction =
                    new CompoundTerm(testCaseActionSymbol,
                                     new Sequence <Term>(new Literal(i)));

                transitions = transitions.Add(new Triple <Term, CompoundTerm, Term>(
                                                  initialState, startTestAction, IntermediateState.State(i, 0)));

                Sequence <CompoundTerm> testseq = testseqs[i];

                //the final step state of the i'th test sequence is an accepting state
                acceptingStates = acceptingStates.Add(IntermediateState.State(i, testseq.Count));
                states          = states.Add(IntermediateState.State(i, testseq.Count));

                for (int j = 0; j < testseq.Count; j++)
                {
                    if (!actionSymbols.Contains(testseq[j].Symbol))
                    {
                        throw new ArgumentException("Not all action symbols in test sequences appear in actionSymbols", "actionSymbols");
                    }
                    states      = states.Add(IntermediateState.State(i, j));
                    transitions = transitions.Add(new Triple <Term, CompoundTerm, Term>(
                                                      IntermediateState.State(i, j), testseq[j], IntermediateState.State(i, j + 1)));
                }
            }
            #endregion

            return(new FSM(initialState, states, transitions,
                           acceptingStates, actionSymbols.Add(testCaseActionSymbol)));
        }
        public void Draw(Graphics graphics) {
            // TODO GameManager.State에 따라 다른 형태의 화면 표시가 필요함
            
            var world = _manager.GetWorld();

            var entities = world.EntityManager.Entities;

            float width = _control.DisplayRectangle.Right - _control.DisplayRectangle.Left;
            float height = _control.DisplayRectangle.Bottom - _control.DisplayRectangle.Top;

            var factorWidth = width / world.Size.Width;
            var factorHeight = height / world.Size.Height;
            graphics.FillRectangle(Brushes.Black, 0, 0, world.Size.Width * factorWidth, world.Size.Height * factorHeight);
            graphics.DrawString($@"Game state: {_manager.State switch {
                PlayingState _ => "Playing",
                PausedState _ => "Paused",
                CompleteState _ => "Complete",
                CompleteAllState _ => "CompleteAll",
                IntermediateState _ => "Intermediate",
                GameOverState _ => "GameOver",
                _ => "Else"
            }}", new Font("Arial", 16), Brushes.White, 0, 0);