2

My sellers set trade_Price with this code:

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) ]]]] 

I want that my buyers also took the same trade_Price if they have a seller in the same patch.(if any? sellers-here). and I code it so:

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

I think its wrong code because I got different trade_Price s from my agent couples. Do you have any idea how can I set it? Best reagrds

runle
  • 149
  • 8

1 Answers1

2

As far as I can tell, you're trying for something like this:

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

Note that there is no ask sellers around this. You only want each buyer to run this once each time through go.

Note that if there are multiple sellers on the patch, one-of sellers-here picks one randomly.

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
  • thank you, it runs:) and I have one more question. in some patches i have "lonely" seller without buyer or lonely buyer without seller. in this case I code it so that their trade_Price is 0. in plot I want to show trade_Price. I code it so : plot mean [trade_Price] of turtles will it calculate the trade_Price which are 0 or? I want that it calculates only trade_Prices which are > 0. how can I code it in plot ? – runle Dec 16 '14 at 19:02
  • If my answer works, then you can thank me by accepting it (using the big checkmark next to it). To ask a new question, open a new question. – Seth Tisue Dec 16 '14 at 19:35
  • I can ask only one question in 90 min :( – runle Dec 16 '14 at 19:54