How to move to another agent with the highest value?

28 views Asked by At

my agents set trade_Price than when they trade and they save their profit to their payoff variable. in ai process I have to code that my agents have to look around and choose the neighbor agent with the highest payoff. and than the agent has to give his decision value to this agent. I asked it before and got this code:

ask buyers [
     let current-buyer self
     ask sellers [
     let current-seller self
     let how-much 1
     set decision ;some number
     ask current-buyer [
     set decision ;some number
 ]]]

but got something else what i wanted. Than I code it myself so:

ask sellers 
        [ let partner one-of buyers-here if partner != nobody 
        [ move-to one-of partner  with-max [decision] of buyers]]

But there are also mistakes, could you give a tip or at least which code is the right way?

1

There are 1 answers

1
Alan On

Revised in response to comment:

ask sellers [
  let candidates (buyers-on neighbors)
  ifelse any? candidates [
    let partner one-of (candidates with-max [decision])
    move-to partner
  ][
    die ;; or whatever you want to do in this case
  ]
]