FSM with functions

24 views
Skip to first unread message

Maurice Mouw

unread,
Nov 18, 2014, 2:59:32 AM11/18/14
to spade...@googlegroups.com
Hi,

I've been workin with SPADE for a few weeks now. I need to build several MAS for a school project. Most of examples given are pretty straight forward and based on those I've made serveral agents.
Since last week I started working on FSM. I want to build several agents working on this. Based on the example I've build the attached 'buildrad.py'. I was wondering if the current setup I used is possible. When i start the agent i get the following:

As you can see it won't transition to the second stage. In this case i would be pretty sure it should at least go to the second because the connection to the localhost on port 80 is possible. If i strip the code i used there it works fine.
I'm probaply missing somthing here.

#note i've been doing this and serveral other things for school in the last few days(yes also the weekend) and have slept about 4-5 hours a night#

Any help would be appreciated :-)
buildrad.py

Markus Schatten

unread,
Nov 18, 2014, 7:47:00 PM11/18/14
to spade...@googlegroups.com
Dear Maurice,

here's a little fix, instead of addBehaviour, put:

        self.setDefaultBehaviour(b)

The problem is that the agent doesn't seem to use FSM behaviour as a default one for message receiving. All states automatically get the message from the FSM behaviour (they use its _receive method).

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

--
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 18, 2014, 7:50:28 PM11/18/14
to spade...@googlegroups.com
And sorry I forgot, you also need to fix the if-else in the first state, since you cannot get to the second behavior:

    class StateOne(spade.Behaviour.OneShotBehaviour):
        REMOTE_SERVER = "127.0.0.1"
        def _process(self):
            print ("This is State One...")
            msg = self._receive(block=True,timeout=1)
            self._exitcode = self.myAgent.TRANSITION_DEFAULT
            if msg:
                if "True" in msg.getContent():
                    self.myAgent.counter = self.myAgent.counter + 1
                if self.myAgent.counter > 2:
                        self._exitcode = self.myAgent.TRANSITION_TO_TWO
            else:
                time.sleep( 1 )

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