[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
re: StarLogo overload
Hi Andy, and thanks for the comments. I have copied all the code for this
model down the bottom of this e-mail, and here is a list of the buttons etc:
button 1: runs "setup" (once only)
button 2: runs "move.liquid" (forever)
button 3: runs "check.for.border" (forever)
button 4: runs "start" (once)
button 5: runs "stop.it" (once)
button 6: runs "dry.up" (forever)
a slider giver the input value of "boiling.pt" (0 to 110 range)
and a monitor window displays the values of "temp.liquid"
The start procedure operates the evaporation model. There is a little
leakage of the green turtles into the white zone, but I don't seem to be
able to prevent it, and I'm not too worried about it. If you push the
dry.up button after the model has started, that's when things seems to get
jammed up. It doesn't make my computer freeze or anything like that, just
the model itself seems to seize.
Any suggestions greatly appreciated.
Regards, Kay
The code for the whole thing is:
turtles-own [energy]
globals [ysky]
to setup
ca
crt 500
setc green
setx random screen-size
sety ((-1 * random screen-edge) - 1)
setenergy random 110
ifelse ycor > 0 [setpc white] [setpc blue]
make.borders
end
to make.borders
setysky 0
if ycor = 0 [setpc sky]
if ((xcor = screen-edge) and (ycor >= 0)) [setpc yellow]
if ((xcor = -1 * screen-edge) and (ycor >= 0)) [setpc yellow]
if ycor = screen-edge [setpc yellow]
if ycor = -1 * screen-edge [setpc black]
if ((xcor = screen-edge) and (ycor < 0)) [setpc black + 1]
if ((xcor = -1 * screen-edge) and (ycor < 0)) [setpc black + 2]
if (((xcor = screen-edge) or (xcor = -1 * screen-edge)) and (ycor = -1 *
screen-edge)) [setpc black + 3]
end
to dry.up
every 0.1 [drop.level]
setenergy (energy + 5)
end
to drop.level
if ycor = (ysky - 1) [setpc sky]
if ((xcor = screen-edge) and (ycor >= (ysky - 1))) [setpc yellow]
if ((xcor = -1 * screen-edge) and (ycor >= (ysky - 1))) [setpc yellow]
if ycor = ysky [setpc white]
setysky (ysky - 1)
end
to move.liquid
fd 1
left random 30
right random 30
end
to check.for.border
if ((pc = sky) and (energy >= 0.8 * boiling.pt)) [gas.heading move.gas]
if ((pc = sky) and (energy < 0.8 * boiling.pt)) [seth 180 fd 5]
if (pc = yellow) [die]
if (pc = (black + 1)) [seth 270 rt random 45 lt random 45 fd 5]
if (pc = (black + 2)) [seth 90 rt random 45 lt random 45 fd 5]
if (pc = black) [seth 0 rt random 45 lt random 45 fd 5]
if (pc = (black + 3)) [seth 45 fd 5]
end
to move.gas
fd 1
check.for.border
move.gas
end
to gas.heading
setc black
seth 0
rt random 90
lt random 90
end
to start
button3
button2
end
to stop.it
stopbutton2
stopbutton3
stopbutton6
end
to temp.liquid
output ((sum-of-turtles-with [color = green] [energy] / count-color green)
/ 2.5)
end