Plans and Services

In order to offer a Service, an agent must use the Service class from the bdi module in SPADE. The body of the Service is the run method. Everything that the Service must do has to be included in the run method. The Service constructor receives the pre-condition P and the post-condition Q as parameters.

		class Serv1(Service):
		    def run(self):
		        self.addBelieve(expr("Value(1)"))

		agent.registerService(name="name", service=Serv1())
	

A Plan only needs a pre-condition P, a post-condition Q and a list of Services. Dictionaries are used in order to define them:


		plan = {'P': expr("value(1)"),'Q':expr("value(4)"), services:[s1,s2,s3,s4]}
		agent.addPlan(plan)