1

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

Interface Screenshot

desertnaut
  • 57,590
  • 26
  • 140
  • 166
raurackl
  • 9
  • 4

2 Answers2

1

First thing I will note is that your butterflies don't "stop" when they have reached the highest local elevation- there is a relevant section in the book that discusses making them stop at that point, so if you've omitted that it may play with your numbers slightly. Also, we have slightly different versions of the book (my expected corridor width for this section is 25), but can you confirm that your elevation landscape matches that in your book? The landscape defined in your code above looks like:

enter image description here

Whereas when I follow the code in my version of the book (which may be a little older, not sure) it looks different, since there are two "peaks" at (30, 30) and (120, 100):

enter image description here

Have you made other modification from the values as presented in the book? For example, your code above uses 500 butterflies. In my version of the textbook, it expects me to have 50 butterflies at the point where it indicates the expected corridor width (in my case, ~25). If I bump up the number of butterflies present, it changes the average corridor width.

Luke C
  • 10,081
  • 1
  • 14
  • 21
  • Yes, same exact landscape. No other modification in the code. There are more hilltops in the example from the second edition of the book. – raurackl Sep 13 '21 at 06:09
  • @raurackl - Fair enough, I'm afraid I can't be of help as I only have the older edition. Good luck! – Luke C Sep 13 '21 at 07:10
0

I think it is because you have all of your turtles starting on the same patch (71,69), because of this code: setxy 71 69. So there's no variety in their starting patches, which will later affect the fraction when you use the avg. distance of any turtle from its starting patch to its final location.

At some point the book had us change the fixed coordinate of the start patch to setxy random-pxcor random-pycor so their initial location is randomised which will make for a better avg. in the denominator of the corridor width equation.

Emi OB
  • 2,814
  • 3
  • 13
  • 29
LAURA
  • 1