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

Turtle zombies and other questions



Hello,

In this mail I ask some questions about the details of the StarLogo
language.

My first question concerns the very first instruction in the reference
manual: alive?. I was wondering if this reporter had a non-trivial use.
I mean, could alive? ever possibly return false?

alive?-of, of course, can return false and tell if a turtle with a given
ID-number is alive. But alive? is only carried out by the turtles, that
is, the living ones. Or could we have a funny conversation with a
zombie-like turtle: "Dear turtle, are you alive?" "No, sorry, I died ages
ago..."

I did some experiments to see whether I can have a turtle do something
after its death, but -not surprisingly- I failed. However, I did find an
interesting thing about hatch and sprout.
Consider this:
ca crt 100
hatch [die]
show count-turtles   -> 100
sprout [die]
show count-turtles   -> 541 (the actual number depends on the settings)
Why the difference in the remaining number of turtles between hatch and
sprout?

***

My next question is about the exceptional command 'wait'. It is
exceptional because it is neither a reporter nor a language construct
(like if, repeat, output, etc.) yet it is in more than one categories of
turtle-only/patch-only/observer. According to the reference manual, it is
an observer and turtle command. So, I was wondering, if I write 'wait 5'
into the command center, what decides whether I am talking to the turtles
or the observer?

I set up some forever buttons which made the turtles move and had the
patches change their color to see who will wait. To my surprise, it was
the patches which stopped, so I was talking to the patches with 'wait 5'.

By having StarLogo produce an error message for wait (putting it into
brackets, [wait 5], for example), StarLogo mentions wait as a 'turtle or
patch command', which seems to contradict the reference manual.

May I suggest here a new instruction or a menu item in StarLogo which
would tell about a command (or a whole instruction-list) whether it is
turtle, patch or observer? That could help to solve such doubts as with
wait.

My feeling about how things work is that wait probably acts like an
observer command, and the patches wait because the they are instructed
through the observer. (I don't know if I can have the turtles wait with
the command 'wait'.)

And another question about 'wait': could somebody comment on the use of
'wait 0'? I saw it in some projects.

***

And finally I would like to ask (again) about 'if' for the patches.
We know from the docs and from previous discussions that the main rule in
patch parallelism is that the patches remain synchronized all the time:
one instruction is carried out for all of them in a cycle, then the next
instruction, etc. And that is the main reason, I suppose, why 'repeat' for
the patches becomes an observer command - in this way, the patches can
remain syncronized. But then I was lead to ask how if-branches are done for
the pathces so that they stay synchronized. There could be a large tree-
hierarchy of if and ifelse branches one inside the other, and the patches
can be in different branches depending on the predicates.
If we have
ifelse pred [branch-A] [branch-B]
for the patches, what happens? What I think probably happens is that pred
is evaluated for all patches, and first the patches for which it is true
are synchronized when they run branch-A, while the other patches where
pred was false rest. Then those patches with pred = true rest (do nothing)
while branch-B is executed for those with pred = false.
And if we have a large tree-hierarcy of 'if' and 'iflelse', then we go
through all the nodes of the tree, in each node only the appropriate
patches work (in synchronization) and the others do nothing.
Am I on the right track?

Cheers,

Gyorgy