Dear Javi,
it doesn't work. Here is an interactive session with the code given in
the documentation:
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import spade
>>> from spade.bdi import *
>>> from spade.DF import Service
>>> def s1_method(Value):
... return {"O1":1}
...
>>> def s2_method(Myoutput1):
... return {"O2":2}
...
>>> def goalCompletedCB(goal):
... agent.goalCompleted = True
...
>>> agent = BDIAgent("
b...@127.0.0.1","secret")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'BDIAgent' is not defined
>>> from spade.Agent import BDIAgent
>>> agent = BDIAgent("
b...@127.0.0.1","secret")
>>> s1 = Service(name="s1", owner=agent.getAID(), inputs=["Value"],outputs=["O1"],P=["Var(Value,0,Int)"],Q=["Var(O1,1,Int)"])
>>> s2 = Service(name="s2", owner=agent.getAID(), inputs=["O1"],outputs=["O2"],P=["Var(O1,1,Int)"],Q=["Var(O2,2,Int)"])
>>> agent.registerService(self.s1,s1_method)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'self' is not defined
>>> agent.registerService(s1,s1_method)
>>> agent.registerService(s2,s2_method)
True
>>> agent.goalCompleted = False
>>> agent.saveFact("Value",0)
>>> agent.setGoalCompletedCB( goalCompletedCB )
>>> agent.addGoal( Goal("Var(O1,1,Int)") )
>>> agent.start()
>>> import time
>>> counter = 0
>>> while not agent.goalCompleted and counter < 10:
... time.sleep( 1 )
... counter += 1
... print counter
...
1
2
3
4
5
6
7
8
9
10
>>> agent.goalCompleted
False
>>> agent.askBelieve( "Var(O1,1,Int)" )
False
>>> agent.getFact("O1")
What am I missing?