【发布时间】:2016-02-05 14:39:30
【问题描述】:
我的代码运行时遇到了这个奇怪的问题。
在我的模型中,我有女性(将女性设为真)和男性(将男性设为真)。
在特定的触发条件下,每个人都会“变成”一个分散器(设置分散器为真)。
分散剂和非分散剂具有非常不同的行为。
我尝试用代表这两个类别的不同品种来解决这个问题,但这也没有奏效。
问题是其中一只乌龟,例如雄性,会在遇到对面的乌龟时进行相应的操作并将分散器设置为“假”。但是另一个不会,并且会继续分散器设置为“真”
我确定这是因为一旦其中一只海龟操作代码,它就不再是“分散器”,因此不再适用于后来海龟的搜索条件,但我尝试过的每一项工作都导致了同样的问题或者没有人出错。
to search-for partner
if male = true [ set potential-mates other turtles with [female = true
and disperser = true]
if female = true [ set potential-mates other turtles with [male = true
and disperser = true]
let chosen-mate min-one-of potential-mates [distance myself]
if any? potential-mates [
set heading towards chosen-mate]
if male = true [ if any? other turtles-here with [female = true and
disperser = true] [set disperser false]
if female = true [ if any? other turtles-here with [male = true and
disperser = true] [set disperser false]
end
【问题讨论】:
标签: netlogo