StarLogo Nova Cookbook



Similar documents
Excel -- Creating Charts

MODULE 1 (COMPUTER MODELING AND SIMULATION) INTRODUCTION. Module Name: Introduction to Computer Modeling and Simulation

Introduction to the TI-Nspire CX

Create a Poster Using Publisher

How to make a line graph using Excel 2007

3D-GIS in the Cloud USER MANUAL. August, 2014

Scientific Graphing in Excel 2010

DOING MORE WITH WORD: MICROSOFT OFFICE 2010

Intermediate PowerPoint

Interactive Excel Spreadsheets:

Instructions for Creating a Poster for Arts and Humanities Research Day Using PowerPoint

CATIA Basic Concepts TABLE OF CONTENTS

Instructions for Formatting APA Style Papers in Microsoft Word 2010

Windows XP Pro: Basics 1

Publisher 2010 Cheat Sheet

Eye Tracking Instructions

WEB TRADER USER MANUAL

ACS Version Check Layout Design

FREE FALL. Introduction. Reference Young and Freedman, University Physics, 12 th Edition: Chapter 2, section 2.5

Excel Tutorial. Bio 150B Excel Tutorial 1

Microsoft Word Quick Reference Guide. Union Institute & University

Handout: Word 2010 Tips and Shortcuts

This activity will show you how to draw graphs of algebraic functions in Excel.

Making Visio Diagrams Come Alive with Data

Microsoft Windows Overview Desktop Parts

Task Card #2 SMART Board: Notebook

Communicate: In Print

Select the Crow s Foot entity relationship diagram (ERD) option. Create the entities and define their components.

USER MANUAL (PRO-CURO LITE, PRO & ENT) [SUPPLIED FOR VERSION 3]

Microsoft Word Track Changes

Excel 2007 A Beginners Guide

Advanced Programming with LEGO NXT MindStorms

Microsoft PowerPoint 2011

Inking in MS Office 2013

Epson Brightlink Interactive Board and Pen Training. Step One: Install the Brightlink Easy Interactive Driver

Microsoft PowerPoint 2010

Getting Started in Tinkercad

SMART NOTEBOOK 10. Instructional Technology Enhancing ACHievement

Excel 2003 A Beginners Guide

Appointments: Calendar Window

Guide To Creating Academic Posters Using Microsoft PowerPoint 2010

Excel 2007: Basics Learning Guide

Getting Started on the Computer With Mouseaerobics! Windows XP

Data Visualization. Prepared by Francisco Olivera, Ph.D., Srikanth Koka Department of Civil Engineering Texas A&M University February 2004

WORDPAD TUTORIAL WINDOWS 7

INTRODUCTION TO DESKTOP PUBLISHING

REFERENCE GUIDE 1. INTRODUCTION

The main imovie window is divided into six major parts.

Creating and Using Links and Bookmarks in PDF Documents

Using Microsoft Word. Working With Objects

Google Sites. How to create a site using Google Sites

Excel 2007 Basic knowledge

Intro to 3D Animation Using Blender

Guide to Viewing Maps in Google Earth

Intro to Excel spreadsheets

Data representation and analysis in Excel

Microsoft Excel 2010 Charts and Graphs

1.0-Scratch Interface 1.1. Valuable Information

Experiment 3: Magnetic Fields of a Bar Magnet and Helmholtz Coil

Microsoft Word 2010 Tutorial

SMART Board Beginning

PowerPoint. Basics. Project

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

WebEx Sharing Resources

Creating Fill-able Forms using Acrobat 8.0: Part 1

WHAT S NEW IN WORD 2010 & HOW TO CUSTOMIZE IT

Experiment 5: Magnetic Fields of a Bar Magnet and of the Earth

Gestation Period as a function of Lifespan

Presentations and PowerPoint

Welcome to CorelDRAW, a comprehensive vector-based drawing and graphic-design program for the graphics professional.

Pacman 3D. Suggestions Multiple levels Powerups that let Pacman chase and eat Ghosts; ghosts need to respawn

SMARTstuff. The first rule for using an interactive whiteboard is very simple and of the utmost importance: Have faith in yourself you can do this!

OneNote 2013 Tutorial

Graphing in excel on the Mac

