August 31 Intro to CS.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

1 An intro to programming concepts with Scratch Session 3 of 10 sessions Repetition and variations.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Using the File Manager WebCT 6. Understanding File Manager The File Manager is the area where all course files are stored. Whenever you link a file in.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Summer Computing Workshop. Session 4 Loops  At the heart of their functionality, loops enable blocks of code to be executed more than once  Loops represent.
Programming Logic Program Design. Objectives Steps in program development Algorithms and Pseudocode Data Activity: Alice program.
In.  This presentation will only make sense if you view it in presentation mode (hit F5). If you don’t do that there will be multiple slides that are.
Programming & Scratch. Programming Learning to program is ultimately about learning to think logically and to approach problems methodically. The building.
InDesign CS3 Lesson 4 ( Only pages ) Importing and Editing Text.
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
ACO 101 Making a program. mb_your_brain_on_improv.html mb_your_brain_on_improv.html.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Working with Loops, Conditional Statements, and Arrays.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Input Boxes, List Boxes, and Loops Chapter 5. 2 Input Boxes Method for getting user’s attention to obtain input. InputBox() for obtaining input MessageBox()
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
Perfecto Mobile Automation
Vex Robotics program three: using motors and sensors together.
Intro CS – Logic & Operators Lesson Plan 5. Goals  Students can explain basic logical operators  AND, OR, NOT  Students can create truth tables for.
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Functions / Blocks.
Review for Final June 13, 2016.
Scratch Programming Cards
FOP: While Loops.
August 25 Intro to CS.
Development Environment
Create a Halloween Computer Game in Scratch
Intro CS – Screens and Variables
Programming & Scratch.
Scratch for Interactivity
WORKSHOP 2 VALVETRAIN MECHANISM
WORKSHOP 2 VALVETRAIN MECHANISM
BIT116: Scripting Loops.
Scratch Unit Overview We are going to look at computer programming and how to create your very own computer game The piece of software we will be using.
Intro to CS Sept 22/23, 2015.
Understanding the Geometric Shape Code
ECS10 10/10
PowerPoint Activity 5: To Be Determined…
ECS 9/7/17.
August 30 Intro to CS.
Chapter 5 Decisions. Chapter 5 Decisions ssential uestion: How are Boolean expressions or operators used in everyday life?
Intro to CS Monday, August 29
Unit 2 Getting Started With
Intro to CS Monday, August 24
Scratch for Interactivity
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Introduction to Object-Oriented Programming
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Go to =>
Introduction to TouchDevelop
Go to =>
Go to =>
Unit 3: Intro to Programming Snap! Introduction
ICT Programming Lesson 3:
Variables & getting info from the user
BIT116: Scripting Lecture 6 Part 1
Selection Statements Chapter 3.
creating a ecosystems model in net logo
How to allow the program to know when to stop a loop.
Restricting Events Creating Conditional Events in Alice By Henry Qin
Presentation transcript:

August 31 Intro to CS

Today’s Objectives Hand in Homework Assignment Review last class Today If/Then/Else Parallelism Debugging How to deal with SNAP! edges

Review: Make Block or Right click on empty space in Script Area this dialog box will appear. or Press “Make Block” button in Variables and this dialog box will appear.

Two “Looks” commands – goto front , go back N layers Front, -2 layers Front, -1 layer Front layer With these 2 commands, you can control where the scenery resides.

Stage scripting Click on Stage icon Scripts just like for Sprites Broadcast messages This runs Mario Sprite only which is useful for debug

Today’s Objectives Hand in Homework Assignment Review last class Today Loops: If; If/Else; Repeat; Forever Parallelism Debugging How to deal with SNAP! edges

“Loops”: If/Else/Repeat Notice how the bottom is flat? This script ends here and does not move on. The contents inside will repeat until the condition is met. Repeat the # of times in the box. Then moves to the next block Executes if evaluation of Boolean expression is True. If not, it moves to the next block. Executes if evaluation of Boolean expression is True. If not, it executes the contents of “else”.

