我的卖家使用以下代码设置 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/