swarm-modeling
[Top][All Lists]
Advanced

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

Re: mining sugarscape


From: Paul Johnson
Subject: Re: mining sugarscape
Date: Mon, 18 Sep 2000 13:32:56 -0500

Sharon Gifford wrote:
> 
> I have taken Benedikt's advice and created at site class which keeps track of 
> the number of mines on each site.  As each agent visits a site and creates a 
> mine, the number of mines at that site is increased.  I have also created a 
> mine class that keeps track of how each mine is doing depending on how many 
> other mines are at the site (from the site class) and on how long it has been 
> since the agent visited the mine (the mine's "age").
> 
> Question:  Do I "build" these things in ModelSwarm?  The agents establish the 
> mines over time and add them to the listOfMines at the site.  The sites are 
> just the points in the Discrete2d SugarSpace.
> 

The site class can hold mine objects. So when you put a site at a spot
in the matrix, all you need is "interface" that agents can use to add
mines.  You probably don't create those mine objects in model swarm, but
rather the agents themselves have some method like "createMineAtX: Y:"
and in that method, they create a mine object, then they grab the site
from the grid, insert the mine into the site, and move on.  You can use
a wrapper class like Sven's MoGrid or my newer version WrappedListGrid
to make this a bit easier.  Unless you have some kind of wrapper
interface around the grid, you will always have to do that tedious thing
where you retreive the object from the grid and work with it. If you
have a wrapper class, then you can just make an "addAtX:Y:" method there
and then the agents can create sites and just dump them where they want.

If your program starts to run really slow because you are constantly
searching through long lists for particular mines, you might think about
using the avl_tree functions. Search is must faster that way. I've got
avlusage examples in the WorkingExampleCode/objc subdirectory of the
SwarmFaq directory on my site. THere is also a full fledged class I
prepared, AVLSet, because I have to do the same kind of thing you are
doing.

good luck
pj


-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700


                  ==================================
   Swarm-Modelling is for discussion of Simulation and Modelling techniques
   esp. using Swarm.  For list administration needs (esp. [un]subscribing),
   please send a message to <address@hidden> with "help" in the
   body of the message.
                  ==================================


reply via email to

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