Netlogo, Finding the next closest agent if another agent is locked on to the same agent

220 views
Skip to first unread message

Imantha Gunasekera

unread,
May 23, 2019, 4:22:23 AM5/23/19
to netlogo-users
Hi Guys,
I have a problem I wish to solve. Lets say there are two type of agents (rabbits and hunters). I want the hunters to find the closest rabbit to them. But if two hunters are find the same rabbit  (i.e the closest rabbit to hunter 103 and hunter 105 is rabbit 103). I want one of the hunters to find the next closest rabbit. Any ideas how to solve this. Thanks

breed[hunters hunter]
breed
[rabbits rabbit]

hunters-own [rab-in-sight]

to setup
  clear-all
  create-hunters 20
  create-rabbits 100
  
  ask hunters [
  set color red
  setxy random-xcor random-ycor
  ]
  ask rabbits [
    set color white
    setxy random-xcor random-ycor
  ]
  
end

to connect
  ask hunters [
    set rab-in-sight min-one-of rabbits in-radius 5 [distance myself]
  ]
    
end



Simon Bush

unread,
May 23, 2019, 7:19:18 AM5/23/19
to Imantha Gunasekera, netlogo-users
You could give the rabbits an own variable called in-sight.  If a hunter selects that rabbit and it’s zero it is set to 1.  You can then modify you statement below to say min-one-of rabbits with [in-sight = 0].  Each round in-sight for rabbits will be set to zero.

Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/474a16b9-5656-4b20-93c0-1fae7ad0372f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages