public void EditEventEffect(Name a, EffectDTO eff, int index) { if (actions.ContainsKey(a)) { actions[a].RemoveAt(index); actions[a].Add(new Effect(eff)); } }
public void AddActionEffect(Name action, EffectDTO eff) { if (actions.ContainsKey(action)) { actions[action].Add(new Effect(eff)); } else { throw new Exception("Action name not found"); } }
public Effect(EffectDTO ef) { Id = ef.Id; PropertyName = ef.PropertyName; NewValue = ef.NewValue; if (ef.ObserverAgent != null) { ObserverAgent = ef.ObserverAgent; } else { ObserverAgent = (Name)"*"; } }
public AddorEditEffect(WorldModelAsset wm, Name eventTemplate, int _index, EffectDTO effectToEdit = null) { InitializeComponent(); this._wm = wm; _eventTemplate = eventTemplate; //DefaultValues newValue.Value = WellFormedNames.Name.BuildName("True"); propertyName.Value = WellFormedNames.Name.BuildName("Bel(A)"); observerName.Value = WellFormedNames.Name.BuildName("*"); //Restrictions index = _index; newValue.AllowUniversal = false; _subject = eventTemplate.GetNTerm(2); propertyName.AllowNil = false; propertyName.AllowUniversal = false; propertyName.AllowLiteral = false; _effectToEdit = effectToEdit; if (effectToEdit != null) { this.Text = "Edit Effect"; this.addEffect.Text = "Update"; newValue.Value = effectToEdit.NewValue; propertyName.Value = effectToEdit.PropertyName; observerName.Value = effectToEdit.ObserverAgent; } else { _effectToEdit = new EffectDTO() { NewValue = newValue.Value, PropertyName = propertyName.Value, ObserverAgent = observerName.Value, } }; }
public IEnumerable <EffectDTO> Simulate(Name[] events) { var result = new List <EffectDTO>(); foreach (var e in events) { var matchingActionRules = this.actionNames.Unify(e); Pair <Name, SubstitutionSet> actionRule = null; var maxPriority = int.MinValue; foreach (var match in matchingActionRules) { if (priorityRules[match.Item1] > maxPriority) { maxPriority = priorityRules[match.Item1]; actionRule = match; } } if (actionRule == null) { return(result); } var substitutions = new[] { actionRule.Item2 }; //this adds the subs found in the eventName var effects = actions[actionRule.Item1]; var responsibleAgent = e.GetNTerm(2); foreach (var ef in effects) { var truePropertyName = (Name)"default"; var trueNewValueName = (Name)"default"; var trueResponsibleAgentName = (Name)"World"; var trueObserverAgentName = (Name)"*"; if (!ef.PropertyName.IsGrounded) { foreach (var sub in substitutions) { truePropertyName = ef.PropertyName.MakeGround(sub); } } else { truePropertyName = ef.PropertyName; } if (!ef.NewValue.IsGrounded) { foreach (var sub in substitutions) { trueNewValueName = ef.NewValue.MakeGround(sub); } } else { trueNewValueName = ef.NewValue; } if (!ef.ObserverAgent.IsGrounded) { foreach (var sub in substitutions) { trueObserverAgentName = ef.ObserverAgent.MakeGround(sub); } } else { trueResponsibleAgentName = responsibleAgent; } var trueEffect = new EffectDTO() { PropertyName = truePropertyName, NewValue = trueNewValueName, ObserverAgent = trueObserverAgentName, }; result.Add(trueEffect); } } return(result); }