Lab: Model the ‘aRoomLightOn’ Boolean expression in SNAP Lab: Model the ‘aRoomLightOn’ Boolean expression in SNAP! (aRoomLightOn = pgePower AND (floorLamp OR tableLamp ) Create three variables: pgePower, floorLamp, tableLamp Initialize all three variables to be ‘false’ Say “The variables are initialized.” Broadcast a “Initialized” message Start when “initialized” message is received Create a Boolean expression that tests each variable for “true” Use an If/Else statement If expression = “true”, say, “The light is on” If expression is not = “true”, think, “Hmmm. I wonder when the light will turn on.”

Lab: ANSWER

Parallelism ( also called threads) These are 5 different streams of instructions/code also called threads. Program Counter can’t be in 5 different places at the same time!! SNAP executes a few instructions in one stream and then moves to the next. 1 GHz = 1,000,000,000 instructions in 1 second Makes it appear that each stream/thread is executed simultaneously.

Debugging A methodical process of finding and reducing the number of defects (bugs) in a computer program, making it behave as expected. 

You need to know where the program stops working. Debugging Who do you find them? You need to know where the program stops working. How do you do that?

Debugging Here are a couple methods: Insert a block before and after the section of code that you think has the problems. (Be sure and remove them after you have solved the problem.)

Debugging You can also isolate the problem by running just he block or script itself. Click on the block or script. Duplicate the block to get it out of the script.

Debugging Finally, you can display global, local and system variables on the stage.

Debugging - Help Right click on desired instruction. Pops up a drop-down menu. Click on “help”.

Debugging - Help The Help dialog box pops up. Has and explanation and ... A code example!!!

Lab: Debug ‘August31Labs - aRoomLightOn’ (There are 3 bugs planted.) Type this into your browser, all on one line with no spaces or breaks: http://snap.berkeley.edu/snapsource/snap.html# Username=johngoble&ProjectName=Aug31Labs-v3

Lab: Debug ‘PowerOnLabs’-ANSWER

Dealing with EDGES in Mario – using Blocks, of course Let’s write some code which deals with a Sprite at the edge. Two choices – The Sprite can wrap or bounce.

Dealing with EDGES in Mario continued Question: Why use a CustomBlock rather than a stack of SNAP! blocks from the palette?

Dealing with EDGES in Mario continued Question: Why use a CustomBlock rather than a stack of SNAP! blocks from the palette? Answer: A stack of SNAP! blocks from the palette requires me to cut and paste the stack 4 times for each of the 4 Sprit I must fix a bug in 4 places instead of 1 place: Custom Block Also, 4 Stacks of the same code consumes too much screen area

Edges - Make Block Dialog box appears Give it a name Press OK Right click in Script area/Press MakeBlock button Dialog box appears Give it a name Press OK

Edges continued Click on “+” sign Name the input - bWrap LowerCase “b” reminds me it’s Boolean i.e. true or false. – not a number Click OK

Edge Logic bWrap = true If past Right Edge  Wrap If not  do nothing bWrap = false Let SNAP make it bounce. Click OK  

Reminder of Stage Geometry

Test it!! I used “MakeVariable” to create 3 variables – LeftEdge RightEdge bWrapOrBounce Why is the “move 2 steps” not inside the CustomBlock? Let’s see it work!

Demo

Edge exercise - get ready Question: Why should CustomBlock be global but variable bWrapOrBounce be local?

Edge exercise - get ready Question: Why should CustomBlock be global but variable bWrapOrBounce be local? Answer : CustomBlock should be global so Mario, Tree , Gremlin and Mountain can use it. bWrapOrBounce should be local( this Sprite only) so that each Sprite can have individual behavior at the edge – Wrap or Bounce.

Lab: Edge exercise – 30 minutes Extend my example to both left and right edges. Your code should be able to Wrap or Bounce based on an input variable. When your code works “Save it” so you can use it on your Mario projects.

Open Lab Work on your project

Review of Today’s Topics Loops: If; If/Else; Repeat; Forever Custom Block w/input for Edge behavior Debugging

Reminders Read Chapter 2* before the start of class on Monday, September 12 *NOT just the excerpt http://www.bitsbook.com/ Test will be Friday, Sept 9 on computer parts and SNAP!