[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
more questions from a beginner
- Date: Sat, 18 Oct 1997 21:39:57 +1000 (EST)
- From: Kay McCullough <mccullou@netspace.net.au>
- Subject: more questions from a beginner
Hello again, and thankyou to Mitch for the reply to my question last week -
the advice helped me make considerable headway. Now I'm stuck again and
wonder if you could help me sort out a few matters. If there is a
list-server group I could post questions like these to, could you please
let me know the address, as I don't want to bother you...its just there are
not many people to ask around here and my Course Adviser suggested I
contact you again.
My main question relates to how the parallel processes for turtles work and
how turtles running under recursive and forever processes (is a forever
process called a demon?) interact with patches.
For example: Here is the code I am trying to develop to simulate evaporation:
turtles-own [energy]
to setup
ca
crt 800
setc green
setx random screen-size
sety -1 * random screen-edge
setenergy random 30
ifelse ycor > 0 [setpc white] [setpc blue]
make.borders
end
to make.borders
if (((xcor = screen-edge) or (xcor = -1 * screen-edge)) and (ycor > 0))
[setpc yellow]
if ycor = screen-edge [setpc yellow]
if ycor = 0 [setpc sky]
if ycor = -1 * screen-edge [setpc black]
if (((xcor = screen-edge) or (xcor = -1 * screen-edge)) and (ycor < 0))
[setpc black + 1]
if (((xcor = screen-edge) or (xcor = -1 * screen-edge)) and (ycor = -1 *
screen-edge)) [setpc black + 2]
end
to move.liquid
fd random 3
left random 30
bk random 3
right random 30
end
to check.for.border
if ((pc = sky) and (energy >= 25)) [seth random 90 move.gas]
if ((pc = sky) and (energy < 25)) [seth 180 fd 5]
if (pc = yellow) [die]
if (pc = (black + 1)) [seth (-1 * heading) fd 5]
if (pc = black) [seth (180 - heading) fd 5]
if (pc = (black + 2)) [seth 45 fd 5]
end
to move.gas
setc black
fd 7
check.for.border
move.gas
end
As you can see, I've set up a line of yellow patches along the top and
upper side edges of the screen and I want any turtles with enough energy to
emerge from the blue area and adopt the move.gas procedure to die when they
hit the upper boundaries of the screen...
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?
I also have trouble with turtles in the bottom half of the screen wrapping
to the top, and turtles getting through the boundary at the middle.I want
them to be contained in the blue part of the screen. I think the problem
could be tied up with the motion I have put in for random motion of
molecules in a liquid, causing unexpected results at the bottom boundaries,
but it might be tied up with how the forever procedures operate and how
often they run the check.for.border routine. If you can understand what I
am getting at, could you please clarify this for me?
Also,
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.
I apoligise for the length of this message, and really hope these questions
are not trivial. Any advice or directions to a suitable list-server group
would be gratefully accepted.
Thanks again,
Kay McCullough