Lecture: 12-06-2012

posted Dec 6, 2012, 9:29 AM by Samuel Konstantinovich   [ updated Dec 6, 2012, 12:50 PM ]

Do Now:

1. When should you use square brackets? List all commands that require or have optional brackets.

Do Now:

1. When should you use square brackets? List all commands that require or have optional brackets.

-repeating commands

repeat n [command]


-conditionals

if boolean

[commands]


ifelse boolean

[commands]

[commands]


-commands that use agent sets:

agentset with [ boolean ]

ask agentset [ commands ]


-Commands that Make turtles:

hatch n [ commands ]

create-ordered-turtles n [ commands ]

create-turtles n [commands]



-Commands that have lists of variables :

globals [ … ]

turtles-own [ …]

patches-own [ … ]


-when you declare a function it has an optional list of parameters in brackets

to functionName [ … ]

…...

end

 


2. When should you use parenthesis? Give at least one example where you need it.

You only need parenthesis to change order of operations, or make things easier to read. You also need it to signify that you want to negate a single expression instead of subtracting it from another value.


NETLOGO PRACTICE:

Add to your model:

Make the people display the number of children they had.

Make the cars display the number of accidents they had.


Make the cars with more than 10 accidents turn to size 3.

Make the people with more than 8 children turn size 4

(THEIR CHILDREN SHOULD NOT BE SIZE 4)


Big people cannot die anymore.  

Comments