Master
Master

Reputation: 1

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

Upvotes: 0

Views: 53

Answers (2)

TurtleZero
TurtleZero

Reputation: 1064

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.

Upvotes: 0

Matteo
Matteo

Reputation: 2926

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.

Upvotes: 1

Related Questions