/// <summary> /// Updates the model on the basis of a new operator and a new state. /// </summary> /// <param name="newAction">Last action.</param> /// <param name="newState">Resulting state.</param> public void UpdateModel(IOperator newAction, List <IPredicate> newState) { // If the action is observed, if (RobertsonMicrotheory.Observes(this.agentName, newAction, newState)) { // Add its operator to the model if it isn't already there. if (!this.KnowsOperator(newAction)) { this.knownOperators.Add(newAction.Template() as Operator); } // If the model has an active knownCurrentState if (this.knownCurrentState.Predicates.Count != 0) { // Apply the action to the state with the current known objects (the latter is for the case of axioms) this.knownCurrentState = (this.knownCurrentState as State).NewState((newAction as Operator), this.KnownObjects); } // Expand the chronology with the observed action. this.knownChronology.Add(newAction); } // Delegate the rest to the other method. UpdateModel(newState); }
/// <summary> /// Updates the model on the basis of a new state. /// </summary> /// <param name="newState">The new state that is known to the model.</param> public void UpdateModel(List <IPredicate> newState) { // For every object in the domain, foreach (IObject domainObject in this.planningProblem.Objects) { // If it is observed and unknown, add the object to the model. if (RobertsonMicrotheory.Observes(this.agentName, domainObject, newState) && !this.KnowsObject(domainObject)) { this.knownObjects.Add(domainObject); } } // For every observed literal of the given state, List <IPredicate> newStateKnowledge = RobertsonMicrotheory.KnowledgeState(newState, this.agentName); foreach (IPredicate literal in newStateKnowledge) { // inform the model of it. InformLiteral(literal); } }