如何将海龟分为祖先/后代?或“向左”/“向右”

时间:2021-01-09 14:21:46

I'm using Netlogo. My model starts from a single cell, and develops into a filament. Ideally, each cell would have a chance of 'dividing', rather than just having the filament grow at the tip. So I'm wondering whether there is a way for each cell to recognize not just its immediate ancestor, but all its ancestors (or its descendants? or all the turtles to its left/right?) and get them to move a patch to make space for the new turtle.

我正在使用Netlogo。我的模型从单个细胞开始,并发展成细丝。理想情况下,每个细胞都有“分裂”的机会,而不仅仅是细丝在尖端生长。所以我想知道每个细胞是否都有一种方法可以识别它的直接祖先,还有它的所有祖先(或它的后代?或者它左/右的所有海龟?)并让它们移动一个补丁来制作新龟的空间。

2 个解决方案

#1


2  

How about giving turtles a lineage as an owned value? Make a global counter and then just add one to that whenever you make a turtle? that way if you have 3 or 300 cells they will each have their own lineage.

如何让乌龟成为一个拥有价值的血统?制作一个全球计数器,然后只要你制作一只乌龟就加一个吧?这样,如果你有3或300个单元格,他们每个都有自己的血统。

If you make a turtle hatch another one, it gives all of it's variables to the new turtle (barring you resetting them like with age or something similar)

如果你让一只龟孵化另一只龟,它会把它的所有变量都给新龟(除非你像年龄或类似的东西一样重置它们)

turtles-own [lineage]
globals [lineage-counter]

   to setup
    create n-of 5 turtles [
       set lineage lineage-counter
       set lineage-counter lineage-counter + 1
    ]
   end

You can use that lineage to have turtles kill non-member of their lineage by using:

您可以使用该血统通过使用以下方式让乌龟杀死其血统中的非成员:

to kill
   set invader one-of turtles here with [lineage != [lineage] of myself]
   if invader != nobody [ask invader [die]]
end

Might want to double check that "lineage != [lineage] of myself" bit just incase. That's always wonky for me.

可能想要仔细检查“自己的血统!= [血统]”这一点。这对我来说总是很不稳定。

Having a new cell move a patch is just as easy as hatching it 1 patch away

有一个新的细胞移动补丁就像孵化1补丁一样容易

to reproduce
  hatch-turtles 1 [setxy ([xcor] of myself + 1) ([ycor] of myself)]
end

#2


2  

Here is a particularly simple approach, but what do you want to do when you hit an edge?

这是一个特别简单的方法,但是当你达到优势时你想做什么?

to setup
  ca
  crt 1 [setxy min-pxcor 0 set heading 90]
end

to go
  ask turtles with [random-float 1 < 0.1] [   
    hatch 1 [
      create-link-from myself [hide-link]
      set heading 90
      ask turtles with [pxcor > [pxcor] of myself] [
        fd 1
      ]
      fd 1
    ]
  ]
end

#1


2  

How about giving turtles a lineage as an owned value? Make a global counter and then just add one to that whenever you make a turtle? that way if you have 3 or 300 cells they will each have their own lineage.

如何让乌龟成为一个拥有价值的血统?制作一个全球计数器,然后只要你制作一只乌龟就加一个吧?这样,如果你有3或300个单元格,他们每个都有自己的血统。

If you make a turtle hatch another one, it gives all of it's variables to the new turtle (barring you resetting them like with age or something similar)

如果你让一只龟孵化另一只龟,它会把它的所有变量都给新龟(除非你像年龄或类似的东西一样重置它们)

turtles-own [lineage]
globals [lineage-counter]

   to setup
    create n-of 5 turtles [
       set lineage lineage-counter
       set lineage-counter lineage-counter + 1
    ]
   end

You can use that lineage to have turtles kill non-member of their lineage by using:

您可以使用该血统通过使用以下方式让乌龟杀死其血统中的非成员:

to kill
   set invader one-of turtles here with [lineage != [lineage] of myself]
   if invader != nobody [ask invader [die]]
end

Might want to double check that "lineage != [lineage] of myself" bit just incase. That's always wonky for me.

可能想要仔细检查“自己的血统!= [血统]”这一点。这对我来说总是很不稳定。

Having a new cell move a patch is just as easy as hatching it 1 patch away

有一个新的细胞移动补丁就像孵化1补丁一样容易

to reproduce
  hatch-turtles 1 [setxy ([xcor] of myself + 1) ([ycor] of myself)]
end

#2


2  

Here is a particularly simple approach, but what do you want to do when you hit an edge?

这是一个特别简单的方法,但是当你达到优势时你想做什么?

to setup
  ca
  crt 1 [setxy min-pxcor 0 set heading 90]
end

to go
  ask turtles with [random-float 1 < 0.1] [   
    hatch 1 [
      create-link-from myself [hide-link]
      set heading 90
      ask turtles with [pxcor > [pxcor] of myself] [
        fd 1
      ]
      fd 1
    ]
  ]
end