我想在Netlogo中编写细胞分裂的程序。我设法对它进行了编程,使细胞以一定的概率分裂。这产生了一个特定的随机函数,我不会用它来打扰你。
然而,为了让它尽可能真实,我不希望多个细胞在同一个补丁上。我设法编程,让一些细胞死亡,如果他们找不到附近的补丁是空的。但这会影响随机函数,因为死亡的细胞比预期的要多。
如果能得到一些帮助,我们将不胜感激。
我要澄清的代码如下:
to mitosis
ask stemcells [
if random-float (2 * r * lambda) < 2 * r * lambda [
ifelse random-float 1. < probability
[ hatch 1 [
let free-neighbor one-of neighbors with [not any? turtles-here]
ifelse free-neighbor != nobody [
move-to free-neighbor]
[ die] ]
set breed stemcells
] [ die ] ] ]发布于 2016-08-08 21:15:15
看起来你的问题是在一开始你有:
if random-float (2 * r * lambda) < 2 * r * lambda因为任意数字x的随机浮点数总是报告一个从0到x的数字。
这将使random-float (x) < x始终是一个正确的语句。
发布于 2016-08-09 21:26:04
按照我遵循代码逻辑的方式,您将根据“概率”询问每个词干单元是否想要除法。
孵化代码看起来不错,我把它拿出来,它正确地测试了:要么找到一个邻居补丁,要么死掉。
但是如果你的干细胞决定不分裂,在我看来,它会进入第二个死因。这就是你的问题所在:“因为死亡的细胞比预期的要多”?
此外,不需要"set breed“,因为ask中的孵化将始终创建breed。
从你最近的评论中添加了以下内容:
“如果可能的话,我希望他们移动并为带阴影的单元格让路”……除了你的代码作用在幼体上,所以实际上,是新孵化的stemcell在移动,而不是原始的。如果这很重要的话。
我测试了整行代码,而不仅仅是拉出过度拥挤的部分,看看这是否有帮助。您将需要按钮来设置、有丝分裂和一个输出窗口来查看消息。我在代码中的注释包括原始回答者对if语句的原始发现。
breed [stemcells stemcell]
globals [
r
lambda
probability
]
to setup
clear-all
set r 0.5544
set lambda 1.233
set probability .85
create-stemcells 1
end
to mitosis
ask stemcells [
if random-float (2 * r * lambda) < 2 * r * lambda [ ;; this is superfluous, always true
ifelse random-float 1. < probability [
hatch 1 [
let free-neighbor one-of neighbors with [not any? turtles-here]
ifelse free-neighbor != nobody [
move-to free-neighbor
]
[; this die is executed if there is no free space in the neighborhood
output-show " Dead because of no free space in neighborhood"
die
]
]
;set breed stemcells ;; not necessary in an ask of stemcells
]
[;this die is executed if probablity compares to random-float and the hatch is not done
output-show " Dead because did not hatch"
die
]
]
]
ehttps://stackoverflow.com/questions/38823108
复制相似问题