16
CS in Algebra | Lesson 16

# The Big Game - Booleans

Lesson time: 30-60 Minutes

## Lesson Overview

Using the same logic from the previous lesson, students will write code that checks whether their Target and Danger sprites have left the screen. If their function determines that a sprite is no longer visible on screen, it will be reset to the opposite side.

## Lesson Objectives

### Students will:

• Use Boolean operators to compare values.

• Apply Boolean logic, such as AND, OR, and NOT, to compose complex Boolean comparisons.

## Anchor Standard

### Common Core Math Standards

• 6.EE.9: Use variables to represent two quantities in a real-world problem that change in relationship to one another; write an equation to express one quantity, thought of as the dependent variable, in terms of the other quantity, thought of as the independent variable. Analyze the relationship between the dependent and independent variables using graphs and tables, and relate these to the equation. For example, in a problem involving motion at constant speed, list and graph ordered pairs of distances and times, and write the equation d = 65t to represent the relationship between distance and time.

Additional standards alignment can be found at the end of this lesson

# Teaching Guide

## Getting Started

### 1) Introduction

Let's get back into that Big Game that we started in stage 7 and continued in stage 12.

When we last worked on the game, our danger and target were moving off the screen in opposite directions. Unfortunately, their update functions move them in one direction forever, so they never come back on screen once they've left! We'd actually like them to have a recurring role in this game, so we'll use some boolean logic to move them back to their starting points once they go off screen.

Once the students correctly implement on-screen? (and its sub-parts safe-left? and safe-right?), the new behavior of target and danger is that once they are off the screen they return to their starting position but with a new y-value. From this new vertical position they will continue to move across the screen. If one (or both) of the characters go off the screen and never reappear, the most likely source of the error is that one of the newly implemented boolean statements is incorrect.

## Activity: The Big Game - Booleans

### 2) Online Puzzles

Return to your Big Game to use Booleans to keep your player character on screen. Head to CS in Algebra stage 16 in Code Studio to get started programming.

Standards Alignment

### Common Core Math Standards

• 5.OA.1 - Use parentheses, brackets, or braces in numerical expressions, and evaluate expressions with these symbols.
• 5.OA.2 - Write simple expressions that record calculations with numbers, and interpret numerical expressions without evaluating them. For example, express the calculation “add 8 and 7, then multiply by 2” as 2 × (8 + 7). Recognize that 3 × (18932 + 921) is three times as large as 18932 + 921, without having to calculate the indicated sum or product.
• 6.NS.8 - Solve real-world and mathematical problems by graphing points in all four quadrants of the coordinate plane. Include use of coordinates and absolute value to find distances between points with the same first coordinate or the same second coordinate.
• 6.EE.9 - Use variables to represent two quantities in a real-world problem that change in relationship to one another; write an equation to express one quantity, thought of as the dependent variable, in terms of the other quantity, thought of as the independent variable. Analyze the relationship between the dependent and independent variables using graphs and tables, and relate these to the equation. For example, in a problem involving motion at constant speed, list and graph ordered pairs of distances and times, and write the equation d = 65t to represent the relationship between distance and time.
• 7.EE.4 - Use variables to represent quantities in a real-world or mathematical problem, and construct simple equations and inequalities to solve problems by reasoning about the quantities.
• 8.F.1 - Understand that a function is a rule that assigns to each input exactly one output. The graph of a function is the set of ordered pairs consisting of an input and the corresponding output.1
• 8.F.2 - Compare properties of two functions each represented in a different way (algebraically, graphically, numerically in tables, or by verbal descriptions). For example, given a linear function represented by a table of values and a linear function represented by an algebraic expression, determine which function has the greater rate of change.

### Common Core Math Practices

• MP.1 - Make sense of problems and persevere in solving them.
• MP.2 - Reason abstractly and quantitatively.
• MP.3 - Construct viable arguments and critique the reasoning of others.
• MP.4 - Model with mathematics.
• MP.5 - Use appropriate tools strategically.
• MP.6 - Attend to precision.
• MP.7 - Look for and make use of structure.
• MP.8 - Look for and express regularity in repeated reasoning.

Derived from