creating a ecosystems model in net logo

Slides:



Advertisements
Similar presentations
The essentials managers need to know about Excel
Advertisements

Space Man Sam: Grammar Mistakes By Aleis Murphy Duke University, Under the direction of Professor Susan Rodger July 2010.
Agents and Pervasive Computing Group Università di Modena e Reggio Emilia System Requirements NetLogo is designed: to run almost any type of computer.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
How Tall Are You? Introducing Functions By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made June 2014 by.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
POWERPOINT May 2004 To move the text box - move the mouse over the border of the text box, and once the 4-way arrow appears - click and drag the box to.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
1 An Introduction to IBM SPSS PSY450 Experimental Psychology Dr. Dwight Hennessy.
 When you receive a new you will be shown a highlighted in yellow box where your can be found  To open your new just double click.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Department of Computer Science What is NetLogo UH-DMML  Multi-agent programmable modeling environment  Well suited for modeling complex systems evolving.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Chapter 1 - Getting to know Greenfoot
Models in NetLogo Day 3 COLQ 201 Multiagent modeling Harry Howard Tulane University.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
 When you receive a new you will be shown a highlighted in yellow box where your can be found  To open your new just double click.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Lesson 10 - Mail Merge and Reviewing Documents Advanced Microsoft Word.
Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
An Introduction to Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University, June 2009 Updated June 2014 by Ellen Yuan.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Illuminating Computer Science CCIT 4-6Sep
VB.NET and Databases. ADO.NET VB.Net allows you many ways to connect to a database. The technology used to interact with a database or data source is.
How Tall Are You? Introducing Functions for Alice 3 By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Getting Started With Alice: The Basics. Step 1: Background Open up Alice, and choose a background for your Alice world. Your world is something you can.
1 Agent-Based Tools: focus on NetLogo Ing. Cristina Ponsiglione University of Naples Federico II Laboratorio di Simulazione ad Agenti.
Training Guide for Residents
Introduction to Programming in RobotC
The Essentials of Alice (Bunny)
Getting Started With Alice: The Basics
Create a Halloween Computer Game in Scratch
Scratch for Interactivity
An Introduction to Alice (Short Version)
Going Green By Ima Librarian
Teaching Characters to Walk: Learning Methods, Part 1
Reviewing Documents Guided Lesson.
Changing Color, Using Text Objects, and Random Selection in Alice
Adding Assignments and Learning Units to Your TSS Course
Let's Race! Typing on the Home Row
Scratch for Interactivity
MS PowerPoint 2010 Week 2.
Learning to program with Logo
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Microsoft Word Reviewing Documents.
Introduction to Object-Oriented Programming
GRAPHING CALCULATOR Part 1
Go to =>
Introduction to TouchDevelop
An Introduction to Alice
Go to =>
Go to =>
Whatcha doin'? Aims: Begin to create GUI applications. Objectives:
How Tall Are You? Introducing Functions
Getting Started With Alice
Using Logo and Logic This presentation uses a version of Logo called StarLogo available through MIT. It can be downloaded for free and installed on your.
Getting Started With Alice: The Basics
Chapter 1 Introducing Small Basic
Introduction to Excel 2007 Part 3: Bar Graphs and Histograms
Creating a Simple Game in Scratch
Presentation transcript:

creating a ecosystems model in net logo

NETLOGO BASICS Tabs - Interface, Info, Code World agent Turtles Patches Interface characteristics - size of world & patch size x & y coordinate grid with 0,0 at center ability to wrap

START A NEW PROJECT & SET-UP WORLD Open NetLogo, click on File and choose New. Name your new project with your name and Ecosystems Model and Save (to your flash drive). Click on Settings, change: min pxcor to -50 (negative 50) and the max pxcor to 50. change the “patch size” to 4 Be sure “world wraps horizontally” and “world wraps vertically boxes are checked, and click OK. Use the ADD button to create two buttons: setup, and go. When creating go, check the forever box.

START CODING Go to the CODE tab You can add any “comments” that the computer will not read by first putting a semi-colon ;; (notice that makes the text gray) So, put a ; or two, then name your project again here Next, type BREED [ SHEEP A-SHEEP ] This tells the computer you are going to call your turtles “sheep” and give them specific commands (you need a singular and a plural name for your breed)

