2017-02-08 41 views
0

我想在两种不同颜色的龟重叠之后孵化龟。基于其他龟色指定颜色的孵化龟

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语法的提示可能会被赞赏。

回答

1

这可能不是你正在寻找的东西,但是如果父母是他们生下的唯一那个补丁,那么这块应该可以做到。

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 
    ] 

end