Codes for Bugs' Meeting
1. Solution with four turtles
to main cs st bugs 200 end to bugs :size pu setxy -:size/2 -:size/2 pd square :size pu setpos list -:size/2 -:size/2 pd setturtle 1 pu setpos list -:size/2 :size/2 pd setturtle 2 pu setpos list :size/2 :size/2 pd setturtle 3 pu setpos list :size/2 -:size/2 pd trajectory end to trajectory if ( xcor*xcor+ycor*ycor)<1 [stop] repeat 4[setturtle remainder repcount 4 make "a pos setturtle repcount-1 seth towards :a fd 2] trajectory end to square :size repeat 4 [fd :size rt 90] end
2. General solution with "thing" operation
to main cs ht bugs 6 100 end to bugs :n :d draw.poligon :n :d draw.trajectory :n :d end to draw.poligon :n :d pu for [i 0 :n-1] [fd :d make :i pos bk :d rt 360/:n] setpos thing 0 pd for [i 0 :n-1] [setpos next :i] end to draw.trajectory :n :d if (distance [0 0])<2 [stop] for [i 0 :n-1][pu setpos thing :i seth towards next :i pd fd 1 make :i pos] draw.trajectory :n :d end to next :i op (thing remainder :i+1 :n) end