Table of Contents
1. Creating the world |
2. Buttons and Procedures |
3. Sliders and Variables |
4. Creating Turtles and Patches |
5. Making the Model Go |
You've now seen how buttons and procedures work together. Now, you will see how sliders connect up to variables (if you need to refresh your memory, there is information about variables in the lecture or in the previous section).
initial-number-of-turtles
. This is the name of the
variable that we can use in the Code tab shortly.0
. This is the smallest number that the slider will show.1
. Moving the slider very slightly will increase or decrease
the number by 1.100
. This is the largest number that the slider can show.10
. The default value (the number that the slider starts with).Now the slider is ready. Next we'll go back into the model code and make some improvements so that it does something more useful.
That was easy enough. In the next section we'll look more closely at how we can use the slider in the model. But first, have a go at the activities below.
These activities will check that you're familiar with how to write procedures. Before starting, type the following code into the Command Centre:
create-turtles 10 [ set xcor random 10 set ycor random 10 ]
This will temporarily create ten new turtles - we need these to see if your procedures
are working properly. For the following questions, write the required code in the
'Code' section of NetLogo, and then run your commands from the Command Centre by simply
typing the name of the procedure. For example, if you have created a procedure called
do-something
you simply type 'do-something' in the Command Centre to run
it.
ask
command as we did in the last practical). Once
you have written the procedure in the 'Code' tab, type 'make-blue' into the Command
Centre to run it.
fd 1
tells a turtle to go one step forward).