我想在两种不同颜色的乌龟重叠后孵化出一只乌龟。
to interact
if any? other turtles-here
[
birth
]
;detect interaction
end
to birth
ask turtles
[
hatch random 5 [ fd 1 ]
]
end我想孵化出一只乌龟,它是两只相互作用的乌龟父母的平均颜色。
就像这样。
to birth
ask turtles
[ hatch random 5
[ let color be sum of previous turtles color sum / 2
fd 1 ] ]
end另外,任何关于我对netlogo语法的误解的提示都可能会被感谢。
发布于 2017-02-09 10:04:59
这可能不是你想要的,但是如果父母是他们分娩时唯一在补丁上的人,那么这个区块应该可以做到这一点。
to birth
let Q mean [color] of turtles-here
ask one-of turtles-here
[hatch random 5
[
set color Q
fd 1
]
]
end我不确定你是否需要让后代成为自己的品种,告诉他们改变颜色和移动,或者这样做是否可行……如果这不起作用,那么:
breed[offsprings offspring]
breed[parents parent]
to birth
let Q mean [color] of parents-here
ask one-of parents-here
[hatch-offsprings random 5 ]
ask offsprings-here
[
set color Q
fd 1
]
endhttps://stackoverflow.com/questions/42124671
复制相似问题