Netlogo如何在gi程序中重复一个程序

时间:2014-12-14 21:37:00

标签: process netlogo

这是我的匹配程序,它在SETUP过程中运行。这个程序意味着我的代理商 - 卖家和买家相遇。但我添加了名为“oneShot”的开关。当“oneShot”为真时,我的“匹配”必须在Go过程中运行。 我的代码看起来像这样:

to matching     

  ask sellers [ move-to one-of patches with [not any? turtles-here]]

  ask buyers  [ move-to one-of patches with [not any? buyers-here]]

  ask buyers  [ if any? sellers-here     [set shape "face happy"]
                if not any? sellers-here [set shape "face sad"]
                if any? sellers-here [set size 0.5]]

  ask sellers [ if any? buyers-here      [set shape "face happy"]
                if not any? buyers-here  [set shape "face sad"]
                if any? buyers-here [set size 0.5]]    

  ask patches with [count turtles-here = 2]
                   [ask one-of turtles-here [fd 0.15 
                    ask one-of other turtles-here [face myself fd -0.15]]]


end

我应该在这里添加什么?

1 个答案:

答案 0 :(得分:1)

ask sellers [
  let candidate one-of patches with [not any? turtles-here]
  ifelse (candidate != nobody) [
    move-to candidate
  ][
    die   ;;or whatever you want to do when there are no empty patches
  ] 
]