Beispiel #1
0
        public void Execute(ref WooState state)
        {
            double rand        = state._Random.NextDouble();
            double totalWeight = 0;

            foreach (Expression e in _Weight)
            {
                totalWeight += e.EvaluateFloat(ref state);
            }
            rand *= totalWeight;
            double currentWeight = 0;
            int    i             = 0;

            while (currentWeight < rand)
            {
                currentWeight += _Weight[i++].EvaluateFloat(ref state);
            }
            if (state._Recursions > 0 || !state.GetRule(_Rule[i - 1]).CanRecurse())
            {
                state._Recursions--;
                WooState newState = state.Clone();
                state.GetRule(_Rule[i - 1]).Execute(ref newState);
                state._Recursions++;
            }
        }
Beispiel #2
0
 public void Execute(ref WooState state)
 {
     if (state._Recursions > 0 || !state.GetRule(_RulePrototype._Name).CanRecurse())
     {
         state._Recursions--;
         for (int i = 0; i < _ArgValue.Count(); i++)
         {
             if (_RulePrototype._Args[i]._Type == VarType.varVector)
             {
                 state.AddVector(_RulePrototype._Args[i]._Name, _ArgValue[i].EvaluateVector(ref state));
             }
             else if (_RulePrototype._Args[i]._Type == VarType.varFloat)
             {
                 state.AddFloat(_RulePrototype._Args[i]._Name, _ArgValue[i].EvaluateFloat(ref state));
             }
         }
         state.GetRule(_RulePrototype._Name).Execute(ref state);
         for (int i = 0; i < _ArgValue.Count(); i++)
         {
             if (_RulePrototype._Args[i]._Type == VarType.varVector)
             {
                 state.RemoveVector(_RulePrototype._Args[i]._Name);
             }
             else if (_RulePrototype._Args[i]._Type == VarType.varFloat)
             {
                 state.RemoveFloat(_RulePrototype._Args[i]._Name);
             }
         }
         state._Recursions++;
     }
 }
Beispiel #3
0
        public void Execute(ref WooState state)
        {
            if (state._Recursions > 0 || !state.GetRule(_Callee).CanRecurse())
            {
                state._Recursions--;
//                WooState newState = state.Clone();
                state.GetRule(_Callee).Execute(ref state);
                state._Recursions++;
            }
        }
Beispiel #4
0
        public void Execute(ref WooState state)
        {
            if (state._Recursions > 0 || !state.GetRule(_Callee).CanRecurse())
            {
                state._Recursions--;
//                WooState newState = state.Clone();
                state.GetRule(_Callee).Execute(ref state);
                state._Recursions++;
            }
        }
Beispiel #5
0
 public void Execute(ref WooState state)
 {
     //WooState newState = state.Clone();
     if (state._Recursions > 0 || !state.GetRule(_Callee).CanRecurse())
     {
         state._Recursions--;
         for (int i = 0; i < (int)(_Expr.EvaluateFloat(ref state) + 0.5); i++)
         {
             state.GetRule(_Callee).Execute(ref state);
         }
         state._Recursions++;
     }
 }
Beispiel #6
0
 public void Execute(ref WooState state)
 {
     //WooState newState = state.Clone();
     if (state._Recursions > 0 || !state.GetRule(_Callee).CanRecurse())
     {
         state._Recursions--;
         for (int i = 0; i < (int)(_Expr.EvaluateFloat(ref state)+0.5); i++)
         {
             state.GetRule(_Callee).Execute(ref state);
         }
         state._Recursions++;
     }
 }
Beispiel #7
0
 public void Execute(ref WooState state)
 {
     if (state._Recursions == 0)
     {
         state._Recursions--;
         WooState newState = state.Clone();
         state.GetRule(_Callee).Execute(ref newState);
         state._Recursions++;
     }
 }
Beispiel #8
0
 public void Execute(ref WooState state)
 {
     if (state._Recursions == 0)
     {
         state._Recursions--;
         WooState newState = state.Clone();
         state.GetRule(_Callee).Execute(ref newState);
         state._Recursions++;
     }
 }
Beispiel #9
0
 public void Execute(ref WooState state)
 {
     double rand = state._Random.NextDouble();
     double totalWeight = 0;
     foreach (Expression e in _Weight) totalWeight += e.EvaluateFloat(ref state);
     rand *= totalWeight;
     double currentWeight = 0;
     int i = 0;
     while (currentWeight < rand)
     {
         currentWeight += _Weight[i++].EvaluateFloat(ref state);
     }
     if (state._Recursions > 0 || !state.GetRule(_Rule[i - 1]).CanRecurse())
     {
         state._Recursions--;
         WooState newState = state.Clone();
         state.GetRule(_Rule[i - 1]).Execute(ref newState);
         state._Recursions++;
     }
 }
Beispiel #10
0
 public void Execute(ref WooState state)
 {
     if (state._Recursions > 0 || !state.GetRule(_RulePrototype._Name).CanRecurse())
     {
         state._Recursions--;
         for (int i=0; i<_ArgValue.Count(); i++)
         {
             if (_RulePrototype._Args[i]._Type == VarType.varVector)
                 state.AddVector(_RulePrototype._Args[i]._Name, _ArgValue[i].EvaluateVector(ref state));
             else if (_RulePrototype._Args[i]._Type == VarType.varFloat)
                 state.AddFloat(_RulePrototype._Args[i]._Name, _ArgValue[i].EvaluateFloat(ref state));
         }
         state.GetRule(_RulePrototype._Name).Execute(ref state);
         for (int i = 0; i < _ArgValue.Count(); i++)
         {
             if (_RulePrototype._Args[i]._Type == VarType.varVector)
                 state.RemoveVector(_RulePrototype._Args[i]._Name);
             else if (_RulePrototype._Args[i]._Type == VarType.varFloat)
                 state.RemoveFloat(_RulePrototype._Args[i]._Name);
         }
         state._Recursions++;
     }
 }