0
我的代码正在出现这个奇怪的问题。同时运行“相似”代码的两只海龟
在我的模特中,我有女性(设置女性为true)和男性(设为男性为true)。
在特定的触发器上,每个'将成为'分散器(设置分散器真)。
分散器和非分散器有非常不同的行为。
我试着解决这个代表两个类的不同品种,但这也没有奏效。
问题是,其中一只乌龟例如男性,将会相应地操作,并在遇到对面的乌龟时将分散器设置为“假”。但其他不会,并将继续与分散器设置'真'
我确定这是因为一旦海龟操作代码,它不再是'分散器',因此不再适用于搜索条件之后的乌龟,但是周围的所有工作尝试都导致了相同的问题或者没有人犯错。
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
欢呼声,完美的作品 –