swarm-modeling
[Top][All Lists]
Advanced

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

Re: [Swarm-Modelling] world getObjectAt and Others


From: Vitorino RAMOS
Subject: Re: [Swarm-Modelling] world getObjectAt and Others
Date: Mon, 16 Jun 2003 16:39:59 +0100

At 15:25 15-06-2003 +0200, you wrote:

On Tuesday, Jun 3, 2003, at 16:26 Europe/Berlin, Paul E. Johnson wrote:

I can't help unless you tell what exactly you did why/how it did not work.

I got ants running frome source to nest, two different sizes and either carrying something or not.
this are attribute which I can set via methods  // setBigAnt
setCarryItem
if this ants meet each other the following happens
1: if a big ant with food meets a small ant or another big ant without food, nothing happens, the ant walks further towards the nest 2: if a big unloaded ant meets a small loaded ant, it takes the food and returns to the nest, the small one walks back towards the source.
genarrly loaden ants walk towards the nest, unloaden towards the source
what I implemented is this:

- step
// the part of walking from source to nest and backwards
// and the conditions for exchanging food and changing places
{
    int newX, newY;


    if(([self isBigAnt] == YES) & ([self getCarryItem] == YES))
    {
        if ((xPos + 1)< 100)
        {
            newX = xPos + 1;
        }
        else if ((xPos + 1) == 100)
        {
            newX = xPos - 1;
            [self setNewCarryItem];
        }
    }

    else if (([self isBigAnt] == YES) & ([self getCarryItem] == NO))
    {
        if ((xPos - 1) > 0)
        {
            newX = xPos - 1;
        }
        else if ((xPos - 1 ) == 0)
        {
            newX = xPos + 1;
            [self setposCarryItem];
        }

    }


    else if (([self isBigAnt] == NO) & ([self getCarryItem] == NO))
    {
        if ((xPos - 1) > 0)
        {
            newX = xPos - 1;
        }
        else if ((xPos - 1) == 0)
        {
            newX = xPos + 1;
            [self setposCarryItem];
        }

    }

    else if (([self isBigAnt] == NO) & ([self getCarryItem] == YES))
    {
        if ((xPos + 1) < 101)
        {
            newX = xPos + 1;
            [self setNewCarryItem];
        }
        else if ((xPos + 1) == 100)
        {
            newX = xPos - 1;
            [self setNewCarryItem];
        }

    }

    newY = yPos + [uniformIntRand getIntegerWithMin: -1 withMax: 1];

    newX = (newX + worldXSize) % worldXSize;
    newY = (newY + worldYSize) % worldYSize;

    // Check that no other ant is at the new site.

    if ([world getObjectAtX: newX Y: newY] == nil)
    {
        [world putObject: nil atX: xPos Y: yPos];
        xPos = newX;
        yPos = newY;
        [world putObject: self atX: newX Y: newY];
    }

  return self;
}

but how can catch the event of the meeting of two ants so that I can
implement the exchange of the food and the change in the walking direction?

thanks a lot

--



Georg Apitz

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WALS Project
Executive Programmer

Max Planck Institute for Evolutionary Anthropology
Deutscher Platz 6
04103 Leipzig
Germany
Phone: +49 (0) 341 3550 - 314
Telefax: +49 (0)341 3550 - 333

address@hidden
www.eva.mpg.de
www.ge-org.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_______________________________________________
Modelling mailing list
address@hidden
http://www.swarm.org/mailman/listinfo/modelling


Dear George:

Apart from the implementation details your model is interesting with two castes. I wonder if you have something already published on your previous works related to this ? Here is also a couple of pointers that you probably will find interesting (some of my works around stigmergy):

http://alfa.ist.utl.pt/~cvrm/staff/vramos/ref_42.html

http://alfa.ist.utl.pt/~cvrm/staff/vramos/ref_39.html

http://alfa.ist.utl.pt/~cvrm/staff/vramos/ref_29.html

best. And a good work. vitorino


~ v. ramos, http://alfa.ist.utl.pt/~cvrm/staff/vramos, "An invisible red thread connects those destined to meet, regardless of time, place, or circumstance. The thread may stretch or tangle, but never broken", Chinese proverb.



reply via email to

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