I have been working on the butterfly hilltopping exercise but the corridor width value that I get is different from the one published in the book (p.68 Fig. 5.2).
The book states:
If you did everything right, you should obtain a corridor width of around 320–330 when q is 0.4.
The values I get range between 70 to 80.
What am I doing wrong in the code I really don't get..
The code I have is below:
patches-own [elevation used?]
turtles-own [start-patch]
to setup
ca
ask patches
[
set elevation 200 + (100 * (sin (pxcor * 3.8) + sin (pycor * 3.8)))
set pcolor scale-color green elevation 0 400
set used? false
]
reset-ticks
create-turtles 500
[
set size 2
setxy 71 69
pen-down
set start-patch patch-here
]
end
to go
ask turtles [move]
plot corridor-width
tick
if ticks >= 1000 [output-print word "Corridor width: " corridor-width stop]
end
to-report corridor-width
let countpatches count patches with [used?]
let meandistance mean [distance start-patch] of turtles
report countpatches / meandistance
end
to move
ifelse random-float 1.0 < q
[uphill elevation]
[move-to one-of neighbors]
set used? true
end