Libraries‎ > ‎Library‎ > ‎Copying‎ > ‎

Create agents from data

BehaviourComposer: ignore everything before this.
Begin micro-behaviour
Begin description:
Create additional agents initialising them using data followed by the specified prototype's initialisation.
End description

Create agents from data

Begin NetLogo code:
substitute-text-area-for kind-of-agents-to-add Prototype1
substitute-text-area-for attributes my-id xcor ycor "" my-age my-name color
substitute-text-area-for initialisation-data "007" 5 5 "ignored column" 32 "James Bond" blue "Number six" -5 -5 "junk" 39 "Unknown" red 
create-agents-from-data 
              "kind-of-agents-to-add"
              [attributes]
              [initialisation-data]
              list-of-micro-behaviours "Additional Behaviours" []
End NetLogo code

Usage tips

The data can be copy and pasted directly from Excel or Google Spreadsheets (and probably many more) or from a tab separated file. The process of creating these agents is a little faster if unwanted columns are removed but you can use "" for the attribute name to skip columns.

Variants

You can edit the text areas to change the  the kind of agent, its attributes or the data.  If an attribute is "" then that 'column' of data will be ignored. You can add additional behaviours to the newly created agents. 

Related behaviours

 Add copies andAdd copies of anothercreate exact copies of an agent as it currently is. Create agents makes any number of agents without initialising them from data.

When used in a 3D model the 3D world declaration must be above or to the left of this micro-behaviour.

How this works

The creates new agents with the behaviours listed in the named prototype plus any additional specified behaviours. It relies upon the create-agents-from-data command.

History

Create agents from data was implemented by Ken Kahn on 28 February 2014. 

BehaviourComposer: ignore everything after this.
Comments