以下代码:是否使用同步或异步更新(set语句)(事件安排)。
globals [larger smaller]
turtles-own [num]
to test
create-turtles 50
[ setxy random-xcor random-ycor
set num random 100
]
ask turtles
[ let nearest-turtle min-one-of other turtles [ distance myself ]
let closed-agent-num [num] of nearest-turtle
ifelse [num] of nearest-turtle > num
[ set larger nearest-turtle
set smaller self ]
[ set smaller nearest-turtle
set larger self]
ifelse random 100 < [num] of larger - [num] of smaller
[ ask smaller [ set heading [heading] of larger] ]
[ ask larger [ set heading [heading] of smaller] ]
]
end