Adding Comments in Microsoft Excel 2003

HOWTO annotate documents in Microsoft Word

Tutorial for Tracker and Supporting Software By David Chandler

Integrated Invoicing and Debt Management System for Mac OS X

CREATING SCENERY WITH THE PHOENIX RC CREATOR PROGRAM

Windows 95. 2a. Place the pointer on Programs. Move the pointer horizontally to the right into the next window.

Welcome to CSU The Software Used To Data Conference.

Microsoft Outlook 2007

Experiment 3: Magnetic Fields of a Bar Magnet and Helmholtz Coil

Getting Started with Excel Table of Contents

Excel Level Two. Introduction. Contents. Exploring Formulas. Entering Formulas

In this session, we will explain some of the basics of word processing. 1. Start Microsoft Word 11. Edit the Document cut & move

App Inventor Tutorial 4 Cat & Mouse Game

Creating a Poster in PowerPoint A. Set Up Your Poster

Manual: I. Getting Started:

SolidWorks Tutorial 3 MAGNETIC BLOCK

Creating a PowerPoint Poster using Windows

Microsoft Access 2010 handout

Microsoft Word defaults to left justified (aligned) paragraphs. This means that new lines automatically line up with the left margin.

Dealing with Data in Excel 2010

Online Tools Training Lesson Plan

Why Use OneNote? Creating a New Notebook

Drawing a histogram using Excel

Creating a Guided Tour with Google Earth

Windows 8.1 Update 1 Supplement

Transcription:

StarLogo Nova Cookbook 1. Basic Set-up 2. Add or rename breeds 3. Giving your agents built in traits 4. Creating new traits for your agents 5. Basic wiggle walk and random walk 6. Basic geometry coordinates 7. Headings 8. Tilt screen to see in 3d 9. Copy and paste code 10. Loops 11. Sliders - basic (# of turtles) and percentage (% of turtles that are purple) 12. Change the terrain color during setup 13. Change the terrain color as the program is running 14. Making turtles react to patch color 15. Scatter turtles randomly on a certain terrain color 16. Collisions -- create/delete turtles on collision, set or modify traits 17. Stop code 18. Data boxes 19. Line graph 20. Hide and show graph 21. Chase another breed 22. Run away from another breed

Basic Setup These blocks to set up your world should be placed on the world tab. Usually, you want to delete everyone (agents tab) and to clear terrain (environment tab) before creating your new world. To create turtles, use the larger create block from the agents tab the create do - - so you can set agent traits. Type in the number of turtles you want to create, and select Turtle from the drop- down menu. It is also common to scatter the agents by attaching a scatter everyone (from the agents drawer) underneath the create block. If you only want to scatter a certain type of agent, you can put a simple scatter block under the word do in the create/do block. You tube GUTS channel: Flower Power 1:10-3:20 demonstrates a setup block (no scatter or traits); 3:50 4:15 makes turtles move forward 3 on setup https://www.youtube.com/watch?v=48x6pp931fe

Adding or Renaming Breeds To add or rename a breed, go to the interface and click on the edit breeds button. You can rename the turtle breed or click on add breed to create another breed. Each breed that you add also adds a page (tab) where you can place blocks that will control that breed.

Setting the built- in traits for your agents. You can give your turtles traits (from the traits drawer) by setting them in a create- do block when you create the turtles. You can type in a number in a blank space, for example to set the size or coordinate, but don t try to type anything else - - if you try to type in words like red to set the color of the block, it will not work. Instead, you need to drag a color or built- in shape block from the traits drawer into the blank space, and use the drop- down menu in that block to set those traits.

Creating a new trait for agents. In addition to using the build in traits, you can also give your agents other traits. All agents of that breed will have the trait and it can be set at startup. First, go to the interface screen and select the edit breeds button. Then, choose data and give your trait a name, then click OK. Get a set my traits block from the traits drawer and use the drop- down menu on select the new trait, and give it an initial value. Use an if or collision block to trigger a change in energy. Be sure to use the agent s existing energy and add or subtract from it to change the energy gradually as the program runs.

Wiggle Walk & Random Walk To make your agents move in a natural way, you can use the wiggle walk or the random walk. In the wiggle walk, agents move forward but randomly turn a little bit to the right then a little bit to the left at each step. Randomness in the amount that they turn causes them to wander across the world. Change the size of the random turns to make them walk in a mostly straight line or walk in tight random patterns. The random walk just has the turtles set their heading to a random number, then step forward. Guts You Tube channel: Flower Turtles https://www.youtube.com/watch?v=48x6pp931fe 4:40 6:40 Shows how to get out forever, while toggled, put in forward and left movement, pen down

Basic geometry coordinates in Nova: Nova creates spaceland as a grid that is 101 patches high and 101 patches wide, with 0,0 in the center. As a default, agents are setup in the center of the screen (and at ground level, z = 0). They can be randomly scattered by using the scatter and scatter everyone blocks from the agent drawer, or by using this formula: To randomly scatter turtles over a limited part of blockland: To change where the turtles scatter, change the x or y coordinate in this formula. For example, to scatter them randomly on the lower half of the screen, change the y-coordinate to return a random number between 0-50, and then subtract 50.

Headings in Nova: If you create a single turtle, its default heading will be 0 degrees. If you create two turtles, the first will face 0 degrees and the second will face 180 degrees;; if you create 4, they will each face a compass direction, as illustrated below (by having turtles move with pen down).

The code that creates this demonstration pattern is here: Additional turtles will set up on default to evenly divide the circle by the number of turtles creates -- 360 turtles will each face 1 degree apart in the circle. You can change the default heading by using the set my to from the traits drawer, within a create/do block or in a procedure or collision block: You can also have the turtles face in a general direction (with some degree of randomness) by using a formula to set the heading. This formula will set the turtle s heading between 0 and 180, or facing the upper half of the screen.

Tilt screen to see in 3d: In some models, like the greenhouse model, it is difficult to see what is happening on the interface using a two- dimensional or overhead view. Two dimensional view of greenhouse model (with cars and bus): To tilt the screen up on edge and view it as a three- dimensional interface, click on the green part of the interface (blockland) then hold down the option key while you click the mouse or keypad, and drag down the screen (toward the bottom) to tilt blockland. It is easy to lose your place - - if you do, just click reset camera at the top of the interface to restore the aerial view and try again. Three- dimensional view:

Another way to have a view of spaceland based on the perspective of an agent or breed is to drag a take camera button from the agents drawer into the create/do block where you create the agent you want to have the camera. In this example, the clownfish takes the camera, and on setup, the interface looks like this:

Cut, Copy and Paste code: It can be very useful to copy a long piece of code that exists for one agent, and change the specific settings to apply to a different agent, or to move code created on one tab to another tab. Click and drag your mouse or touchpad to make a box (shown by a dotted green line) around the entire block of code you want to copy. (Nova will only copy a complete block of code, so if you want only a piece of a block, detach it from the larger block before copying). Then, click copy (at the bottom left of the screen, beneath the drawers). Finally, click paste to copy your code, creating additional copies by clicking paste again. Nova will sometimes paste the code on the extreme upper right of the tab use the horizontal and vertical scroll bars to find it.

Loops: Any button created using the while toggled will be a loop, continuing to execute the commands in order (top to bottom) until the button is toggled off. So, putting a series of movement commands inside a while forever toggled will make the turtles move in a wiggle until the forever button is toggled off. You can also use a block from the logic drawer, while to have agents continue a behavior only as long as a certain condition is true. You can use a repeat block, from the logic drawer, to get turtles to perform a command or series of commands a set number of times.

Adding a Slider Sliders are useful for changing a value that you will use inside your model. To create a slider, go to the interface screen, click Edit Widgets on the upper left, and then click the red New Widget buttons to call the Create Widget screen. Select horizontal slider (upper right), name your slider, and click Add Widget Your slider will appear on the interface drag it where you want it, and set the minimum and maximum values by typing in the desired numbers be sure to hit the return (enter) key after typing in your desired values while still on this screen. Then click Edit Widgets again to return to the interface screen. Now, go to the setup block on the world page where you created your turtles. In the Interface drawer, scroll down to select the slider value block. Put it into the create block where you set the number of turtles, and select the name of your slider.

The number of turtles you create on setup should now reflect the slider setting. To use a slider to create a percent: Follow the directions above to create and name a slider. Be sure to set the slider maximum value to 100. Put the slider value block into the code to replace number you want to use as a variable, using the following formula:

Change the color of the terrain on setup Nova does not allow the terrain color to be changed directly, so to change it you must create a turtle to do the work and then delete that turtle. On setup, create a turtle, set it to a large size, set its x and y coordinates to the beginning corner of the desired patch to re-color, and set its heading toward the end of the desired patch. Put a stamp command from the terrain drawer, with a my color block from the traits drawer, and a forward command (movement drawer) inside a repeat block (logic drawer) to have the turtle walk along, stamping the desired terrain color. Then, delete the turtle. For example, you can make the top half of spaceland look like the sky: Call the make sky procedure in the set-up block, after clearing the terrain, deleting everyone, and clearing any data boxes or graphs, and before creating the actual agents for the model. To make earth or the ground in that model, follow a very similar procedure, changing the y-coordinate to -25, and the color to brown.

To change the color of the terrain as the program is running: Create a widget to push when you want the terrain to change, for example, if you want it to appear that flowers get planted randomly in the landscape at a certain point (see the entry for Hiding and Showing Graphs for a review of how to create widgets). Here, the widget is named plant flowers and is a when pushed widget. In that widget, create an agent (it can be an agent you use elsewhere, or a separate breed) and set its size to zero. Then, in a repeat block (repeat as many times as you like), set the agent to random x and y coordinate, to a visible size, have it stamp a color, then set its size to zero. Delete the agent at the end of the widget s code.

To make turtles react to patch color: To make your turtles react to a certain condition, like the color of a patch, use conditional blocks from the logic drawer. When you want agents to change their behavior if a certain condition is true, use the if block. For example: This code will make the turtles turn left if they hit a red patch on the terrain. You can have agents follow different sets of commands, depending on whether a condition is true or false, by using the if else block (from the logic drawer).

This code allows you to set the percent of turtles created on setup that are red, and set the color of the rest of the turtles to blue. GUTS you tube channel Bumper Turtles: https://www.youtube.com/watch?v=w1iobyo6vzm Conditionals code for turtles to react to patch color at 3:15 4:10

To scatter turtles according to terrain color: If you have created a terrain color on set-up and want to scatter your agents randomly within that particular color or exclude them from a particular color, you can create a scatter procedure that calls itself, or a recursion. For example, in this water pumping model, the turtles (acting as groundwater) need to scatter randomly on the bottom half of the screen only (the earth, which has been colored brown), and not in the sky, which is cyan. Drag a procedure block onto the turtle tab, and name it. Put a simple scatter first, and then add a conditional ( if ) block from the logic drawer. Ask the turtle to look at the terrain color, and if it has scattered onto the wrong color (cyan) it calls the scatter procedure again (recursion). Don t forget to call this procedure in the setup block on the world page. You can also use recursion and set the x and y coordinates to random numbers, to accomplish the same goal. Here, the turtles (consumers) need to scatter randomly except in the yellow portion of the terrain.

Again, the procedure must be called in the setup block, as well as in itself.

Collisions Turtles will simply walk through each other unless you tell them to react to a collision. Using the collision blocks, you can have various events occur when agents collide, with each other or with a different breed. To show the spread of an infection, for example, you might want blue (healthy) turtles to turn red (infected) when they collide with a red turtle. Use a collision block (from the detection drawer) and select Turtle from the drop- down menu. Then, have the colliding turtle check whether it is colliding with (the collidee) is red. If so, the colliding turtle should turn red: If you want a collision between breeds, you should pay attention to where you are placing the collision block. For example, you might want to make a shark to appear to eat a turtle on collision. Put the collision block on the shark page, and delete the collidee or turtle.

Stop code When you are using a model to collect data, it is useful to have the model stop running after a set period of time, so the data can be recorded. You need to run the model long enough to see results, but not so long that repeated trials of the same experiment become burdensome. To have a model stop after 500 ticks, use a conditional logic block inside each use of the while forever toggled in your code. For example, this code will call all the procedures and will update the data box for 500 ticks. The program will then stop running (although the forever button is still pushed), and the data can be recorded before the next trial of the experiment begins.

Data boxes: To have the computer count agents for you, create and name a data box. Nova automatically opens a new project with a data box called score but you can create as many others as you would like. On the interface, check Edit Widgets and then click the red button to create a New Widget. Choose Data Box and name your widget, then click Add Widget. Drag your widget where you want it on the interface page, and click the Edit Widgets button again to exit this screen. Look in the interface drawer for two blocks: when forever toggled and set data box to and drag them onto the world tab. Use the drop- down menu to select the title of your data box. Then, from the detection drawer, add a block that will allow you to count the agents, or as in this example, the agents with a particular characteristic:

The world agent will count the turtles within a certain number of steps from itself (located in the center of the screen, at 0,0), so be sure to use a number that will count all turtles on the 101 x 101 step screen. If you want to clear the data box on setup, use the set data box code to set the data box to 0. Be sure to place this box above the blocks creating the turtles.

Line graph Creating a line graph is similar to creating a data box, with just a few more steps. On the interface, click the edit widgets button and create a new widget. Select line graph, name your graph, and click Add Widget. Place your graph on the interface (you cannot resize it, although another cookbook entry explains how to hide or show a graph). While you are still on the gray screen to edit widgets, double click at the bottom of the graph on series 1 to name the series. Click on the colored square to choose the color of the line in the graph, and click Accept. Click on add series to create another input into the graph, name it, and choose the color of the line. When you have created all relevant series, click edit widgets to exit the editing screen.

Get a when forever toggled block and a block called add data to line graph from the interface drawer, and place them on the World tab. Use the drop- down menu to select the name of your line graph and to select the first series in your graph. Put a count within command from the detection drawer into the y- axis slot. The world agent will count the agents within a certain number of steps from the center of the screen, so use 200 steps to cover the entire screen. Get a clock block from the environment drawer and place it in the slot for the x- axis. Repeat this process for each series in your graph. You can also clear the graph on setup by using the clear graph block from the interface drawer. Be sure to place this block above the create agents blocks.

Hide and show graphs: Since the graphs cannot be resized in Nova, they can block the view of the interface (blockland). You can solve this problem by creating a widget to hide and show the graphs. On the interface, click Edit Widgets and then the red button to Create a New Widget. Select Push button on the upper left, name your widget, and click Add Widget. Create another Push button widget called Show graph, place the buttons where you want them on the interface, and then click the Edit Widgets button again to exit this screen. To create the code to make these widgets work, go to the world tab, open the interface drawer and select the when pushed block and a hide block. Use the drop-down menus to select first the name of your new push button ( Hide graphs ) and then the name of your graph ( heat ). Add a hide block for each additional graph ( co2 levels ). Follow the same procedure for your show graphs button.

Chase: Instead of having agents always move in a random wiggle, you can make a predator agent chase the closest prey agent. In this example, create a procedure on the tab for your predator agent (mountain lion) using the face towards and forward blocks from the movement drawer, and a nearest within steps from the detection drawer. Put them together so you are asking the mountain lion to face towards the nearest rabbit (prey) within 100 steps, and move forward 1. The lion will follow the nearest rabbit until it catches (and eats) it, and then will choose another rabbit to follow: You can call this procedure inside a forever button, so the lion is always moving forward straight toward the nearest rabbit. Or, you can use an if/else logic block to have the lion move in a wiggle unless a rabbit is nearby, and then follow the chase procedure.

This second method allows you to change the speed and the energy loss for the lion, depending on whether it is chasing a rabbit or just wandering around.

Run Away: To make the prey breed wander around unless a predator is nearby, create a basic move or wiggle procedure for your prey (rabbits) on the prey tab and call the procedure in a forever block. Create another procedure for them to run away, and call this procedure in the same forever block, below the wiggle procedure. A rabbit will follow its wiggle procedure (which is called first in the forever block) until a lion comes within 10 steps. Then, the rabbit executes the runaway procedure, where it faces towards the nearest lion, then turns around and takes a small step away (there is no block to ask the rabbit to face away from the lion, it can only face towards it and then turn around). It will continue to take small steps away from the lion until the lion is more than 10 steps away, when the rabbit will wiggle again.