Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Is there a way to exclude the previous patch a turtle was on from its neighborhood?

69 views
Skip to first unread message

Victoria Haskins

unread,
Feb 24, 2025, 9:04:17 AMFeb 24
to netlogo-users
I'm trying to make my turtles build roads. I want them to turn the patch they're on grey and die if they're on a grey patch or if any of their neighbors4 are grey (because this means they have already connected to the larger road network). 

However, if I just use neighbors4, then the turtle will die as soon as it moves forward once because the patch it was just on is now grey. 

I feel like I've tried absolutely everything. 

ask turtles [
let adjacent-patches neighbors4 
if any? adjacent-patches with [ pcolor = grey ]
[ die ]

fd 1
]
--> results in the turtle dying after moving forward once because the patch it just moved from is part of neighbors4

I've done let adjacent-patches neighbors4 with [ self != previous-patch ]
--> I can't use previous-patch in a patch context, because it's turtles only (even though it's in ask turtles
 let adjacent-patches neighbors4 with [ not member? self previous-patch ] --> also doesn't work

Jacob Kelter

unread,
Feb 25, 2025, 10:49:27 PMFeb 25
to Victoria Haskins, netlogo-users
Where is previous-patch defined? If it is a turtle variable, then you would need:

let adjacent-patches neighbors4 with [ self != [previous-patch] of myself ]

That should work because myself refers to the asking turtle. 

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/netlogo-users/4958b3d8-e162-4c07-a2ea-34446faba028n%40googlegroups.com.


--

S Nezhadi

unread,
Feb 26, 2025, 12:49:16 PMFeb 26
to Jacob Kelter, Victoria Haskins, netlogo-users

Ensuring Proper Pairing of Patch Variables When Calculating Correlation in NetLogo

Dear NetLogo Users,

I am currently working on a spatial model in NetLogo where I need to compute the correlation between crop-land (CL) profit and CL pest density at the patch level. However, I want to ensure that each profit value is correctly matched to the corresponding pest density from the same patch before performing the correlation calculation.

  I want to verify that the NetLogo list extraction process maintains the correct pairing of profit and pest density for each patch.

Questions:

  1. Does NetLogo maintain the same order when extracting multiple variables from an agentset using map and sort?
  2. Is there a better way to ensure the correct alignment between profits and pest densities when working with patch data?
  3. Would it be more reliable to store these values as patch variables first and access them directly later instead of using lists?
  4. Are there known issues where sorting patches causes misalignment between extracted values in separate lists?

Any guidance, suggestions, or best practices to ensure the correct pairing of profit and pest values per patch before calculating correlation would be greatly appreciated!

Thank you!

Best regards,

Sogol 


Jacob Kelter

unread,
Feb 26, 2025, 12:51:46 PMFeb 26
to S Nezhadi, Victoria Haskins, netlogo-users
Without knowing anything else about your model I would recommend storing these values as patch variables. Then you can calculate correlation with something like:
[correlation-function profit pest-density] of patches
--

Victoria Haskins

unread,
Mar 3, 2025, 1:36:49 PMMar 3
to netlogo-users
Thanks, this worked!

Aaron Andre Brandes

unread,
Mar 3, 2025, 2:11:15 PMMar 3
to Victoria Haskins, netlogo-users

Hi,

Although it’s not the best tool for your problem the primitive other is sometimes useful for excluding a turtle or patch from an agentset.

  • Aaron

 

 

-- 

Aaron Brandes, Software Developer

Center for Connected Learning and Computer-Based Modeling

 

 

--

You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to


To view this discussion visit

Reply all
Reply to author
Forward
0 new messages