1/32 StarLogo Andrew Begel University of California, Berkeley Agent Simulation Workshop October 16, 1999 Building a Modeling Construction Kit for Kids The StarLogo Team at MIT: Prof. Mitchel Resnick Brian Silverman Andrew Begel Bill Thies Vanessa Colella
32
Embed
1/32 StarLogo Andrew Begel University of California, Berkeley Agent Simulation Workshop October 16, 1999 Building a Modeling Construction Kit for Kids.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1/32
StarLogo
Andrew BegelUniversity of California, Berkeley
Agent Simulation WorkshopOctober 16, 1999
Building a Modeling
Construction Kit for Kids
The StarLogo Team at MIT:Prof. Mitchel ResnickBrian SilvermanAndrew BegelBill ThiesVanessa Colella
2/32
Big Ideas
• StarLogo: a programmable modeling environment
• Intended for non-expert users and non-programmers– Great for kids, great for researchers!
• Emphasis on decentralized behaviors with local interactions.
3/32
Talk Outline
• History of StarLogo
• Models of Parallelism
• Parallel Communication
• Parallel Debugging
• StarLogo Workshop
• StarLogo for Java
4/32
History
• 1990’s: *Logo on the Connection Machine 2 (a massively parallel computer)
• 1994: MacStarLogo on 68K and PPC Macs• 1999: StarLogo in Java
5/32
Logo
• Developed by Feurzeig and Papert in 60’s
• Based on Lisp– simpler syntax– incorporates elements of natural language.
• Interactive programming environment
6/32
Turtle Logo
• Turtle can move around a grid-based world.
• The turtle is an “object to think with.”– body syntonics
• Example Code:
to squarependownrepeat 4 [forward 10 right 90]end
7/32
StarLogo• Thousands of turtles instead of
just one (can be organized in groups called breeds).
• Background grid of patches can run Logo code.
• The user is the observer and can discover and modify global characteristics of the model.
8/32
time
1 2 43 5
StarLogo Parallelism
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Job #2
Job #1
9/32
1 2 43 5
CM2 *Logo Parallelism (SIMD)
Turtles run commands in lockstep.Each job executes in series.
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1 Cmd #1 Cmd #1 Cmd #1 Cmd #1
Cmd #2 Cmd #2 Cmd #2 Cmd #2 Cmd #2
Cmd #3 Cmd #3 Cmd #3 Cmd #3 Cmd #3
Cmd #5 Cmd #5 Cmd #5 Cmd #5 Cmd #5
Cmd #6 Cmd #6 Cmd #6 Cmd #6 Cmd #6
Cmd #4 Cmd #4 Cmd #4 Cmd #4 Cmd #4
timeJob #2
Job #1
10/32
Simulating Parallelism
• How do you simulate parallelism on a computer with one processor?
• Our goal is realistic looking parallelism.– Preemptive multi-threading
• Switch threads every n milliseconds.
– Cooperative multi-threading• Switch threads at carefully chosen program points.
• Fine-granularity vs. coarse granularity
• We context switch after each command, but not each reporter.
11/32
1 2 43 5
MacStarLogo Parallelism
Each job executes in series.Turtles are switched one after another.
Turtles may get out of sync.
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Cmd #6
Cmd #5
Cmd #4
Cmd #3
Cmd #2
Cmd #1Cmd #1
Cmd #2
Cmd #3
Cmd #5
Cmd #6
Cmd #4
Cmd #3
time
12/32
time
1 2 43 5
All jobs are scheduled in parallel.Commands are switched one after another.
to procreateif breed = girls [grab one-of-guys-here [set father-color color-of partner set child-gene combine mygene mygene-of partner hatch [ifelse (random 2) = 0 [set breed guys] [set breed girls] set mygene child-gene set color father-color]]]end
28/32
Parallel Debugging
• In MacStarLogo, with 2000 turtles, how do you figure out if something went wrong?
• Stack overflow (too many nested functions) and divide by zero in turtles and patches are ignored.
• Unexpected behaviors due to not knowing how the compiler interpreted your code.
• Look at turtle or patch state:– Oops, no print capability for turtles or patches.
– Use turtle monitors to view all variables for a turtle.
– Use command center to ask turtles or patches to set observer variables (or set turtle variables that are visible from the turtle monitor).
29/32
Parallel Debugging (2)• Java StarLogo
o Simpler programming model (separate turtle and observer procedures) to eliminate certain kinds of programming bugs.
– Turtles and observer can use print (output shows up in the appropriate command center).
– Runtime errors in turtles and observer pop up in a dialog box.
• (What happens if all 2000 turtles have the error? 2000 dialog boxes?)
– Much better compiler error messages. They even report the line number of the error!
– Turtle monitors and patch monitors will be added soon.
30/32
StarLogo for Java: New Features
• Works on PC, Mac and Unix!• Rectangular (non-square) patch grid.• Turtles and observer can play sounds.• (count, one-of, list-of)-(turtles, breeds)-(here, at,
towards) reporters.• 64-bit double math.• Unlimited number of turtles and number of variables.• All math and list operations work for both turtles and observer.• New primitives: case, let, loop, wait-until, random-