1 / 113

StarLogoTNG

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. Definition of “Agent”. Like a character or object in a game

emelda
Télécharger la présentation

StarLogoTNG

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. StarLogoTNG Treasure Hunt Game Unit Lesson 1: Basic Movement

  2. Today’s Agenda • Starlogo TNG basics • Mini-lesson on programming movement • First programming challenge • Wrap-up

  3. What’s What in SLTNG

  4. Definition of “Agent” • Like a character or object in a game • Can be programmed to have behaviors • Can have more than 1

  5. 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

  6. Your First Program • File menu > Open project “first program.sltng” • File menu > Save project as “first program your initials.sltng” • 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.

  7. 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?

  8. 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)

  9. Programming Activity • Get the highest score possible by programming additional movement instructions when the turtles detect that they’re on a particular color patch

  10. Movement Blocks Found in Movement drawer: • Forward steps • Back steps • Left degrees • Right degrees Dragged onto canvas

  11. 0 degrees 45 degrees 270 degrees 90 degrees 180 degrees 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?

  12. About First Program Setup: Create and scatter 20 turtles Time=60 sec? Yes End No Run: All turtles move 1 step forward Run: Your instructions Run: Calculate score

  13. 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?

  14. 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.

  15. One more thing… • Every time you want to test out your program, click setuponce (turtles created and scattered) and then runonce (wait for green highlight around the run block). • Use the blue slider bar to speed up or slow down the program.

  16. Programming Tip To delete a block, drag it to the trash can in the corner of the canvas

  17. Programming Tip Save often. Save now.

  18. Wrap Up

  19. StarLogoTNG 101 Treasure Hunt Game Unit Lesson 2: Treasures and Hazards

  20. Today’s Agenda Review Mini-lesson on breed editor and new programming blocks Modify first program Wrap-up

  21. Review What do you predict will be the agent’s movement when it executes the following block? What about this stack of blocks?

  22. Breed Editor Click “Edit Breeds” button near top of canvas to bring up the editor. Used to assign “shapes” and names to breeds. Breeds are used to create different types of agents. Each breed has its own set of programs and blocks (or block section). Exercise: Click “new” button and rename the newly created agent to “treasure” and select a new shape.

  23. New Block: Setup Found in the “Setup and Run” drawer Used to set initial conditions of the game Example: what happens in first program when you click on setup? Brainstorm starting conditions for your treasure game

  24. New Blocks: Clear Found in the “Setup and Run” drawer “Clear everyone” makes all agents disappear You can learn about the other clear blocks in your reference guide Look at the setup block in first program. Why is it important to include “clear everyone” in setup? What do you think will happen if you remove this block? Make a prediction and test it!

  25. New Blocks: Create Create is used to create agents of a particular breed. Because it is specific to each breed, these blocks are found in the “My Blocks” palette. On the “My Blocks” palette, each drawer is named for a breed or a section of the canvas. Select the breed you want to create agents of, and look for the “Create breed name” block. This block takes a number argument that specifies how many agents you want to create. There is also a “Create breed name” that has two parts – the number of agents and a “do” section. The “do” section allows you to specify additional instructions, such as placement of the agent in spaceland and setting the camera angle.

  26. New Block: Scatter Located on the “My Blocks” palette Found in each breed’s drawer Usually used after agents are created to place them randomly in spaceland There is also a “scatter everyone” block in the Setup drawer for scattering all agents that have been created, regardless of breed.

  27. Guided Programming 1 In the existing setup block, attach the appropriate blocks to create 10-20 treasure agents and scatter them. Test out your new setup by clicking setup in the runtime window.

  28. New Block: Collision Found in each breed’s drawer in the “My Blocks” palette Used to determine what happens when one agents touches another agent What happened in second program when the player agent collided with a tree agent?

  29. New Block: Die Found in the “Logic” drawer The agent that runs the block deletes itself (disappears completely from Spaceland). How do you think this block was used in the second program?

  30. Guided Programming 2 Drag a collision block that shows “treasure” and “turtles” onto the collisions section of the canvas Think: what do you want to happen when the turtle collides with the treasure? Explore different possible results for collision. Use blocks that you already know, such as set color*, set size, movement blocks, die, and set score. *To see an agent’s color, you also need to use the block “model skin off” found in traits.

  31. Programming Activity Create a new breed for Hazards Add create and scatter hazards to setup. Think: what do you want to happen when the player collides with a hazard? Explore different possible results for collision (check out the reference guide for new blocks or explore new blocks on your own).

  32. Wrap Up

  33. Review What is the purpose of the Setup block? What blocks typically go in the Setup block? If you don’t put a “scatter” block, where are the agents placed when you create them? Program a collision block between turtle and treasure agents so that the treasure moves up into the air 1 step and change its color to purple.

  34. StarLogoTNG 101 Treasure Hunt Game Unit Lesson 4: Forever and Procedures

  35. Today’s Agenda Review Mini-lesson on new programming blocks Create v1 of treasure hunt game Wrap-up

  36. Programming Tip Use the canvas sections to keep your program organized

  37. Programming Tip Use the mini-map on the upper right corner of the canvas to quickly navigate to different sections of your program.

  38. Treasure Game v.1 File menu > Open Project > “treasure game” Save as “treasure game your initials.sltng” About the treasure game Setup: creates 1 player agent; creates treasure agents and non-moving hazards agents Run (forever): player agent(s) calls a procedure that executes movementwhen theplayer presses various keyboard keys to control the player agent from 1st person point of view Collisions: between player and treasure and hazard agents

  39. Guided Programming 1: Setup Breed Editor: Rename turtle breed to “player” (or your choice) and select a new character Make new breed called “treasure” (or your choice) Make new breed called “hazard” (or your choice) Drag setup block to setup section of canvas Attach “clear everyone” block Create 1 player agent Create treasure and hazard agents and randomly scatter them Click on setup in runtime window to check that the setup does what you want.

  40. New Block: If / then Found in the “Logic” drawer First part (“test condition”) must evaluate to true or false If test condition is true, the blocks in the “then” section is executed. If false, ignore the “then” section. Example: see first program

  41. Exercise: If / then block What do you think these IF blocks will do when executed by an agent? Explain your thinking.

  42. New Blocks: Keyboard detect Found in the “Controls” drawer. Question mark means that the blocks tests if that particular key is pressed – evaluates to true or false. Click on down arrow on the right side of the block to select a different keyboard key to test.

  43. Programming Activity 1 Program instructions to control the agent’s movement from the agent’s point of view: Up arrow key = move forward Left arrow key = turn left Right arrow key = turn right Down arrow key = move backward

  44. New Block: Forever Found in the “Setup and Run” drawer Repeats instructions placed in this block over and over again, in order from top to bottom, and then starts at the top again. Each breed has its own section. Turn on/off by clicking on the green arrow Can also run from runtime window

  45. Guided Programming 2: Forever Drag a Forever block to the runtime section of canvas. Rename the Forever block “Run.” Attach the If/then keyboard controls stack to the Player section of the Run block. Turn on the Run block and test the keyboard controls. What would happen if you move the Keyboard Controls stack to the treasure section?

  46. Do Now: Set Agent Camera, ID, and views In first person games, it’s helpful to start the game from the player’s perspective. You do this using the following blocks when you create the player agent in Setup:

  47. About Procedures Recall the cake making analogy: procedures are like those sub-tasks (make the batter, bake the cake, decorate the cake) Procedures make programs easier to build and to understand.

  48. New Block: Procedure Guided Programming 3: Make a procedure of the keyboard movement controls that are currently in the player section of the run block. Replace those instructions with a call to the procedure. To make (or “define”) a procedure: Position your canvas in the Player section. Drag a green “procedure” block from the “Procedure” drawer. Rename the procedure “keyboard controls.” Drag the if/then blocks and connect them to the procedure block.

  49. New Block: Procedure To “call” a procedure is to use a block with the procedure’s name; the procedure’s instructions are executed in the place where it’s called. Each breed and programming section has its own procedures (found in “my blocks” palette). To call the “keyboard controls” procedure: Go to the “my blocks” palette and open the “Player” drawer. Find the procedure that’s labeled “keyboard controls” and drag it to the empty player section of the run block. Start the run block to make sure that the keyboard controls are working properly.

  50. New Blocks: Score Score is a variable. This means that it represents a number that can change. You can change the value of score using set score, found in the “Setup and Run” palette. Set score takes either a single number or a mathematical expression that is evaluated to a single number. For example, if you want to increase the score, you can drag out the addition block from the “Math” palette. The pink score block represents the current value of score. Drop that in the left side of the expression. Drag a pink number block on the right side of the expression and change the number to the amount you want the score to increase. You can also change the sign of the math expression block by clicking on the down arrow next to the operator symbol. Think: What are some ways to use score in your treasure game? When should the score be changed?

More Related