When you ask a set of agents to run more than one command, each agent must finish all the commands in the block before the next agent starts. ] show of end1 ) - ( of end2 )] of links check everything’s OK 8. agentset satisfies a certain condition ask turtles and with same color as me. if all? turtles use all? to see if every agent in the Use member? to see if an agent is a member of an agentset. Check whether two agentsets are equal using = or != show member? ( turtle 0 ) turtles with-min Use turtle-set, patch-set and link-set reporters to make new agentsets by gathering together agents from a variety of sources show ( turtles with ) = ( turtles with ) show ( turtle-set turtle 0 turtle 2 turtle 9 turtles-here ) Use of to make a list of values, one for each agent in the agentset. max-one-of agentset reports an agent in the agentset that has the highest value for the given reporter show mean ( of turtles with ) ![]() one-of reports a random agent from an agentset ask ( max-one-of turtles ) You can make a list by simply putting the values you want in the list between brackets, e.g.: Each value in the list can be any type of value: a number, a string, an agent, an agentset, or even another list. Lists let you store multiple pieces of information in a single variable by collecting those pieces of information in a list. In the simplest models, each variable holds only one piece of information, usually a number or a string. to ask the patch to her east set pcolor red. ] ask turtle 0 [ ask the turtle with who number 0 ask patch-at 1 0 [. ] ask link 0 2 [ ask the link between turtle 0 and 2. ] ask turtle 0 [ ask the first turtle (with who number 0) create-link-to turtle 2 to link to turtle with who number 2 ] ask patch 2 -2 [ ask the patch at (2,-2). The following code is an example of the implementation of procedure to setup:Ĭlear-all clear the world create-turtles 3 make 3 turtles ask turtle 0 tell the first one to go forward 10 steps ask turtle 1 [ ask the second turtle (with who number 1) set color green. Once you define a procedure, you can use it elsewhere in your program. The NetLogo Dictionary has a complete list of built-in instructions (i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |