New Mexico Computer Science For All Variables and Scope Maureen Psaila-Dombrowski.

Slides:



Advertisements
Similar presentations
Introduction to C++ An object-oriented language Unit - 01.
Advertisements

Netlogo! NetLogo is a programmable modeling environment for simulating complex systems. Modelers can give instructions to hundreds or thousands of independent.
Agents and Pervasive Computing Group Università di Modena e Reggio Emilia System Requirements NetLogo is designed: to run almost any type of computer.
13 giugno 2006Master in economia e politica sanitaria - Simulazione per la sanità 1 _Strumenti, seguito _______________________________________ Un modello.
Netlogo and its Relatives Logo (Papert) –Language for teaching mathematics graphically –Tell turtle how to move Starlogo (Resnick) & StarlogoT (Wilensky)
Outline What Is Function ? Create Function Call Function Parameters Functions Function Returning Values PHP Variable Scopes Passing by Reference Vs Value.
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 1 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference.
Day 1 Goal: To create a model of people hunting in the forest for mushrooms and then start working on improving their mushroom hunting ability mathematically.
New Mexico Computer Science For All
New Mexico Computer Science For All Local Variables in Netlogo Maureen Psaila-Dombrowski.
New Mexico Computer Science For All Breeds and Shapes in NetLogo Maureen Psaila-Dombrowski.
Agent-based model of a simple stable economy Alexandre Lomovtsev Adviser: Dr. Russ Abbott.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Agent-based model of a simple stable economy Alexandre Lomovtsev Advisor: Dr. Russell Abbott, Ph.D. California State University, Los Angeles Department.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
Teaching Contemporary Mathematics Conference January 25, 2013 Christine Belledin NC School of Science and Mathematics.
Department of Computer Science What is NetLogo UH-DMML  Multi-agent programmable modeling environment  Well suited for modeling complex systems evolving.
New Mexico Computer Science For All Booleans and Logic Maureen Psaila-Dombrowski.
An Introduction to NetLogo given by Gabriel Wurzer. ,
A First Program Using C#
New Mexico Computer Science For All Statements and Expressions in NetLogo Maureen Psaila-Dombrowski.
ABM Frameworks Dr Andy Evans With additions from Dr Nick Malleson.
NetLogo Dr. Feng Gu. NetLogo NetLogo is a programmable modeling environment for simulating natural and social phenomena, authored by Uri Wilensky in 1999.
2-Day Introduction to Agent-Based Modelling Day 1: Session 4 Networks.
Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.
CISC 1600 – Lecture 3.2 Simulations Complex Input & Output NetLogo.
Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.
Week 11 DO NOW QUESTIONS. An ask turtles block is a set of instructions that is issued to every turtle. Even though computers can do things very quickly,
New Mexico Computer Science For All Population Dynamics: Birth and Death Maureen Psaila-Dombrowski.
NetLogo Workshop Complexity And Business Analytics October 10, 2008, UM-Dearborn David Bowen, WSU Physics Slides and model files will.
New Mexico Computer Science For All Interface Input in NetLogo Maureen Psaila-Dombrowski.
An Introduction to NetLogo Gabriel Wurzer, Vienna University of Technology AnthropologischeGesellschaftWien.
New Mexico Computer Science For All Interface Output in NetLogo (Part 1) Maureen Psaila-Dombrowski.
Q4 Day 19 COLQ 201 Multiagent modeling Harry Howard Tulane University.
Week 9 DO NOW QUESTIONS. Question: If the following procedure is executed after 1 turtle is created in the program, what shape is created on the NetLogo.
Functions CS 103. Review A function is a set of code we can execute on command to perform a specific task When we call a function, we can pass arguments.
Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.
New Mexico Computer Science For All Command Procedures in NetLogo Maureen Psaila-Dombrowski.
New Mexico Computer Science For All Creating Turtles Maureen Psaila-Dombrowski.
New Mexico Computer Science For All Patches and Agent/Environment Interactions Maureen Psaila-Dombrowski.
MIS 585 Special Topics in IMS Agent-Based Modeling Bertan Badur Department of Management Information Systems Boğaziçi University.
Principles of programming languages 10: Object oriented languages Isao Sasano Department of Information Science and Engineering.
MIS 585 Special Topics in MIS: Agent-Based Modeling 2015/2016 Fall.
Creating a mystic meg program A simple program asking the user questions and using their answers to build up a fortune telling in a list.
Computer Science 1000 Algorithms III. Multiple Inputs suppose I ask you to write a program that computes the area of a rectangle area = length * width.
M10 WS11:Krankenhausbedarfsplanung The World as We See It given by Gabriel Wurzer and Wolfgang E. Lorenz
Stored Procedures and Functions Pemrograman Basis Data MI2183.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
1 Agent-Based Tools: focus on NetLogo Ing. Cristina Ponsiglione University of Naples Federico II Laboratorio di Simulazione ad Agenti.
M10 WS11:Krankenhausbedarfsplanung More, More and Even-More More given by Gabriel Wurzer and Wolfgang E. Lorenz
Unit 2 Technology Systems
An Introduction to NetLogo given by Gabriel Wurzer and Wolfgang E
AnthropologischeGesellschaftWien
Management Information Systems
What Actions Do We Have Part 1
Creating Simple Agent-Based Models
1-1 Logic and Syntax A computer program is a solution to a problem.
Management Information Systems
Welcome to Computer Science Jeopardy
Functions, locals, parameters, and separate compilation
MIS 643 Agent-Based Modeling and Simulation 2016/2017 Fall.
Functions BIS1523 – Lecture 17.
Programming Right from the Start with Visual Basic .NET 1/e
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Modeling, Coding and good research
creating a ecosystems model in net logo
Presentation transcript:

New Mexico Computer Science For All Variables and Scope Maureen Psaila-Dombrowski

Variables - review Variable: container that holds a value that can be used and changed. Three Steps for Using Variables ▫Declare – allocates the space for the variable and sets the name given to the variable ▫Initialize – set the initial value of the variable ▫Get/Set– Use it in the program or change the value stored in the variable as the program is executed

Types of Variables There are three types of NetLogo variables  Local Variables  Agent Variables  Global Variable Differ in scope of where they can be used  Local – used in the block where declared  Agent – used by specific type of agents  Global – used anywhere in the program

Local Variables Already discussed at length Can only be used in the procedure or command block where it is declared Can be used by any agent How to Use: ▫Declare and initialize local variables using the let command ▫Use the local variable in an expression or ▫Modify a local variable using the set command

Agent Variables Three types of Agent Variables ▫Turtle Variables  Each turtle has its own value for every turtle variable ▫Patch Variables  Each patch has its own value for every patch variable ▫Link Variables  Each link has its own value for every link variable

Built-In Agent Variables ▫Some agent variables are built-in to NetLogo  Turtles: color, heading, xcor, ycor, etc.  Patches: pcolor, pxcor, pycor, etc.  Links: color, shape, etc. User-defined variables ▫Can make user defined agent variables by declaring them at the beginning of the program turtles-own [ energy ] patches-own [ grass? ] links-own [ strength ] Agent Variables

How to use an agent variable ▫Declare the agent variable if necessary ▫Change/modify the variable using the set command ▫Generally can only be used/set by the specific agent  Turtles  Turtle Variables  Patches  Patch Variable  Link  Link Variables

Agent Variables Exceptions ▫An agent can set a different agent's variable by using the ask command. ask patches [……. ask turtle 5 [ set color blue] ;; changes turtle 5’s color to blue …] ▫One agent can read another agent’s variable using the of command show [color] of turtle 5 ;; prints turtle 5’s color ▫A turtle can read and set patch variables of the patch it is standing on directly ask turtles [set pcolor blue] ;;makes patches under all turtles blue

Show program with different types of variables

Global Variables The is only one value of each global variable at any time You can declare a global variable by ▫Using an input device on the interface tab (switch, slider, chooser or input box) ▫In the code by using the globals keyword at the beginning of the code globals [NumTurtles]

Global Variable Can be used and modify ▫At any location in any procedure in the code ▫By any agent Use by using the variable name Modified by the using ▫In the Code with the set command set NumTurtles 100 ▫On the Interface tab with switch, slider, chooser or input box

SIMPLE NETLOGO PROGRAM WITH SLIDER INPUT BOX, SWITCH AND CHOOSER

Summary Variable: container to hold a value To use: Declare, Initialize and Use/Modify Three types: ▫Local Variables ▫can be used by any agent but only in the procedure or block it is declared in ▫Agent Variables ▫Each agent has its own value for each agent variable ▫Used only by that specific agent (exceptions) ▫Global Variables ▫Only one value at any time ▫Used by any agent in any procedure