Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

RE: Agent communication in a selected area

New Message Reply Date view Thread view Subject view Author view

Subject: RE: Agent communication in a selected area
From: Nicolas Becu (nicolas.becu@gmail.com)
Date: Sun Apr 27 2008 - 16:42:10 CEST

Hello François,

 

To send the message only to the agents situated on the same cell as the
sender you could use the following for example:

 

Instead of sending a message to all the acquaintances, you can use some
perception methods defined by Cormas, such as

similarAgentsOnMyCell := self perceivedSimilarAgentsWithinRange: 1. “a
radius of 1 includes only the cell the agent is on”

 

OR

agri01OnMyCell := self perceivedEntities: #Agri01 withinRange: 1. “

 

OR “if you want to send the messages to all the agents Agri01, Agri02, 03
etc.. “

agriOnMyCell := IndexedSet new.

1 to : 5 do :[ :i|

agriOnMyCell addAll : (self perceivedEntities: ((‘Agri0’, i printString)
asSymbol) withinRange: 1)].

 

 

Then you continue your method as in your actual script, but you use the
temporary variable earlier defined instead of acquaintances. As so,

similarAgentsOnMyCell “OR agri01OnMyCell “ do: [:x |
                    alarm location: (Cormas selectRandomlyFrom:
bigNeighbours).
                    alarm receiver: x.
                    self sendMessageAsynchronously: alarm].

 

Hope this helps,… and good luck

 

Nicolas

 

PS: nice idea to have a CA within a CA

 

 

De : owner-cormas@cirad.cirad.fr [mailto:owner-cormas@cirad.cirad.fr] De la
part de François Rebaudo
Envoyé : samedi 26 avril 2008 00:43
À : cormas@cirad.fr
Objet : Agent communication in a selected area

 

Hello,

One question for which I'll be glad to receive some help.

My CA is divided into x areas of y cells (like big cells containing smaller
ones), and this information is contained in an instance variable named
agroPart (agroPart=[1:90]).
I have 5 different types of agent [Agri01 ; Agri02 ; Agri03 ; Agri04 ;
Agri05]. When one send a message, I would like to be sent only to agents
situated in the same area x of the CA (or to be received only by agents of
the area x of the CA). What I found to make it work is the following code:

CormasNS.Models.SimPolillaSimiatug_v02 defineClass: #Agri01
    superclass: #{CormasNS.Kernel.GroupCommLocation}
    indexedType: #none
    private: false
    instanceVariableNames: '... stockSend stockRead '
    classInstanceVariableNames: ''
...

alarmCalling
...
    bigNeighbours size > numCeldas
        ifTrue:
            [alarm := MsgHelp new.
            alarm sender: self.
            alarm symbol: #alarm.
            self acquaintances do:
                    [:x |
                    alarm location: (Cormas selectRandomlyFrom:
bigNeighbours).
                    alarm receiver: x.
                    self sendMessageAsynchronously: alarm].
        emit:=1.
        90 timesRepeat:[
            self patch agroPart = emit ifTrue:[self stockSend: emit].
            emit:=emit+1]]

readMail
| aMessage recept|

aMessage := self nextMessage.

recept:=1.
90 timesRepeat:[
    self patch agroPart = recept ifTrue:[self stockRead: recept].
    recept:=recept+1].

self stockRead = self stockSend ifTrue:[
    aMessage notNil ifTrue:[
        self leave.
        self moveTo: aMessage location]
    ifFalse: [
        self moveIntoAgroPart]]

But I would like my agents to send the message to both the agents of its
type and the other agents. What should I change to my code to realize that.

Thanks

François Rebaudo

New Message Reply Date view Thread view Subject view Author view
 

Back to home