1

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.

tcdejong
  • 88
  • 6

1 Answers1

2

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)).

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Charles
  • 3,888
  • 11
  • 13
  • Thanks! Confirming it _should_ be possible was all I needed, so it made me dive into it again. I changed setup procedures in the meantime, so the `(turtle-set partner myself)` thing doesn't apply anymore. Using `ask patches [ set houseHold turtles-here ]` works. The new way also lets me ask all patches at once instead of many iterations of single commands. Cheers! – tcdejong Jan 19 '20 at 09:03