swarm-modeling
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Modelling] How to send and get messages between two agents of


From: Rick Riolo
Subject: Re: [Swarm-Modelling] How to send and get messages between two agents of different types?
Date: Thu, 6 Jan 2005 09:00:35 -0500 (EST)

there are many ways to set things up for agents to send each other
messages---the "best" way depends on the circumstances.
the basic idea, tho, is that then sAgent (sender) must know the address
(pointer to) the rAgent (receiver).
So for example, if agents have a fixed set of others to whom they send
messages (their "neighbors"), then the Agent object could have some
id instance variables (iv) to hold the addresses of those neighbors.
   id neighbor1, neighbor2;
At some point in building the model, the program must be sure
to store the address of rAgent in, say, sAgent's neighbor1 iv.
   [sAgent setNeighbor1: rAgent];
Once that is done, sAgent can send messages to rAgent, eg,
  -(void) sendMessagesToNeighbors () {
    ...
    [neighbor1  message... ];
    ...
  }

Another approach, for cases where the receivers are not known ahead of
time, is to have all potential rAgents on a list,
and have sAgent search that list for the address of the appropriate
rAgent when its time to send a message to rAgent.

And there are many other ways to do that.

regarding your question #2:

If I understand the question, you are asking how to do program
development and testing.  There are many books about this.  One good one is
  Code Complete by Steve McConnell
But there are many other good books, especially related to
development in an OOP enviroment.
You might also look at the "extreme programming" books.

Directly addressing your question:  one approach to test the A class
methods independent of the other classes is to write test programs
that are explicitly designed to test just class A.
Of course often class A acitivity depends on the functionality
of some of the other classes, so there are different approaches
to handling that problem.  (eg develope A and B together.)

I think it is key to NOT write the entire program and all its
functionality all at once, and then start testing.  I would suggest
writing minimally function versions of the various classes, get that
running, then add additional functionality bit-by-bit, testing each
new addition as appropriate.

good luck!

- r



Rick Riolo                           address@hidden
Center for the Study of Complex Systems (CSCS)
4477 Randall Lab
University of Michigan         Ann Arbor MI 48109-1120
Phone: 734 763 3323                  Fax: 734 763 9267
http://cscs.umich.edu/~rlr

On Thu, 6 Jan 2005, James Liu wrote:

> Date: Thu, 6 Jan 2005 21:17:14 +0800
> From: James Liu <address@hidden>
> Reply-To: Swarm Modelling <address@hidden>
> To: modelling <address@hidden>
> Subject: [Swarm-Modelling] How to send and get messages between two
>     agents of different types?
>
> Dear All:
>
> I am new user of Swarm and I plan to use it for simulating a Multi-agent 
> system in my Msc thesis.  Now I have some questions in simuation with Swarm 
> as follows:
>
> 1.There are four types of agent such as A,B,C,D in the model.They interact 
> with each other.
> How to send and get messages between two  agents of different types,for 
> example,A send a message to B(A tell something to B) and get a message from 
> B(A receive a reply from B)to decide what to do next.How to relize it in 
> Swarm with ObjC?
>
> 2.There are many source code files such as
> A.h,A.m,B.h,B.m,C.h,C.m,D.h,D.m,then what shoud I do if I want to debug
> and compile a file A.h/A.m after finishing the souce code of A.h/A.m
> respectively instead of debugging and compiling the project to a
> executable file after all the files(A.h,A.m,B.h,B.m,C.h,C.m,D.h,D.m)
> finished?
>
> btw:I know little about gcc and gdb.
>
> I would appreciate your feedback. Thanks a ton!
>
> Best regards,
>
> James
>
>
>
> James Liu
> Room 313, Laodixuelou Building
> College of Environmental Science
> Peking University
> Beijing,100871
> China
>
>
>      2005-01-06
>
> _______________________________________________
> Modelling mailing list
> address@hidden
> http://www.swarm.org/mailman/listinfo/modelling
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]