Netlogo: Store agentset in patch property

207 Views Asked by At

I am simulating a neighborhood. Patches represent households, turtles people living there. I want to track "households" and thought it would be convenient to store an agentset of each household at the patch. That would allow me to do easy "household behavior", like ensuring regular groceries.

However, ask homePatch [ set houseHold (turtle-set partner myself) ] just stores 0 in the patch variable.

Is it possible to save agentsets in the patch variable? It is defined in patches-own.

1

There are 1 best solutions below

1
Charles On BEST ANSWER

It is possible for a patch variable to hold an agent set, as shown in the following example.

patches-own [ household ]

to test
  clear-all
  ask patches [set household nobody]
  create-turtles 100 [
    fd random 10
    if any? other turtles-here [
      let partner one-of other turtles-here
      ask patch-here [set household (turtle-set partner myself)]
    ]
  ]
  ask patches with [household != nobody] [show household]
end

To know why is seems not to be working for you, we'd need to see more of your code, since the line you provide does work. (Note that if the turtle who is "myself" is sitting on the patch homePatch, it can set the homePatch variable directly with set household (turtle-set partner self)).