🚒 Lesson 2: Hunt All the Ships!

βœ… Learning Outcomes

πŸ’‘ Why It Matters

Real games don’t end after one guess! They track score, lives, and progress. Learning to manage game state is how you build Pac-Man, Minecraft, or Roblox games!

Lists and loops are used in every programming language β€” from apps to robots.

⏱️ Lesson Plan (40 minutes)

0–5 min β†’ Review & Goal
β€œLast time: 1 ship. Today: 3 ships and 10 turns!”
Show the enhanced game in action.
5–20 min β†’ Upgrade Your Code
Edit your Lesson 1 file to this:
import random

ships = []
while len(ships) < 3:
    r = random.randint(0, 4)
    c = random.randint(0, 4)
    if [r, c] not in ships:
        ships.append([r, c])

print("3 ships hidden! 10 turns to find them all.")
hits = 0

for turn in range(10):
    print("\nTurn", turn + 1)
    guess_row = int(input("Row (0-4): "))
    guess_col = int(input("Col (0-4): "))
    
    if [guess_row, guess_col] in ships:
        print("🎯 HIT!")
        ships.remove([guess_row, guess_col])
        hits += 1
        if hits == 3:
            print("πŸ† You win!")
            break
    else:
        print("πŸ’¦ MISS!")

if hits < 3:
    print("Game over! You found", hits, "ships.")
    
20–35 min β†’ Level Up!
β€’ Test the game (try to win!)
β€’ 🌟 Challenge 1: Let players use A, B, C for rows!
row_letter = input("Row (A-E): ").upper()
guess_row = ord(row_letter) - ord('A')
β€’ 🌟 Challenge 2: Show how many turns are left!
35–40 min β†’ Play & Reflect
Play your friend’s game! What makes it fun?
β€œNow YOU can make games β€” not just play them!”

🌟 You’re Now a Game Coder!

You’ve learned the core ideas behind almost every game: hidden objects, player input, feedback, and win/lose conditions.