Netlogo:foreach命令用于在每个项目中具有多个参数的列表

问题描述

我正在尝试遍历称为max-links的链接列表(这意味着每个项目都有两个参数),我已经通过以下代码实现了这一点:

    ask item counter max-links
     [
       ask end1 [ask my-out-links with [not member? self keep] [die]]
       ask end2 [ask my-in-links with [not member? self keep2] [die]]
       set counter counter + 1
     ]

但是我试图用foreach命令编写它,并且我认为它同时在所有end1和end2上执行。我希望函数在界面上按它的按钮时一次遍历每个项目。 这是我用foreach命令编写的代码

  foreach max-links
  [
    [a] ->
    [
      ask [end1] of a [ask my-out-links with [not member? self keep] [die]]
      ask [end2] of a [ask my-in-links with [not member? self keep2] [die]]
    set max-links-update sort-on [(- label)] link-set [max-one-of my-out-links [label]] of turtles
    show max-links-update
    ]
  ]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)