So i'm having a probelm making my netlogo simulation to stop after all the patches have turned yellow. i want the turtle to go through the world and find all black patches and turn them into yellow and right after the last one i want the simulation to stop.
globals [marked-patches angle nextangle]
to setup
clear-all
ask patches[set pcolor black ]
crt turt [setxy random-xcor random-ycor set size 1 set color red pd]
ask turtles [
ifelse draw-paths? [pen-down] [pen-up]]
reset-ticks
end
to go
ask turtles
[
set heading (random 360)
rt 50
forward 1
if pcolor = black [set pcolor yellow
if count patches with [pcolor = black] = 0 [
stop
]
]
set marked-patches count patches with [pcolor = yellow]
if (count patches = marked-patches)[stop]
]
tick
end
to patch-count-plot
set-current-plot "area covered"
set-current-plot-pen "number of patches"
set marked-patches count patches with [pcolor = yellow]
plot marked-patches
end
Aucun commentaire:
Enregistrer un commentaire