Intermediate — Day 5
Full-Feature Reference
Day Schedule
Online
| Time | Activity |
|---|---|
| 10:00 | AI Day Intro Frame AI as a coding partner — understand every line before using it |
| 10:15 | Prompt Demo Live demo: paste Day 4 code, request a score display, walk through result |
| 10:35 | Breakout Groups Students extend snake with AI help |
| 11:00 | Break |
| 11:10 | Breakout Groups Continue + polish |
| 11:30 | Post-Assessment Link provided separately |
| 11:50 | Show & Tell |
| 12:20 | Closeout |
In-Person
| Time | Activity |
|---|---|
| 8:00 | AI Day Intro Frame AI as a coding partner — understand every line before using it |
| 8:20 | Prompt Demo Live demo: paste Day 4 code, request a score display, walk through result |
| 8:50 | Breakout Groups Students extend snake with AI help |
| 9:40 | Break |
| 9:50 | Breakout Groups Continue + polish features |
| 11:00 | Post-Assessment Link provided separately |
| 11:20 | Show & Tell |
| 11:50 | Open Coding / Overflow Finish up or start a second AI extension |
| 12:10 | Meetup Beginner group joins |
| 12:20 | Closeout |
Learning Objectives
- Use AI to add one feature to the snake game
- Read and explain every line of AI-generated code before using it
- Demo the extended game in show & tell
Complete Reference Snake
# INSTRUCTOR — Day 5: AI-Assisted Customization (Intermediate)
# -----------------------------------------------
# TEACH: No new Python concepts today. Students use AI to extend their snake game.
# Your role: circulate and verify students understand generated code before using it.
# Ask: "What does this line do?" If they can't answer, send them back to the AI to ask.
#
# DEMO SEQUENCE (do this at the start before students work independently):
# 1. Paste the Day 4 snake code into the AI.
# 2. Prompt: "Add a score display to my snake game. Show the current score
# at the top of the screen using a pen turtle."
# 3. Walk through every line of the generated code with the class.
# 4. Paste it in live and show it working.
#
# REFERENCE: complete snake game with all AI-assisted features added
import turtle
import time
import random
screen = turtle.Screen()
screen.title("Snake Game")
screen.bgcolor("black")
screen.setup(width=600, height=600)
screen.tracer(0)
head = turtle.Turtle()
head.shape("square")
head.color("white")
head.penup()
head.goto(0, 0)
food = turtle.Turtle()
food.shape("circle")
food.color("green")
food.penup()
food.goto(random.randint(-270, 270), random.randint(-270, 270))
# AI feature: score display
pen = turtle.Turtle()
pen.penup()
pen.hideturtle()
pen.color("white")
pen.goto(0, 270)
score = 0
high_score = 0
def update_score():
pen.clear()
pen.write("Score: " + str(score) + " High: " + str(high_score),
align="center", font=("Courier", 18, "bold"))
update_score()
bodysegments = []
# AI feature: speed scaling
currentspeed = 0.1
def got_food():
global score, currentspeed
food.goto(random.randint(-270, 270), random.randint(-270, 270))
new_seg = head.clone()
bodysegments.append(new_seg)
score += 1
currentspeed *= 0.95 # AI feature: speed up slightly on each eat
update_score()
def go_up():
if head.heading() != 270:
head.setheading(90)
def go_down():
if head.heading() != 90:
head.setheading(270)
def go_left():
if head.heading() != 0:
head.setheading(180)
def go_right():
if head.heading() != 180:
head.setheading(0)
screen.listen()
screen.onkeypress(go_up, "Up")
screen.onkeypress(go_down, "Down")
screen.onkeypress(go_left, "Left")
screen.onkeypress(go_right, "Right")
halfSize = 290
def reset_game():
global score, currentspeed, high_score
if score > high_score:
high_score = score # AI feature: high score persists across resets
score = 0
currentspeed = 0.1
head.goto(0, 0)
head.setheading(0)
for seg in bodysegments:
seg.hideturtle()
bodysegments.clear()
update_score()
# AI feature: bad food that resets the game
badfood = turtle.Turtle()
badfood.shape("circle")
badfood.color("red")
badfood.penup()
badfood.goto(random.randint(-270, 270), random.randint(-270, 270))
while True:
screen.update()
for i in range(len(bodysegments) - 1, 0, -1):
bodysegments[i].goto(bodysegments[i - 1].pos())
bodysegments[i].setheading(bodysegments[i - 1].heading())
if len(bodysegments) > 0:
bodysegments[0].goto(head.pos())
bodysegments[0].setheading(head.heading())
head.forward(20)
if head.distance(food) < 20:
got_food()
if head.distance(badfood) < 20: # bad food resets
badfood.goto(random.randint(-270, 270), random.randint(-270, 270))
reset_game()
for seg in bodysegments:
if head.distance(seg) < 15:
reset_game()
break
if (head.xcor() > halfSize or head.xcor() < -halfSize or
head.ycor() > halfSize or head.ycor() < -halfSize):
reset_game()
time.sleep(currentspeed)