Re: carrying, killing

jon klein <[email protected]>
Newsgroups gmane.comp.breve
Message-ID <[email protected]>
On Jan 30, 2004, at 4:10 AM, sky wrote:

> A couple of new questions from an ultra-novice.
>
> I am trying to model an information-exchange particle on the
> "gatherers.tz" food, but I cannot figure out how to get an agent to
> "own" more than one food particle at a time and to exchange them with
> other agents. I have been messing around with the code, but I cant get
> them to pick up more bits, even if I disable the "drop" feature.

In the Gatherers demo, the "carrying" occurs because the gatherer
constantly updates the position of the food as it moves along, using
the iterate method.  In order to carry multiple pieces of food, you'll
need to have the gatherer keep track of multiple Food objects.

So, for example, when the agent wants to pick up a new piece of food:
	push newFood onto foodList.

And then, in the iterate method:
	foodList move to (self get-location) - (1, 0, 0).

> Also, I am having problems "freeing" an agent that has flocking 
> behavior
> associated with it. Do you have any "fighting" code examples?

This generally occurs because something is later trying to access the
freed agent.  The best thing to do is figure out why exactly this is
happening, and make sure that when an agent is freed, that other agents
understand that it doesn't exist anymore.  A quicker fix is to simply 
test
the agent variable before using it:

	if agent: {
		# do stuff...
	}

- jon klein

_______________________________________________
breve mailing list
[email protected]
http://www.spiderland.org/mailman/listinfo/breve
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.