turtles have patches but those patches do not have the turtles
Closed this issue · 1 comments
Where do turtles initially get added to a patch?
Running into issues when I spawn or hatch a turtle and trying to figure out where the disconnect is happening.
Replacing the spawn or hatch with a turtles.createOne() and calling the following:
this.turtles.ask((t) => {
if (!t.patch.turtlesHere().contains(t))
t.patch.turtles.push(t)
})
before attempting to move turtles is a work around:
I just added a fix to Turtles.createOne() which checks to see if patches have the turtles cache (patch.turtles). If so it adds the new turtle to the cache.
The cache is "promoted" within the patches on the first use of patch.turtlesHere() to be space efficient. But any new critters made after that promotion were being left out. Sigh!
I'm thinking of having turtlesHere be a getter that self promotes itself when first used. The turtlesHere() function does that but looking at the NL docs, turtles-here is not called like a function.