public ChoiceStateTest(String name)
            : base(name, new NSFEventThread(name))
        {
            // Events
            evaluateEvent = new NSFEvent("EvaluateEvent", this);
            waitEvent = new NSFEvent("WaitEvent", this);

            // Regions and states, from outer to inner
            initialChoiceStateTestState = new NSFInitialState("InitialChoiceStateTest", this);
            waitToEvaluateState = new NSFCompositeState("WaitToEvaluate", this, null, null);
            evaluateValueState = new NSFChoiceState("EvaluateValue", this);
            evaluatedState = new NSFCompositeState("Evaluated", this, null, null);
            initialEvaluatedState = new NSFInitialState("InitialEvaluatedState", evaluatedState);
            valueLowState = new NSFCompositeState("ValueLow", evaluatedState, null, null);
            valueMiddleState = new NSFCompositeState("ValueMiddle", evaluatedState, null, null);
            valueHighState = new NSFCompositeState("ValueHigh", evaluatedState, null, null);

            // Transitions, ordered internal, local, external
            initialChoiceStateTestToWaitToEvaluateTransition = new NSFExternalTransition("InitialChoiceStateTestToWaitToEvaluate", initialChoiceStateTestState, waitToEvaluateState, null, null, null);
            waitToEvaluateToEvaluateValueTransition = new NSFExternalTransition("State1ToState2", waitToEvaluateState, evaluateValueState, evaluateEvent, null, null);
            //waitToEvaluateToEvaluateValueTransition = new NSFExternalTransition("State1ToState2", waitToEvaluateState, evaluatedState, evaluateEvent, null, null);
            initialEvaluatedToValueLowTransition = new NSFExternalTransition("InitialEvaluatedToValueLowTransition", initialEvaluatedState, valueLowState, null, null, null);
            evaluateValueToValueLowTransition = new NSFExternalTransition("EvaluateValueToValueLowTransition", evaluateValueState, valueLowState, null, isValueLow, null);
            evaluateValueToValueMiddleTransition = new NSFExternalTransition("EvaluateValueToValueMiddleTransition", evaluateValueState, valueMiddleState, null, Else, null);
            evaluateValueToValueHighTransition = new NSFExternalTransition("EvaluateValueToValueHighTransition", evaluateValueState, valueHighState, null, isValueHigh, null);
            evaluatedToWaitToEvaluateTransition = new NSFExternalTransition("EvaluatedToWaitToEvaluateTransition", evaluatedState, waitToEvaluateState, waitEvent, null, addValue);
        }
        private void createStateMachine()
        {
            // State Machine Components
            // Define and initialize in the order:
            //   1) Events
            //   2) Regions and states, from outer to inner
            //   3) Transitions, ordered internal, local, external
            //   4) Group states and transitions within a region together.

            // Events
            scoutEvent = new NSFEvent("Scout", this, this);

            // Regions and States
            combatInitialState = new NSFInitialState("CombatInitial", this);
            scoutingState = new NSFCompositeState("Scouting", this, null, null);
            scoutingInitialState = new NSFInitialState("ScountingInitial", scoutingState);
            patrolState = new NSFCompositeState("Patrol", scoutingState, null, null);
            moveToEnemyState = new NSFCompositeState("MoveToEnemy", scoutingState, null, null);
            attackChoiceState = new NSFChoiceState("AttackChoice", this);
            attackState = new NSFCompositeState("Attack", this, null, null);

            // Transitions
            combatInitialToScoutingTransition = new NSFExternalTransition("CombatInitialToScouting", combatInitialState, scoutingState, null, null, null);
            scoutingToAttackChoiceTransition = new NSFExternalTransition("ScoutingToAttackChoice", scoutingState, attackChoiceState, scoutEvent, null, null);
            scoutingInitialToPatrolTransition = new NSFExternalTransition("ScoutingInitialToPatrol", scoutingInitialState, patrolState, null, null, null);
            attackChoiceToPatrolTransition = new NSFExternalTransition("AttackChoiceToPatrol", attackChoiceState, patrolState, null, Else, null);
            attackChoiceToAttackTransition = new NSFExternalTransition("AttackChoiceToAttack", attackChoiceState, attackState, null, isEnemyInRange, null);
            attackChoiceToMoveToEnemyTransition = new NSFExternalTransition("AttackChoiceToMoveToEnemy", attackChoiceState, moveToEnemyState, null, isEnemyNear, null);
        }