netlogo - 要求一个代理集从另一个代理集获取值

标签 netlogo agents

我的卖家使用以下代码设置 trade_Price:

ask buyers  [ ask sellers [if any? buyers-here [ if seller_Price <= [buyer_Price] of myself 
       [ set trade_Price  seller_Price + random ([buyer_Price] of myself - seller_Price) ]]]] 

我希望我的买家也采取相同的交易价格,如果他们在同一补丁中有卖家的话。(如果有的话?卖家 - 这里)。我这样编码:

ask sellers [ ask buyers [if any? sellers-here [set trade_Price ( [trade_Price] of myself )]]]

我认为它的代码是错误的,因为我从我的代理夫妇那里得到了不同的 trade_Price 。 你知道我该如何设置它吗? 最好的成绩

最佳答案

据我所知,您正在尝试这样的事情:

ask buyers [
  let candidate one-of sellers-here
  if candidate != nobody [
    set trade_Price [trade_Price] of candidate
  ]
]

请注意,对此没有询问卖家。您只希望每个买家每次通过 go 运行一次。

请注意,如果补丁上有多个卖家,one-of sellers-here 会随机选择一个。

关于netlogo - 要求一个代理集从另一个代理集获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27505596/

相关文章:

Netlogo 链接品种

colors - 根据 pcolor 更改颜色 - NetLogo

NetLogo - 行为空间 - 控制变量值

agents-jade - 智能代理如何接受组织结构并塑造他们的整个范式?

Clojure 代理问题 - 使用发送

c++ - 异步代理库和数据共享

logging - 如何使用代理和 core.async 在 Clojure 中正确异步登录?

python - 基于代理的模拟 : performance issue: Python vs NetLogo & Repast

netlogo - 在这段代码的界面中使用列表时,如何避免 "expected 2 inputs"?