Ejemplo n.º 1
0
        virtual public void determineNextAction()
        {
            List <MythAction> next_actions   = new List <MythAction>();
            MythAction        current_action = _action_fsm.CurrentState;
            int total_weight = 0;

            foreach (MythAction action in _action_fsm.getPossibleStates())
            {
                if (action.checkPrecondition(this))
                {
                    next_actions.Add(action);
                    total_weight += action.getWeight(this);
                }
            }


            int random = ConfigValues.Random.Next(total_weight);
            int prev_weight = 0, current_weight;

            foreach (MythAction action in next_actions)
            {
                current_weight = action.getWeight(this);
                if (prev_weight <= random && random < current_weight)
                {
                    _action_fsm.Advance(action, this);
                    return;
                }

                prev_weight = current_weight;
            }
        }
Ejemplo n.º 2
0
 protected void AddTransition(MythAction initial_state, MythAction end_state)
 {
     _action_fsm.AddTransition(initial_state, end_state, end_state.Effect);
 }