GEOG3150 - GIS, Geocomputation and Geoplanning - Semster 2


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

Practical 2, part 5 - Making the Model 'Go'


To finish the model we need to create a go button. This will start the model running.

  1. Create a new button in the same way that you created the setup button. In the 'commands' section, write go. This will make the button start a procedure called 'go'. You can give the button any name you want (typically people use 'Go', but you could use 'Begin model' or whatever, it doesn't matter).
  2. Important: tick the 'Forever' box. This will mean that the procedure is run over and over again until you actually stop it. If you don't tick this box the button will make the model run for one iteration (time step) and then stop.
  3. Press 'OK' to create the button.
  4. Go back to the 'Code' tab and add the following procedure to the code. It doesn't matter where it goes, but you would usually put it after the procedures that set up the model. to go
      ask turtles [
       rt (random 360)
       fd 1
       if pcolor = green [
        set pcolor brown
       ]
      ]
    end
  5. There are some more new commands in there, but they are quite easy to explain.

    Built-in slider to change the speed of the model.
  6. Finally, go back to the main interface tab and click on the 'go' button. The model probably runs too quickly to see what is happening and the whole world suddenly turns brown. To stop this, move the slider at the top of the program (just below the 'Interface', 'Info' and 'Code' tabs) to the left. The reset the model and go again, you should be able to see the sheep moving around at a more reasonable pace.

That's it! You now have a very simple simulation with some turtles that will move around and eat grass. With a few small additions to the code it is possible to have grass that grows and can be eaten, turtles that die if they do not have enough to eat, and a graph to show how many turtles are alive. We'll look at these changes next time. If you have the energy, you can move straight on to practical 3. Or, if you are ready to either cry or destroy the computer in front of you, go and have another cup of tea.

The final model.
[School of Geography homepage] [Leeds University homepage]