Download presentation
Presentation is loading. Please wait.
Published byUnique Henthorne Modified over 9 years ago
1
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 1 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 1 PLEASE HAVE NETLOGO INSTALLED -it‘s open source -available for windows, mac and linux -download: GOOGLE „ NETLOGO “ - FIRST LINK – DOWNLOAD - DON ‘ T FORGET TO INSTALL AFTER DOWNLOADING ( TAKES 3 MINUTES )
2
N ETLOGO F IRST S TEPS (A RTIFICIAL S OCIETIES ) Gabriel Wurzer Vienna University of Technology gabriel.wurzer@tuwien.ac.at
3
„Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 3 YOU GET WHAT YOU SEE HERE place user interface elements here see the world here type code here
4
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 4 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 4 THE NETLOGO WORLD..is a 3D grid, of which we show only a 2D slice: origin in the middle X+ goes right Y+ goes into screen Z+ goes up (not shown, assuming that z=0)
5
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 5 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 5 THE NETLOGO WORLD grid consists of patches (grid cells) each patch is identified by the coordinate at its center, e.g. patch 0 0 0 at origin
6
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 6 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 6 THE NETLOGO WORLD grid consists of patches (grid cells) each patch is identified by the coordinate at its center, or patch 1 1 0 as shown here
7
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 7 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 7 AGENTS („ TURTLES “) movable entities within NetLogo heading xcor ycor zcor - 0..360 degrees - 0 is north, 90 east, etc. - in grid coordinates - e.g. 0, 0, 0 pitch - 0...360 degrees - 0 is level, 90 up, 270 down roll - 0...360 degrees - rotation of wingtip - 0 is parallel to XY plane
8
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 8 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 8 AGENTS („ TURTLES “) movable entities within NetLogo heading xcor ycor zcor - 0..360 degrees - 0 is north, 90 east, etc. - in grid coordinates - e.g. 0, 0, 0 or 0.5, 0.5, 0 pitch - 0...360 degrees - 0 is level, 90 up, 270 down roll - 0...360 degrees - rotation of wingtip - 0 is parallel to XY plane
9
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 9 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 9 can change their appearence AGENTS („ TURTLES “) shape color size - e.g. „default“
10
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 10 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 10 can change their appearence AGENTS („ TURTLES “) shape color size - e.g. „default“ or „person“
11
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 11 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 11 can change their appearence AGENTS („ TURTLES “) shape color size - e.g. „default“ or „person“ - relative to patch size - 1 is the default
12
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 12 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 12 can change their appearence AGENTS („ TURTLES “) shape color size - e.g. „default“ or „person“ - relative to patch size - 1 is the default - but can be 2 as well
13
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 13 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 13 can change their appearence AGENTS („ TURTLES “) shape color size - e.g. „default“ or „person“ - relative to patch size - 1 is the default - but can be 2 as well - can be specified using words, - e.g. RED, GREEN, BLUE
14
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 14 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 14 can change their appearence AGENTS („ TURTLES “) shape color size - e.g. „default“ or „person“ - relative to patch size - 1 is the default - but can be 2 as well - can be specified using words, - e.g. RED, GREEN, BLUE or MAGENTA
15
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 15 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 15 can change their appearence AGENTS („ TURTLES “) hidden? - default: false
16
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 16 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 16 can change their appearence AGENTS („ TURTLES “) hidden? - default: false - can set to true as well
17
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 17 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 17 have a pen glued to their belly AGENTS („ TURTLES “) pen-mode - default: „up“, can also be „down“ pen-size
18
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 18 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 18 have a pen glued to their belly AGENTS („ TURTLES “) pen-mode - default: „up“, can also be „down“ -when the turtle moves with pen down, it will leave trails - trail colors corresponds to the turtle‘s color pen-size
19
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 19 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 19 have a pen glued to their belly AGENTS („ TURTLES “) pen-mode - default: „up“, can also be „down“ -when the turtle moves with pen down, it will leave trails - trail colors corresponds to the turtle‘s color pen-size - may also influence the thickness of the trail
20
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 20 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 20 change these to make an agent move AGENTS („ TURTLES “)
21
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 21 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 21 change these to make an agent move AGENTS („ TURTLES “) - special property containing the ID of the turtle (e.g. turtle 0)
22
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 22 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 22 cannot movePATCHES - are addressed by their center, e.g. patch 0 0 0
23
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 23 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 23 HANDS ON start NetLogo 3D type into the observer create-turtles 1
24
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 24 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 24 SEE THE RESULT
25
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 25 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 25 RIGHT MOUSE - CLICK THE TURTLE
26
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 26 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 26 CHOOSE TURTLE 0 > INSPECT TURTLE 0 … turtle 0 inspect patch 0 0 -16 inspect patch 0 0 -15 inspect turtle 0 watch turtle 0 follow turtle 0 ride turtle 0
27
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 27 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 27 HERE YOU GO, NOW … see the properties we talked about here change them & see the 3D view: pen-mode „down“ xcor 10 ycor 10 zcor 10 hidden? true
28
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 28 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 28NUMBERS are entered as-is you cannot change „who“ colors are numbers, too (see Tools>Color Swatches) color namenumber RED15 BLACK0 WHITE9.9
29
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 29 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 29STRINGS enter with quotation marks pen-mode: „up“ or „down“ shapes(see Tools>Turtle Shapes Editor) are for example: shape namelooks like „default“ „person“ „arrow“
30
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 30 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 30BOOLEANS enter either true or false
31
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 31 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 31 AGAIN, RIGHT - CLICK
32
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 32 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 32 CHOOSE INSPECT PATCH 0 0 -16 SEE THAT YOU CAN CHANGE THE PROPERTIES THERE THE SAME WAY SEE THAT YOU CAN CHANGE THE PROPERTIES THERE THE SAME WAY … turtle 0 inspect patch 0 0 -16 inspect patch 0 0 -15
33
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 33 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 33 NETLOGO ENTITIES observer turtles patches creates live on
34
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 34 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 34 CREATE - TURTLES observer create-turtles 1 turtle 0
35
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 35 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 35INSPECT observer turtle 0 inspect turtle 0
36
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 36 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 36 ASK AND SET observer turtle 0 ask turtle 0 [ ] set color BLUE
37
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 37 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 37 ALSO FOR PATCHES observer ask patch 0 0 0 [ ] set pcolor CYAN
38
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 38 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 38 TRY THIS ask and set are general commands, everything else is entity-specific, see Help > NetLogo Dictionary codewon‘t work because… ask turtle 0 [ create-turtles 1 ] only the observer can create-turtles ask patch 0 0 0[ set color red ] a patch has no property color. perhaps you meant pcolor?
39
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 39 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 39 COMMANDS SPECIFICALLY FOR TURTLES forward patch-units, back patch-units moves a turtle in the current direction left degrees, right degrees alters the heading of a turtle pen-down, pen-up changes pen-mode try this yourself! ask turtle 0 [forward 1]
40
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 40 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 40 COMMANDS SPECIFICALLY FOR OBERSERVER clear-all erases everything clear-drawing erases only the tracks of turtles create-turtles number […commands…] creates the specified number of turtles and runs commands on each one of them.
41
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 41 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 41 ASKING ALL AGENTS observer ask turtles [ ] set shape „person“
42
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 42 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 42 ASKING ALL PATCHES observer ask patches [ ] set pcolor cyan
43
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 43 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 43 THE „ WITH “ QUERY Can address entities based on their properties using a “with” query: observer ask turtles with [ycor > 0] [ ]
44
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 44 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 44 MORE EXAMPLES WITH „ AND “/„ OR “ ask turtles with[…] ask patches with[…] ycor > 0 ycor > 0 and xcor < 0 ycor > 0 or xcor < 0
45
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 45 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 45 WRITING A PROGRAM code is written on the „code“ tab click on this tab
46
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 46 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 46 YOUR FIRST PROGRAM to setup clear-all create-turtles 1 end write this
47
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 47 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 47 GIVE YOUR PROGRAM A USER INTERFACE get back to the interface add a button type this here setup
48
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 48 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 48 PRESS IT ! this will go to code and execute „setup“ the view will turn black and one turtle will be created at the origin
49
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 49 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 49 YOUR SECOND PROGRAM to go ask turtles [ set pen-mode „down“ forward 1 ] end write this
50
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 50 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 50 GIVE YOUR PROGRAM A USER INTERFACE get back to the interface add a button type this here go check this!
51
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 51 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 51 PRESS TO SEE THE DIFFERENCE will execute „go“ in a loop (forever) lots of trails will appear on screen
52
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 52 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 52 TYPICAL NETLOGO PROGRAM LAYOUT setup (executes once) clear everything set the environment (patches) –generate or load per-patch data create agents (turtles) –set shape, color, position and orientation set simulation time to 0 –…using reset-ticks go (called in a loop) simulate environment –e.g. changes to patches simulate agent behavior –orient and move turtles –simulate interactions between turtles and environment update statistics –using e.g. charts and plots advance time –…using tick see File > Models library
53
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 53 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 53 USER INTERFACE instead of using constant values, e.g.: create-turtles 10 you may 1.add a slider named num-turtles 2.use that as a placeholder, i.e. create-turtles num-turtles num-turtles
54
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 54 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 54 WHERE TO GO FROM HERE replacing hard-coded values by UI elements is always a good idea: after having finished, your program look like our our prototype implementation (which we present in the following slides): produces a number produces true or false) lets you enter a list of values to choose from
55
ARTIFICIAL SOCIETIES
56
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 56 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 56 WHAT IS THIS naively, a bunch of turtles interacting with patches having a behaviour (both patches AND turtles!) …interaction (turtle-turtle, turtle-patch, patch-turtle) is the key to complex systems
57
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 57 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 57INTERACTION per-patch data (e.g. „amount of wood“) is read or set by a turtle (e.g. get amount of wood here; set amount of wood to 0) per-turtle data is influenced likewise - can be read or set by a patch (e.g. if any turles here then set color to my color) data behaviour actor
58
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 58 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 58 DATA : PER - PATCH is written as: patches-own [ wood food ] at begin of your code. all data is initially set to zero, must explicitly ask patches [set wood 10] in setup if you want to change that wood = 0 food = 0
59
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 59 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 59 try it, e.g. using patches-own [ value ] and going to the interface tab YOUR TURN !
60
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 60 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 60 DATA : PER - TURTLE is likewise written as: turtles-own [ carries-wood carries-food ] try this out to see how it looks carries-wood = 0 carries-food = 0
61
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 61 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 61 BEHAVIOUR : SETTING A PATCH VALUE TOP VIEW value SIDE VIEW 1.each turtle is in exactly one patch 2.it can access a value of a patch by writing its name, e.g.: ask turtle 0 [set value (value + 1)] try it! +1
62
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 62 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 62 MORE OPTIONS you can get a value from… SAME PATCH PATCH AHEADSURROUNDING PATCH
63
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 63 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 63 GET VALUE AT Figure taken from McLoughlin, Laramee and Zhang 2009, “Easy integral surfaces “ optioncode same patchvalue [value] of patch-here patch one step ahead[value] of patch-ahead 1 surrounding patches (mean, minimum or maximum) mean [value] of neighbors or max [value] of neighbors or min [value] of neighbors
64
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 64 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 64 SET VALUE AT however, to set a value at a different patch, you must ask: ask turtle 0 [ ask patch-ahead 1 [ set value (value + 1) ] yes that‘s right you can nest asks (in fact, you can nest almost everything)
65
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 65 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 65 NEED FOR INTERMEDIATE MEMORY ask turtle 0 [ ask patch-ahead 1 [ set pcolor color ] pcolor doesn‘t work which of these two colors do you mean? color
66
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 66 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 66 INTERMEDIATE MEMORY ask turtle 0 [ let the-color color ask patch-ahead 1 [ set pcolor the-color ] use let to remember things even after nesting, like here: the color RED
67
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 67 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 67 BEHAVIOUR : SETTING TURTLE VALUES ask patch 0 0 0 [ ask turtles-here [ set color red ] remember: there can be many turtles in the same patch color RED color
68
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 68 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 68 MORE OPTIONS you can also set a value to… RED one-of turtles-here with [color = purple] RED one-of turtles in- radius 2
69
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 69 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 69 SELECTING TURTLES sample model: garden.nlogo – used as demo for selecting turtles
70
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 70 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference 2014, Barcelona, Slide 70 S O WE COME TO BREE DS NetLogo predefines one „breed“ of agents called turtles As programmer, you are free to define more breeds using the „breed“ keyword: breed inherits properties of turtle (no multiple inheritence, no patch breeds) breed [persons person] plural singular
71
THANK YOU gabriel.wurzer@tuwien.ac.at
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.