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

Re: more questions from a beginner



   I find not many of the die - most of them wrap to the bottom part of the
   screen, apparently not sensing when they pass over a yellow patch. If I
   change the number of steps forward to 1, then they do die at the boundary,
   but they move too slowly then. With a recursive process do the turtles only
   check the patch colour at the end of the fd n steps and not at all times?

In StarLogo, the "time slicing" typically involves each parallel
process executing one Logo command. The command "fd n" counts as a
single command. So the command that checks for color-under will
execute only after the entire forward motion, not in the middle. To
check for color-under, it is best to use steps of "fd 1". Yes, that
makes the turtle slower, but I'm afraid there is no good alternative.

    With the turtles that do the move.gas routine, is there any way to express
   a random heading between -90 and 90? It would be nice if they went to the
   left as well as the right but I don't seem to be able to come up with an
   expression that is acceptable to Star Logo. I've been wondering if there
   any way to program inverse sine for instance, so that the turtles could
   adopt a random heading angle whose sine is between 0 and +1.

If you want to turn a random amount left or right, you can do one of
the following:
    RT RANDOM 90 LT RANDOM 90
    or
    RT -90 + RANDOM 181

Note that two alternatives give different distributions of
angles.  I tend to prefer the first since it seems more "intuitive."

I hope this is helpful.

-- Mitchel