简体   繁体   中英

Introducing IDs to patches in Netlogo

I am working on a model which is supposed to act like a human tissue. It is composed of only patches which represent the human cells. The cells replicate over time, and I want to introduce unique IDs to each of the individual patches (cells). These IDs should also carry over to the daughter cells after the replication. I cannot seem to find a good starting point for this and not sure how to approach it.

This is the code I tried but it is not working to even at least give each patch a unique ID. Track clones is supposed to give each of the patches an ID and I will later introduce more to the code to track individual patches and their division over time.

to track-clones

;  let patch-list patches
;  let patch-count count patches
;  foreach patch-list [
;    set id ?1
; ]
end

This will have each patch take unique and sequential IDs:

to assign-ids
  ask patches [
    set id (max [id] of patches + 1)
  ]
end

That said, it is not clear to me what you mean, in model's terms, when you say

These IDs should also carry over to the daughter cells after the replication.

given that we don't know how such replication is supposed to take place - but it seems this is a separate issue to address.

PS: the syntax using ? for anonymous procedures is no longer accepted, make sure to check the latest NetLogo Dictionary .

You can quickly assign an initial ID based on the patch coordinates

Ask patches [ set patch-id (pxcor - min-pxcor ) + (pycor - min-pxcor) * world-width ]

Alternately, you can use the patch itself as the patch ID:

Ask patches [ set patch-id self ]

This might make other operations relating to the progenitor patch simpler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM