我想对分支过程进行简单的模拟。我有两种类型的细胞,SC和CM。
SC - > SC + SC,概率为p1
SC - > SC + CM,概率为p2
SC - > CM + CM,概率为p3
SC - >死,概率为p4
CM - > CM + CM,概率为p5
CM - >死。概率为p6
到目前为止,我已经设法创建了两种类型的品种,并使用设置按钮命令设置初始概率。
breed [SCs SC]
breed [CMs CM]
SCs-own [p1 p2 p3 p4]
CMs-own [p5 p6]
to setup
clear-all
set-default-shape SCs "circle"
set-default-shape CMs "circle"
create-SCs 50
create-CMs 50
ask SCs [ setxy random-xcor random-ycor
set color red
set p1 0.15 ;; 2 SC
set p2 0.15 ;; SC + CM
set p3 0.4 ;; CM + CM
set p4 0.15 ;; die
set size 1
]
ask CMs [ setxy random-xcor random-ycor
set color blue
set p5 0.3 ;; CM + CM
set p6 0.7 ;; die
set size 1
]
reset-ticks
end
然后使用move-all和reproduce过程创建go命令按钮
to go
move-all
reproduce
tick
end
这是move-all程序
to move-all
ask turtles [
right random 90
left random 30
forward 1
]
end
现在,问题在于重现命令。我想要求CM孵化但是基于SC的属性(如p2和p3)。我在标记命令时遇到运行时错误。这是代码
to reproduce
ask SCs [
if random-float 1 < p1 [
hatch 1
]
if random-float 1 < p4 [
die
]
]
ask CMs [
if random-float 1 < p5 [
hatch 1
]
if random-float 1 < p6 [
die
]
;runtime error with this block
;p2 and p3 belong to SC, but I want to hatch 1 CM and 2 CM
;if random-float 1 < p2 [
; hatch 1
;]
;if random-float 1 < p3 [
; hatch 2
;]
]
end
任何人都可以帮我解决这个问题吗?如何用p2和p3模拟过程?我相信大多数经验丰富的Netlogo用户都知道如何处理这个问题。谢谢......