Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetLogo - finding patch with max value

Tags:

netlogo

I'm trying to have female animal agents select all patches that have no females within a certain radius. Then, from among those patches, I'd like the female to move to the one which has the highest average prey within the same radius. I currently have:

  let potential-sites patches with [not any? patches in-radius 2 with [owner-fem != nobody]]
  let pot-site-areas [patches in-radius 2] of potential-sites
  let pot-site-prey map [mean [prey] of ?] pot-site-areas
  let ideal-site max pot-site-prey

But then I realize that I have no way to tell the female which patch to go to, because ideal-site is just a value with no patch coordinates associated with it. Any suggestions on how to link the value to the actual patch? Many thanks!

like image 790
user2359494 Avatar asked Jul 15 '26 15:07

user2359494


1 Answers

Use max-one-of, perhaps like this:

let ideal-site max-one-of potential-sites [mean [prey] of patches in-radius 2]
like image 60
Alan Avatar answered Jul 21 '26 15:07

Alan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!