如何联系代理人的行为? [英] How to link actions of agents?

查看:67
本文介绍了如何联系代理人的行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用3组代理-A,B,C对仿真进行编程. 关键是,集合A中的代理可以选择执行操作或不执行操作. 如果他们决定不执行该操作,则模拟将停止. 当他们决定执行该操作时,仿真将继续进行下一步,在该步骤中,来自集合B的代理也可以决定执行或不执行该操作.这里也是一样. 并且来自集合C的代理也可以决定执行该操作或不执行该操作,但是在此情况下,两种情况下的模拟都停止了. 这是我的代码:

I am trying to program the simulation with 3 sets of agents - A,B,C. The point is that the agents from the set A can choose to DO the action or NOT. If they decide to NOT do the action, the simulation stops. When they decide to DO the action, simulation continues to the next step, where the agents from the set B can also decide to DO the action or not. The same is here. And the agents from the set C, can also decide to DO the action or NOT, but here, the simulation in both cases stops. Here is my code:

ask turttles [
if breed = set A [ ifeslse do?= false [ set lazy]
                                        stop]
[ if breed = set B [ ifelse do1?= false [ set lazy]
                                         stop]
[ask other turtles [ if breed = set C [ ifelse do 2? = false [ set lazy
                                                               stop] ] 
                                       [set done
                                        stop] ]
                                        ]
                                      ]
                                    ]

代码不能很好地工作,我需要某种方式来链接这三个步骤,因为当我导出世界时,我仅从第一步获得数据

The code does not work very good,I need somehing to link these three step, because when I export-world, I got data only from the first step

推荐答案

如果在ask内执行stop,则不会导致整个模拟停止.它只会阻止当前的乌龟执行其余的ask.

If you do stop inside of an ask, it won't cause the whole simulation to stop. It will only stop the current turtle from executing the rest of the ask.

我认为您想要更多类似的东西:

I think you want something more like:

globals [done?]

to setup
  ...
  set done? false
  ...
end

to go
  if done? [ stop ]
  ifelse ...
    [ ask A [ do-action ] ]
    [ set done? true ]
  ifelse ...
    [ ask B [ do-action ] ]
    [ set done? true ]
  ifelse ...
    [ ask C [ do-action ] ]
    [ set done? true ]
  ...
end

但是我有点猜测,因为很难从您的描述中看出您的实际意图. (特别是因为您还没有包含您的真实代码-问题中的男女同伴不会越过编译器.)

But I'm guessing somewhat, since it's difficult to tell from your description what your actual intentions are. (Especially since you haven't included your real code — the coede in your question wouldn't get past the compiler.)

这篇关于如何联系代理人的行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