netlogo turtles与其值的错误

时间:2014-12-12 17:30:29

标签: netlogo turtle-graphics

我有两个代理商:买家和卖家。买家自己买家_Price和卖家拥有卖家_Price。当卖家价格<=买方 - 价格交易发生时。我这样编码:

ask turtles [ if seller_Price <= buyer_Price [deal]]

但我变成了这个错误:

SELLERS breed does not own variable BUYER_PRICE
error while seller 34 running BUYER_PRICE
  called by procedure INTERACTION
  called by procedure GO
  called by Button 'STEP'

即使我将ask turtles更改为ask buyyersask sellers

也是如此

任何人都可以提供一些关于我的错误的提示,我应该改变什么?

1 个答案:

答案 0 :(得分:2)

正如布莱恩所说,你可能想要选择一个潜在的买家和潜在的卖家(因此卖家不会用完商品等)。但是,如果您真的希望所有买家以合适的价格从所有卖家购买,您需要使用“我自己”的代码来访问提问者的变量。代码看起来像这样。

breed [buyers buyer]
buyers-own
[ buyer_Price ]

breed [sellers seller]
sellers-own
[seller_Price]

to setup
  clear-all
  create-sellers 5 [set seller_Price random-float 1]
  create-buyers 5 [set buyer_Price random-float 1]

  ask buyers
  [ ask sellers
    [ if seller_Price < [buyer_Price] of myself [print myself print self ]
    ]
  ]
end

我刚刚完成了一个print语句,而不是你的交易程序。您可能希望将您的交易程序变成一个只处理两个指定乌龟之间的程序,并将自己和我自己传递给该程序。