[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mining sugarscape
From: |
Benedikt Stefansson |
Subject: |
Re: mining sugarscape |
Date: |
Wed, 26 Jul 2000 12:29:58 -0600 |
Sharon,
Yes, you'd probably be best off creating a site class, this class would contain
as instance variable the list of its miners, growth and dividend parameters and
the state variable (sugar). Header file could look something like this:
@interface Site: SwarmObject
{
double sugar;
double growthRate;
double dividend;
id <List> list;
}
+ createEnd; // Create the list here
- addMiner: m; // Used by miners to add themselves to the list
- step; // Grows the sugar and doles out dividends
- removeMiner: m; // Used to remove miners from list
@end
Each miner that arrives and claims the site will add him/her self to the list:
- addMiner: m
{
[myList addLast: m];
return self;
}
I assume you will define a simple law of motion for the growth of stock of
sugar per period (e.g. grows by 'growthRate' per period) and the extraction
rate per miner per period (e.g. each miner extract 'dividend' number of units
per period); so the 'step' function of the site would calculate the new stock,
and then 'extract' some fixed number of units of sugar and iterate over the
list of miners, 'sending' each miner his share:
- step
{
sugar = sugar * (1 + growthRate);
// Create an index to iterate over list
index = [myList begin: [self getZone]];
// Iterate over list
while((miner = [index next]))
{
// Extract dividend (if enough sugar)
if(sugar >= dividend)
{
sugar = sugar - dividend;
[miner takeSugar: dividend];
}
}
[index drop];
return self;
}
Hope this helps,
Benedikt
Sharon Gifford wrote:
> I want to adapt sugarscape so that after an agent visits a site, it continues
> to generate "sugar" for that agent, as if the agent had set up an ongoing
> mining operation that continues to operate while the agent leaves to explore
> for additional sites. However, others can also mine the same site, reducing
> the amount of sugar available for others who mine the site. Each agent can
> return to the site to improve the performance of that agent's mine. I have
> the Multi2D files for multiple occupancy from the Swam http site and Paul
> Johnson's "culture", and will probably use a listOfMines like the
> listOfFriends in hello-world to keep track of each agent's mines. However,
> each cite now seems to be an object itself, whose behavior changes each
> period depending on how many agents have visited it. Is it best to create a
> pair of .h and .m files for a class of "cites" objects? Has anyone done
> anything like this before. I'm still a novice with Swarm and very afraid to
> try this alone.
>
> Sharon
> Prof. Sharon Gifford
> Faculty of Management
> Department of Finance and Economics
> Co-Director Center for Entrepreneurial Management
> Rutgers University
> 180 University Avenue
> Newark, NJ 07102
> 973-353-1646
> http://andromeda.rutgers.edu/~sgifford/webpage.html/
>
> ==================================
> 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.
> ==================================
--
Bushism of the day
--------------------------------------------------
"It's clearly a budget. It's got a lot of
numbers in it."
George W. Bush, Governor of Texas
--Reuters, May 5, 2000 (Thanks to Allison
Fansler.)
(Source: Jacob Weisberg in Slate magazine)
--------------------------------------------------
--
Benedikt Stefansson | address@hidden
HNC Software (CASA) | Ph : (505) 988-8807 x101
Santa Fe, NM | Fax: (505) 988-3440
==================================
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.
==================================
- mining sugarscape, Sharon Gifford, 2000/07/26
- Re: mining sugarscape,
Benedikt Stefansson <=