在我的NetLogo世界表面上,我想计算粉红色斑块上的海龟数量 . 接下来,我想要包括复制过程 . 更具体地说 I want to multiply number of turtles on these patches by number of offspring per turtle (3) and thus create new turtles. 后代应该具有父母的品质 .
步骤:1 . 在粉红色斑块上创建100只乌龟(父母)2 . 确定每个粉红色斑块的海龟数量(我希望将此模型纳入更大的模型)并将其乘以3 - > 100个父母有300个后代3.让父母死,只留下后代4.每粉红色补丁产生的龟数:300
似乎使用 sprout
足以在每个粉红色斑块上 生产环境 海龟 . 但是我不明白我怎样才能包含这个后代的创作?我知道我可以计算每个补丁的数量
用[pcolor = pink]显示[计数海龟 - 这里]补丁
但如何将这些信息包含在我的新龟(后代)创作中?以及如何“复制”父母的品质? (红色?)
我试图纳入这里发表的答案,但没有成功:Sprouting turtles in NetLogo based on patch value
非常感谢,这是我的代码:
to setup
clear-all
setup-patches
setup-turtles
reset-ticks
end
; create diverse landscape
to setup-patches
ask n-of 5 patches [ set pcolor pink ]
end
; create turtles on pink patches
to setup-turtles
ask patches with [pcolor = pink] [sprout 100 [ set color red ]]
; ask patches with [pcolor = pink] [count turtles-here]
; show [count turtles-here] of patches with [pcolor = pink] ; calculate number of turtles on every pink patch
let patch-list [count turtles-here] of patches with [pcolor = pink]
let i 0
foreach patch-list [
ask ? [
sprout item i patch-list
set plabel count turtles-here
]
set i i + 1
]
reset-ticks
end
2 回答
您正在寻找的原语是hatch . 如果
ask
是后代的父亲,它会自动复制后代中所有父母的属性:轻松解决方案,融入
进入我的简单公式: