turtles-own [energy]
to setup
clear-all
setup-patches
setup-turtles
create-turtles 100 [ setxy random-xcor random-ycor ]
reset-ticks
end
to go
move-turtles
eat-grass
reproduce
check-death
regrow-grass
tick
end
to move-turtles
ask turtles [
right random 360
forward 1
set energy energy - 1
]
end
to setup-patches
ask patches [ set pcolor pink ]
end
to setup-turtles
create-turtles 100
ask turtles [ setxy random-xcor random-ycor ]
end
to eat-grass
ask turtles [
if pcolor = pink [
set pcolor black
set energy energy + 10
]
ifelse show-energy?
[ set label energy ]
[ set label "" ]
]
end
to reproduce
ask turtles [
if energy > 50 [
set energy energy - 50
hatch 1 [ set energy 50 ]
]
]
end
to check-death
ask turtles [
if energy