请求一个代理集从另一个代理集中获取值

时间:2014-12-16 13:19:19

标签: 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。 你有什么想法我怎么设置它? 最好的反思

1 个答案:

答案 0 :(得分:1)

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

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

请注意,此处没有ask sellers。您只希望每个买家每次都通过go运行一次。

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

相关问题