同步或异步

时间:2016-02-19 07:44:50

标签: netlogo

以下代码:是否使用同步或异步更新(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

1 个答案:

答案 0 :(得分:2)

NetLogo中的所有内容都是同步的。没有“事件安排”的概念。见What is the sequence of Netlogo execution?