StarLogoTNG Treasure Hunt Game Unit Lesson 1: Basic Movement
Today’s Agenda Starlogo TNG basics Mini-lesson on programming movement First programming challenge Wrap-up
What’s What in SLTNG Programming Window –Palette of “blocks” –Canvas Spaceland Runtime Window
Definition of “Agent” Like a character or object in a game Can be programmed to have behaviors Can have more than 1
First Programming “Blocks” Give an agent behavior instructions by dragging blocks from the palette onto the canvas Many blocks take arguments An agents “executes” an instruction when the agent does what the instruction says Arguments
Your First Program File menu > Open project “first program.sltng” File menu > Save next version In runtime window, click once on “set up” and then “run” to start the program. The program will end after 60 seconds. Repeat to run the program again. Practice: run the game a few times, move around in spaceland and try different camera angles using the Guide to Spaceland activity sheets.
About First Program What did you notice about how first program works? –How did the score change? What do you think the score is based on? –How did the turtle agents behave? What happened when they reached the edge of Spaceland?
How Score is Calculated The score is the running added total of the height of each patch that a turtle is standing on. Green patches = 0 (no effect on score) Blue patches = negative (varies) Red patches = positive (fixed) Yellow patches = positive (varies)
Programming Activity Get the highest score possible by programming additional movement instructions when the turtles detect that they’re on a particular color patch
Movement Blocks Found in Movement drawer: Forward steps Back steps Left degrees Right degrees Dragged onto canvas
Quick geometry review! How many degrees are there in a circle? Degrees for turning left or right are relative to the direction the turtle is currently facing – for example, the labels in the diagram on the right shows the degrees for turning right. What should be the degree labels if we’re turning left? 0 degrees 90 degrees 180 degrees 270 degrees 45 degrees
About First Program Setup: Create and scatter 20 turtles Run: All turtles move 1 step forward Run: Your instructions Run: Calculate score Time=60 sec? End No Yes
Programming Activity 1 Get the highest score possible by programming additional movement instructions when the turtles detect that they’re on a particular color patch For example, how should the turtle behave if it detects that it’s standing on a blue patch?
Programming Activity Try out different commands and sequences; see what happens to the score each time. There are many ways to achieve a high score. Try to use as few blocks as possible.
One more thing… Every time you want to test out your program, click setup once (turtles created and scattered) and then run once (wait for green highlight around the run block). Use the blue slider bar to speed up or slow down the program.
Programming Tip To delete a block, drag it to the trash can in the corner of the canvas
Programming Tip Save often. Save now.
Wrap Up What strategies did you try? What worked? What didn’t work? What challenges did you have? What was fun? What questions do you have?
To get StarLogo TNG for your home computer Website: Register, download, install