List Info

Thread: Question regarding hatch




Question regarding hatch
country flaguser name
United States
2007-08-03 09:58:50

Here's some code:

ask turtles[
loop[
[do-stuff]

[hatch more turtles]
]
]

I'd like that the turtles being hatched within this loop "do-stuff" as
well. At the moment, they are hatched and remain idle. I realize that
they need to be "asked" to "do-stuff". How can I do that while
remaining in the loop and not affecting the behavior of the other
turtles already "doing stuff";

Thanks!

__._,_.___
.

__,_._,___
Re: Question regarding hatch
country flaguser name
United States
2007-08-03 12:12:57

Hi!

To make newly hatched turtles perform commands, just follow the hatch
command with a command block:

ask turtles
[ hatch 1
[ command-for-the-new-turtles
]
]

(also, i'm sure you didn't mean to include LOOP in your ASK
commands... LOOP creates an infinte loop -- generally, you would only
use LOOP with something inside that contains STOP, to break out of the
loop. Also, generally, you would never use LOOP if you could avoid it,
and most times, you are better off using ASK, REPEAT, WHILE, FOREACH,
or a list traversal reporter like MAP, FILTER, SORT or REDUCE.)

~~James
http://www.turtlezero.com

On 8/3/07, cooldia00 < no_reply%40yahoogroups.com">no_replyyahoogroups.com> wrote:
&gt; Here's some code:
&gt;
> ask turtles[
> loop[
&gt; [do-stuff]
>
&gt; [hatch more turtles]
> ]
> ]
>
> I'd like that the turtles being hatched within this loop "do-stuff" as
> well. At the moment, they are hatched and remain idle. I realize that
>; they need to be "asked" to "do-stuff". How can I do that while
&gt; remaining in the loop and not affecting the behavior of the other
&gt; turtles already "doing stuff";
>
> Thanks!

__._,_.___
.

__,_._,___
Re: Question regarding hatch
country flaguser name
United States
2007-08-03 12:05:41

At 09:58 AM 8/3/2007, you wrote:

>Here's some code:
&gt;
>ask turtles[
> loop[
&gt; [do-stuff]
>
&gt; [hatch more turtles]
> ]
>]
>
&gt;I'd like that the turtles being hatched within this loop "do-stuff" as
>well. At the moment, they are hatched and remain idle. I realize that
>;they need to be "asked" to "do-stuff". How can I do that while
&gt;remaining in the loop and not affecting the behavior of the other
&gt;turtles already "doing stuff";

Try putting the ask inside the loop instead of the loop inside the ask.

Teresa Carrigan
tcarr%40acm.org">tcarracm.org

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.2/933 - Release Date: 8/2/2007 2:22 PM

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )