[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
commas & turtle orders in StarLogo
- Date: Thu, 6 Nov 1997 18:05:29 -0800
- From: Jerry Balzano <gjbalzano@ucsd.edu>
- Subject: commas & turtle orders in StarLogo
I have some questions about commas in StarLogo. I remember reading a
little about them in some version of the documentation (I've been on this
list since v1.0), but I can no longer recall where, or precisely what.
My understanding is that when you place a comma between two consecutive
StarLogo commands, like
"fd 1" and "setc blue", this forces all of the turtles to finish doing "fd
1" before any of them do "setc blue". My first question is, does this work
the same way when the commands separated by commas refer to user-defined
procedures each consisting of several StarLogo primitives? And my second
question is, does a comma work the same way when it is placed between a
turtle command and a patch command?
I am having synchronization problems in a project I am working on that are
hard to track down, as follows. I have two breeds of turtles, who are
competing for the same "food" (patch color). When there are two turtles,
one of each breed, both sitting right beside a food patch, I want them both
to have an "equal opportunity" to get the food. I assume that in general
this would be no problem since the order in which turtles execute a command
addressed to all of them is essentially random, so half the time turtle A
would get the first shot and half the time turtle B would get the first
shot (right?). But now suppose that the turtles of breed A have some extra
processing to do, say for example they need to run an extra procedure "foo"
(i.e. ask-breedA [foo]) that turtles of breed B don't need to do. If,
furthermore, this "foo" procedure needs to run *before* the turtles of
either breed get a chance to eat, won't this extra processing for the A's
tend to make them lose the race for the food? How should I think about
writing my StarLogo code -- named procedures, commas, etc. -- to prevent
this kind of thing from happening?
In *Turtles, Termites, & Traffic Jams*, Mitch Resnick displays a style of
StarLogo programming where patch, turtle, and observer code are separated
from one another. This style is generally not preserved in the Sample
Projects, and I wondered why not. StarLogo, of course, allows you to mix
all three types of commands, and I usually do just that, but wouldn't it be
clearer (and therefore recommended) to keep the doings of the different
"actors" separate as a matter of method? Or not?
-------------------------
Dr. Gerald J. Balzano
Dept of Music
Teacher Education Program
Laboratory for Comparative Human Cognition
Cognitive Science Program
UC San Diego
La Jolla, CA 92093
(619) 822-0092
gjbalzano@ucsd.edu