BDI agents

69 views
Skip to first unread message

Markus Schatten

unread,
Nov 26, 2014, 10:03:35 AM11/26/14
to spade...@googlegroups.com
Hi everyone,

I'm struggling to implement a BDI agent in SPADE. The documentation
seems not to be up to date. Can anyone send a simple working example
where an agent automatically plans and executes a plan to achieve a
goal?

All the best,

M.
--
Markus Schatten, PhD
Assistant professor and head of Artificial Intelligence Lab
University of Zagreb
Faculty of Organization and Informatics
Pavlinska 2, 42000 Varazdin, Croatia
http://www.foi.hr/nastavnici/schatten.markus/index.html
http://www.researchgate.net/profile/Markus_Schatten1
http://ai.foi.hr

Javi Palanca

unread,
Nov 26, 2014, 12:07:41 PM11/26/14
to spade...@googlegroups.com
Hi Markus,

I’ve been re-reading the documentation about bdi (http://pythonhosted.org//SPADE/spade.bdi.running.html) and seems to be updated.
Which is your issue?

best,
Javi

--
You received this message because you are subscribed to the Google Groups "spade-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spade-users...@googlegroups.com.
To post to this group, send email to spade...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Markus Schatten

unread,
Nov 26, 2014, 2:10:39 PM11/26/14
to spade...@googlegroups.com
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?

All the best,

M.
--
Markus Schatten, PhD
Assistant professor and head of Artificial Intelligence Lab
University of Zagreb
Faculty of Organization and Informatics
Pavlinska 2, 42000 Varazdin, Croatia
http://www.foi.hr/nastavnici/schatten.markus/index.html
http://www.researchgate.net/profile/Markus_Schatten1
http://ai.foi.hr


Reply all
Reply to author
Forward
0 new messages