🎯Calibrate
1Fill-in
2Debug
3Extend
4Create
🧠Concept
📓Reflect
👤 Your Details REQUIRED — fill in before you begin (★ = required)
🎯 Before You Begin Calibration Check 2 questions + 1 reflection — unlocks Tier 1
Think about how the snake changes direction: what variable stores it, how key presses update it, and why you must prevent reversing direction (going straight back into yourself).
1 10 5
Tier 1 Fill in the Blanks Complete the code skeleton — 10 blanks

Complete the direction-control system. Fill each blank so the snake responds to arrow keys and moves correctly.

direction = ▢1   # starting direction

for event in pygame.event.get():
    if event.type == pygame.▢2:
        if   event.key == pygame.K_UP    and direction != ▢3:
            direction = "UP"
        elif event.key == pygame.K_DOWN  and direction != ▢4:
            direction = "DOWN"
        elif event.key == pygame.K_LEFT  and direction != ▢5:
            direction = "LEFT"
        elif event.key == pygame.K_RIGHT and direction != ▢6:
            direction = "RIGHT"

hx, hy = head_x, head_y
if   direction == "UP":    hy ▢7= 1
elif direction == "DOWN":  hy ▢8= 1
elif direction == "LEFT":  hx ▢9= 1
elif direction == "RIGHT": hx ▢10= 1
1.Blank 1: "______
2.Blank 2: K______
3.Blank 3: "_____
4.Blank 4: "___
5.Blank 5: "______
6.Blank 6: "_____
7.Blank 7: _
8.Blank 8: _
9.Blank 9: _
10.Blank 10: _
Tier 2 Find & Fix the Bugs 3 bugs to correct

The direction-control code below has 3 bugs. Type the corrected line for each.

direction = "RIGHT"

for event in pygame.event.get():
    if event.type == pygame.KEYDOWN:
        if   event.key == pygame.K_UP   and direction != "UP":   # Bug 1
            direction = "UP"
        elif event.key == pygame.K_DOWN and direction != "DOWN": # Bug 1 (same guard issue)
            direction = "DOWN"

hx, hy = head_x, head_y
if   direction == "UP":    hx -= 1   # Bug 2 – wrong axis
elif direction == "DOWN":  hx += 1   # Bug 2
elif direction == "LEFT":  hx -= 1
elif direction == "RIGHT": hx += 1
# Bug 3: elif chains missing – only first matching if fires
if direction == "LEFT": hx -= 1

Bug 1

Buggy line:

if event.key == pygame.K_UP and direction != "UP":

Your fix:

Hint: What direction would reverse the snake going UP? The guard should block that opposite.

Bug 2

Buggy line:

if direction == "UP": hx -= 1

Your fix:

Hint: Moving UP changes the row (y), not the column (x).

Bug 3

Buggy line:

if direction == "LEFT": hx -= 1 # (second standalone if)

Your fix:

Hint: Without elif, every matching branch executes — the snake double-moves. Use elif.

Reflection 2 Mid-Point Check-In
Tier 3 Extend the Code Add the feature described below

Add **WASD controls** alongside the arrow keys so either set works. Both should respect the opposite-direction guard.

direction = "RIGHT"

for event in pygame.event.get():
    if event.type == pygame.KEYDOWN:
        # Arrow keys already handled:
        if   event.key == pygame.K_UP    and direction != "DOWN":  direction = "UP"
        elif event.key == pygame.K_DOWN  and direction != "UP":    direction = "DOWN"
        elif event.key == pygame.K_LEFT  and direction != "RIGHT": direction = "LEFT"
        elif event.key == pygame.K_RIGHT and direction != "LEFT":  direction = "RIGHT"
        # YOUR CODE: add W/A/S/D handling here
Tier 4 Create from Scratch Open-ended challenge

**Challenge:** Replace the `if/elif` chain with a **dictionary lookup**. Define a dict that maps each key constant to a `(new_direction, forbidden_opposite)` pair, then use it to update direction in two lines of code. Paste your solution.

🧠 Concept Check Test Your Understanding 5 quick questions — required before the Reflective Journal 🔒

Answer all 5 questions, then the Reflective Journal will unlock.

1. How is the snake's current direction typically stored in the game?

2. What condition prevents the snake from reversing directly?

3. if event.type == pygame.KEYDOWN: — what does this test?

4. Which direction vector moves the snake one cell to the RIGHT?

5. What should happen if the player presses the LEFT key while the snake moves RIGHT?

📓 Reflective Journal 5 prompts — required before Step 3 is marked complete 🔒

Answer each prompt thoughtfully. There are no right or wrong answers — this is your own reflection.

🎯 Post-Activity Check-In After Completing All Tiers Complete after the Reflective Journal to finish this step 🔒
1. How confident do you feel about this step’s concepts now? (1 = not confident, 10 = very confident)
1 10 5
2. Your Tier 1 first-attempt score (auto-filled)
%