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++; } }
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++; } }
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++; } }
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++; } }
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++; } }
public void Execute(ref WooState state) { if (state._Recursions == 0) { state._Recursions--; WooState newState = state.Clone(); state.GetRule(_Callee).Execute(ref newState); state._Recursions++; } }
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++; } }
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++; } }