CREATE A “TURTLES-OWN” VARIABLE Next, tell the computer you want your turtles (for right now, your sheep) to have a variable (like a trait or characteristic” of “energy” Type turtles-own [ energy ] Notice the colors of your text: ;; Title (after semi-colons) is gray breeds and turtles-own are green, - NetLogo understands those words (primitives) “sheep” “a-sheep” and “energy” are black - words you’ve used to name things that the computer will use, but you will have to explain what they mean

CREATE CODE FOR THE SETUP BUTTON Start with TO SETUP, end with END. First command is to clear out whatever happened when we last ran the program: CLEAR-ALL Next, we want to write procedures to setup the grass: The grass will be the patches, so we ask them to have a random chance of turning green, and otherwise to be brown. Conditional logic - “IFELSE” asks a true/false question, if the answer is true the computer does one thing, if it is false, it does another. Our true-false question is: if else random 100 < 5 In other words, when the computer rolls a dice with 100 sides, does it get a 0, 1, 2, 3, or 4? If so, the answer is true, if not (if it rolls any other # 6-99) its false. If the answer is true (5% of the time), we want the patches to be green (grass) If the answer is false (95% of the time) we want the patches to be brown (dirt)

Notice the beginning and ending brackets [ ] SETUP CODE SO FAR Notice the beginning and ending brackets [ ]

create sheep in setup code Next, we want to create 50 sheep, set their size to 3, their shape to “sheep”, their color to white, and give them some initial energy, plus a random amount of energy. We also want to scatter them through space land. Notice the colors of the code

Finish Setup CODE Because we are going to add a graph later, we want the computer to keep track of “time” or “ticks” At the end of your setup code, type “reset-ticks” then type “end” Be sure to SAVE your model frequently Push the “check” button on the upper left of the coding window - see if the computer identifies any errors in your code so far. If not, go to the Interface screen and push the setup button. Do you get the sheep and grass you expect to see?

CONGRATULATIONS! You are finished with the setup code. Review: Concepts Types NetLogo commands agents turtle patch world ask-turtles ask-patches variables agent (turtle) conditionals if ifelse procedures to end Tabs Interface Info Code

new procedures - GO Button Create a go procedure - everything that should happen when you push the go button on the interface. This is a “forever” button - it will call all the procedures, in the order you place them, repeatedly until you click the button again. Under your setup procedure, type: to go end Inside the procedure, type “tick” so the computer will count the ticks as the program runs. Next, think about everything we want the sheep to do.

walk around (and lose a little bit of energy) Go procedures The sheep need to: walk around (and lose a little bit of energy) eat the grass (and gain energy) reproduce (if they get enough energy) die (if they lose all their energy) We also want the grass to grow as the model runs

Sheep procedures Your “go” procedure should look like this so far: Notice I have put a comment after ;; to explain to myself what I’m doing here Finally, be sure your go ends with “end”

define procedures We told the computer the names of all the procedures we want the sheep to follow (the words are all black in this list) but we haven’t been specific about what each procedure is. Walk procedure - start with “to walk” and end with “end”, and make the sheep walk with a random wiggle (left 45, right 45, forward 1). The sheep also need to lose 1/2 unit of energy (.5) at each step.

Your “walk” procedure should look like this: Sheep procedures Your “walk” procedure should look like this: Notice I have put a comment after ;; to explain to myself what I’m doing here about the energy

Don’t forget to start with “to graze” and end with “end” “Graze” procedure We want the sheep to eat the grass. For this, we need a simple conditional, “if” rather than “ifelse”. The sheep should ask if they are on a green patch pcolor (means patch color) = green, and if so, change the patch color to brown and gain 10 units of energy. Don’t forget to start with “to graze” and end with “end”

Your “graze” procedure should look like this: Sheep procedures Your “graze” procedure should look like this:

SAVE AND TEST Save your model, and hit the “check” button in the upper left. You will likely get an error message, saying the computer doesn’t know how to execute all the procedures, because we haven’t written the “sheep-breed” “sheep-die” and “regrow-grass” procedures. If you want to test whether your model works, put a semi-colon in front of those procedures in the “go” procedure, check again, and go to the Interface to see if your sheep are walking around and eating grass.

“sheep-breed” procedure We want the sheep to reproduce if it gains enough energy. For this, we again need a simple conditional, asking if the sheep’s energy is greater than 20. If so, first divide the sheep’s energy by 2 (or you will have a population explosion), and then “hatch 1” and tell then new sheep to face in a random direction (set heading random 360), and step 1 step away from the parent sheep. Don’t forget to start with “to sheep-breed” and end with “end”

SHEEP -BREED PROCEDURE Your procedure should look like this:

“sheep-die” procedure We want each sheep to die if its energy drops to (or below) zero. We have to name this procedure “sheep-die” because the computer already knows the word “die” so we can’t use it as the name of a procedure. See if you can create this procedure yourself. Once you have done it, save your model, use the “check” button, and then (if you have put ;; in front of the “regrow-grass” procedure), see if your model is working so far on the interface.

“regrow-grass” procedure Finally, we want our model to re-grow the grass as the program is running. After the “to regrow-grass” this procedure needs to ask the patches whether they are brown, and if so, create a very small random chance (random 1000 < 1) of turning green. Why does this chance have to be so small?

re-grow grass PROCEDURE Your procedure should look like this:

SAVE AND TEST We have written all procedures, so save your model, be sure to remove any ;; you put in to test the model before we were finished, hit the “check” button, and go to the interface to see if the model runs.

CONGRATULATIONS! You have a model that behaves as you want it to, but you can’t collect any data yet. Let’s create some data boxes and a graph to see how the model runs. On the interface tab, choose “monitor” from the drop down arrow on the upper left, then hit the green plus sign ADD button, then use your mouse the put the button where you want it. You should see a “reporter” screen, and to count the sheep, type in count sheep and put the word “sheep” in the display area. No need to change the other values.

more data boxes Push setup, and see that the sheep monitor shows the number of sheep created. Push go, and the monitor should show the changing number of sheep. Once this monitor is working, make a monitor to count the grass (count patches with [pcolor = green]). Next, try creating a graph (a “plot”) and name it Populations. Tell it to “plot count sheep” and use a similar code to the monitor for the grass to tell it to count the grass.

create a graph

we have a model! Now that you have a working model with monitors and a graph, look for patterns of behavior. How do the populations of sheep and grass change over time? Can we run any experiments with this model? What could we ask about, that running the model might help us figure out?

MAKE THIS AN EXPERIMENTAL MODEL To make it easy to experiment with the model, let’s create a slider. On the interface screen, select “slider” from the drop-down menu, and use your mouse to create a slider button. In the first blank (global variable) put the name of your slider: “initial- sheep.” Set the minimum to 1, the maximum to 100, and the “value” (where the slider will be when you open the model) to 50. Click OK.

slider continued We have a slider on the interface but like any button there, it doesn’t work until you put something in the code to tell the computer where to use the slider value. What number (hard-coded into our code) does we want the slider to replace?

slider continued We want the slider to control the number of sheep created when we hit the setup button. Find that number in the code, and instead of the number (50), type in the exact name of the slider. Save your model, and test your slider by moving it all the way to the bottom and then hitting setup, and then by moving it all the way to the top. Now, we can easily see how changing one variable (the number of sheep we have to start with) affects the model.

add a predator Use what you have learned about creating a breed, setting it up in the set-up, and writing procedures to create wolves which will walk around (lope) and lose a little bit of energy, eat the sheep and gain energy, reproduce, and die. You can copy the procedures you used for the sheep but you must change the name of the procedure. When you have your wolves doing everything you want, add a monitor to count the wolves, and add a “pen” to the graph to count the wolves. Be sure to save often and check your code after writing each procedure.

add a slider for your wolf population How did adding 10 wolves change the dynamics of your model? Would you also like to experiment with the number of wolves created? If so, try adding a slider for the initial-wolves, and experiment with your code. Extension: add a slider for the grass-regrowth rate, so you can experiment with any of three variables in your code. What other ideas do you have about how to improve this model, to run interesting experiments?