BehaviourComposer: ignore everything before this.Note that this needs to be a behaviour of the agents being laid out.It works by finding a position in the list of all agents being laid out in this circle and using that to compute the angle from the centre that it is to be moved to.  Begin micro-behaviour: Begin description:Jump to a location on a circle. Many agents can do this and will be spread out along the circle.End description Jump to a location on a circle Begin NetLogo code: substitute-text-area-for radius 8substitute-text-area-for center-x 0substitute-text-area-for center-y 0substitute-text-area-for agents-on-the-circle all-individualslet saved-my-heading my-headinglet those-in-the-circle sort agents-on-the-circleset my-next-heading position self those-in-the-circle * 360 / length those-in-the-circleset my-next-x center-xset my-next-y center-ygo-forward radiusset my-heading saved-my-heading End NetLogo code VariantsTo change the radius of the circle change the last box to another number.To change the centre of the circle change the values of my-next-x and my-next-y.If you want separate circles for different kinds of agents, e.g. "Sheep" then those-in-the-circle to all-of-kind "Sheep" .How this worksThis temporarily sets my-heading to an angle that places each agent 360 divided by the number of agents multiplied by the position of the agent in a list of all agents in the circle. It then moves the radius distance in the computed heading. Finally it restore my-heading to its original value.Related micro-behavioursPlace a set of agents on a circle relies upon the NetLogo layout-circle primitive which is restricted to placing all circles in the centre of the world. Place a set of agents in a rectangular grid places agents to fill a rectangle. Lay out a set of agents where the agents repel each other and the links between them act like springs attempts to find good locations for agents based upon their links with other agents. There are many movement behaviours in the main library. HistoryJump to a location on a circle was implemented by Ken Kahn.BehaviourComposer: ignore everything after this. |