Students get their first look at the inside of their own video games. They will start development by substituting in new Images, Strings, and Numbers for existing variables.
Substitute new values into existing variables of an existing program and describe the effects.
Examine the structure of an existing program.
Common Core Math Standards
- 6.EE.4: Identify when two expressions are equivalent (i.e., when the two expressions name the same number regardless of which value is substituted into them). For example, the expressions y + y + y and 3y are equivalent because they name the same number regardless of which number y stands for.
Additional standards alignment can be found at the end of this lesson
Activity: The Big Game - Variables
This lesson has three new and important words:
Troubleshooting - when a program generates an unexpected result, a programmer must examine the code to determine the source of the unexpected results (usually an unanticipated input or incorrect handling of an expected input). Sometimes called debugging.
Mod - Short for modification. Games in the real world are often a mod of another game. Othello (or Reversi) is usually considered a mod of the ancient game of “Go”. A mod of a program is one that has been altered to do something slightly different than its original purpose.
Stub - A function whose domain and range have been designated, but the process to transform the domain into the range has not yet been defined.
The students will create a mod of an existing game. As they make changes to the game, it is possible that they will add code that will either “break” the program (cause nothing to happen) or cause an unexpected wutcome. If either of these conditions exist, they will need to troubleshoot or debug the code to determine how to get it working in the proper way. If things go terribly awry and finding a problem is too frustrating, use the Clear Puzzle button in the upper right corner of the workspace. This button will clear your game back to its initial state, so it should only be used as a last resort.
This exercise is a simplified version of a very common real world programming task. Programmers often create mods of programs about which they know very little. They slowly unravel which pieces require further understanding in order to make the mod work the way they want, while leaving other parts of the program completely unexplored.
Many programs and functions are customizable through their arguments (which can be variables or values). When a function is called, its arguments are passed in as variables into the function. In other cases, variables that someone might want to change (sometimes called constants) are often at the top of a piece of code. Having access to the code allows the programmer to change the way the program behaves by setting these variables to different values.
In this lesson, we are creating the mod by changing the variables inside the code. The student has access to the game code and is changing the initial value of the Title, Subtitle, Player, Danger, and Target. As a reminder, the ultimate goal of this game will be to manipulate the player through pressing keys, to avoid the danger, and to make contact with the target. The current lesson has no motion or interactivity. It only changes the look of the game. The motion and interactivity function stubs, such as “update-target” and “danger?”, will be completed in later lessons.
The blocks menu displays a few new items (Boolean, Cond, and Functions) which will be examined in more detail in future lessons. The students should be encouraged to explore each of the sub-menus. However the only navigation required for this level is editing the five color blocks at the top of the function: Title, subtitle, bg (background), player, target, and danger. The difference between the color and black blocks will also be explained in a future lesson.
Activity: The Big Game - Variables
In this stage you'll define and modify variables to changes how some games function. Head to CS in Algebra stage 7 in Code Studio to get started programming.
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.EE.4 - Identify when two expressions are equivalent (i.e., when the two expressions name the same number regardless of which value is substituted into them). For example, the expressions y + y + y and 3y are equivalent because they name the same number regardless of which number y stands for.
- A.SSE.1 - Interpret expressions that represent a quantity in terms of its context.
- A.SSE.2 - Use the structure of an expression to identify ways to rewrite it. For example, see x4 – y4 as (x2)2 – (y2)2, thus recognizing it as a difference of squares that can be factored as (x2 – y2)(x2 + y2).
- A.CED.1 - Create equations and inequalities in one variable and use them to solve problems. Include equations arising from linear and quadratic functions, and simple rational and exponential functions.
- A.CED.2 - Create equations in two or more variables to represent relationships between quantities; graph equations on coordinate axes with labels and scales.
- F.IF.1 - Understand that a function from one set (called the domain) to another set (called the range) assigns to each element of the domain exactly one element of the range. If f is a function and x is an element of its domain, then f(x) denotes the output of f corresponding to the input x. The graph of f is the graph of the equation y = f(x).
- F.IF.2 - Use function notation, evaluate functions for inputs in their domains, and interpret statements that use function notation in terms of a context.
- F.IF.3 - Recognize that sequences are functions, sometimes defined recursively, whose domain is a subset of the integers. For example, the Fibonacci sequence is defined recursively by f(0) = f(1) = 1, f(n+1) = f(n) + f(n-1) for n ≥ 1.
- F.LE.1 - Distinguish between situations that can be modeled with linear functions and with exponential functions.
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.