Unit 1: What is Complexity

13 thoughts
last posted Oct. 14, 2013, 7:46 p.m.

11 earlier thoughts

0

Netlogo code:

Agents in NetLogo are called "turtles" for historical (Logo) reasons.

You can add buttons to the UI with the GUI.

To create a function:

to <function name="">
...
end

To create a function with a return value:

to-report <function name=""> ... report <return value=""> end

clear-all - clear the world
reset-ticks - ticks back to 0
create-turtles <n> - create n number of agents
tick - increase the tick count by 1


ifelse <condition> [<...>] [<...>] - if condition is true, execute the 1st bracket, otherwise execute the 2nd bracket of code

ask turtles [ <stuff> ]

stuff settings for turtles:
set shape "<shape>"
set size <n>
set color <color>


action settings for turtles:
right <n degrees="">
forward <n steps="">

random <n> - number between 0 and n - 1

Turtles (agents) start in the middle and facing in a random direction.

A button can continue to click itself (such as go) by right clicking it, selecting edit, then clicking the forever checkbox.

The world can have wrapped walls or solid walls. Right click on the world, click edit, then uncheck the wrap horizontal and vertical checkboxes.

Completed Ant1.nlogo exercise.

1 later thought