Search code examples
netlogobehaviorspace

report a variable from all patches in behavior space netlogo


I have a model in NetLogo that simulates insects(turtles) herbivory on plants (patches). Each patch has a variable called resources that is depleted every time a turtle visits it. I would like to report the resources of each patch and the patch coordinates when running my model through behavior space.

So far I have:

to-report damageToPatches
  foreach sort patches [ ask patches [
    report resources ]]
end 

Which obviously doesn't work, this might be pretty simple but I am struggling to come up with a solution. Might it involve adding the resource value of each patch to list at every time step?


Solution

  • If I just make the smallest modification to your code to make it operational, we get:

    to-report damage-to-patches
      report [resources] of patches
    end
    

    But you said you want to include the patch coordinates too, so that'd be:

    to-report damage-to-patches
      report [(list pxcor pycor resources)] of patches
    end
    

    of gives results in random order, though. If you want the list in left-to-right, top-to-bottom order, then that's:

    to-report damage-to-patches
      report map [[(list pxcor pycor resources)] of ?] sort patches
    end