Moving turtles towards another breed without overlap

164 views
Skip to first unread message

Didier Clement

unread,
May 25, 2022, 10:59:25 AM5/25/22
to netlogo-users
I have 2 breeds of turtles:
- One (supplier) is fixed and represented as squares.  
- the other (customer) choose their supplier and move near it without overlap

My code:
ask customers
  move-to supplier                                    
  while [ any? other customers-here ] [ forward 1 ] 

I get a nice spread in circle around each square (see picture attached) but:
- the customers are not filling up all the nearest space to their supplier 
- If there are too many customers (1,000+) , the code run forever

What can I do to make sure that the placement end (even if few customers overlap) and all the customers are closely near their supplier (more than now)?

Thank you 
Screenshot 2022-05-25 at 10.09.00.png

Pradeesh Kumar K V

unread,
May 26, 2022, 2:36:20 AM5/26/22
to netlogo-users
Hi,

This could be due to the use of 'customers-here' which essentially ensures that a patch can contain only one customer. In order to have a tighter distribution of customers, you can use 'in-radius' in place of 'customers-here'. In this case, customers are arranged based on their distance from each other. A suggested modified code is given below:

ask customers
  move-to supplier                                    
  while [ any? other customers in-radius 0.5 ] [ rt random 90 forward 0.5 ] 

Best,

Pradeesh

--
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/ac0e2368-eec8-4571-9ec6-66d636160b90n%40googlegroups.com.

James Steiner

unread,
May 26, 2022, 2:51:09 PM5/26/22
to Didier Clement, netlogo-users
Many options to place turtles around an “attractor” here’s two. 

A

make the customers gently repulsed by each other, and gently attracted to a point a few degrees away supplier.  Initially, place the customer next to the supplier. Each tick, all the customers do three things: 1 look for amother customer of that supplier that is too close. 2. If there is one, take a small step directly away from the customer.  2. If there is one, also Take a small step toward and slightly to the left of the supplier.  Customer will promenade around the supplier. 



B (most deterministic, fastest)

Decide that there are a certain number of “spaces” in each ring around the supplier, with more spaces in the rings as distance form the supplier increases.  Perhaps ((int distance supplier) * 2 * pi /  ( size * 2)) 

come up with a pair of formulas that calculates the correct distance and angle to place the Nth turtle to arrive at the supplier in the A(n) slot of the D(n) ring.  I bet somebody out there figured this out already.  Or just keep count. Like suppliers-own Num-customers, Ring#, RingHeading Initialize Ring#  to 1 and RingSlice to (Ring# * 2 * pi ) / (size * 2)  and RingHeading to 0
When a customer arrives do
Set heading [ ringangle ] of supplier
Jump [ ring# ] of supplier
Ask supplier
[ Set ringangle ringangle + ringslice
If ringangle >= 360 [ set ringangle 0 set ring# ring# + 1]
]


--

James Steiner

unread,
May 26, 2022, 10:41:11 PM5/26/22
to Didier Clement, netlogo-users
---RingSlice is wrong / incomplete. It's supposed to be 360 * (( size * 2)  /  ring-circumference)

Didier Clement

unread,
Jul 18, 2022, 11:52:44 AM7/18/22
to netlogo-users
Thank you for your help
I have now built a model to arrange turtles around a given point ordered by colour.
Basically, working from an ordered list,
- calculate the number of turtle on the initial circle (closest to the point) and degree step to set them all in on circle
- place the turtles using xcor = x + radius * cos(degree) ycor = y + radius * sin(degree),  x y being initial point
- Once the circle is complete (360 degree), expand the radius for the next circle and repeat
I have attached a rough model that allows you to varies some of the parameters for best visual effect.

Hope it helps
circleArrange.nlogo
Reply all
Reply to author
Forward
0 new messages