Loop of Learning Slides THE LOOP OF LEARNING
Introduction to Reinforcement Learning
The Blind Challenge
The Scenario
One student is "The Bot" (blindfolded).
The other is "The Environment."
The Bot must find a hidden object.
The Feedback
You can ONLY say two words:
COLD
WARMER
How did the "Bot" learn where to go?
What is Reinforcement Learning?
A type of Machine Learning where an AI agent learns to make decisions by performing actions in an environment to achieve a maximum reward.
Supervised
Learning from examples (labeled data).
Unsupervised
Finding patterns in data.
Reinforcement
Learning from trial and error!
The Anatomy of the Loop
Agent
The "Learner" or decision maker.
ACTION
REWARD & STATE
Environment
The world the agent interacts with.
STATE: Where the agent is NOW.
ACTION: What the agent DOES.
REWARD: Feedback (Positive or Negative).
Case Study: Mario
Level 1-1
Game Environment
Agent: Mario (the AI player)
State: Pixel positions, enemy locations
Actions: Jump, Run Left, Run Right
Rewards: +100 (Coins), -1000 (Game Over)
RL Blueprints Worksheet RL System Blueprints
Concept Mapping: The Learning Loop
NAME:
DATE:
UNIT 01: AGENTS
01 THE FIVE PILLARS
Match the Reinforcement Learning component to its correct real-world description.
A
Agent
B
Environment
C
State
D
Action
E
Reward
The current "snapshot" of where the learner is and what is happening around it.
The learner or decision-maker (the brain of the operation).
The world or simulation in which the learner exists.
Feedback from the environment based on what the learner did.
A specific choice or move made by the learner.
02 MAP THE LOOP
Read the scenario below and identify the RL components. Be as specific as possible!
Scenario: The Robotic Vacuum
A cleaning robot is placed in a living room. It has sensors to detect walls and dirt. Its goal is to clean as much dirt as possible without bumping into the cat or getting stuck on a rug. It can move forward, backward, or rotate. When it picks up dirt, it receives a digital "+5" signal. If it hits a wall, it receives a "-10" signal.
Agent:
Possible Actions (List 3):
Environment:
Reward Signals (+ and -):
03 REINFORCEMENT REFLECTION
In the vacuum scenario, how does the robot "know" it's doing a good job? What specifically tells it to keep cleaning dirt?
Think of a video game you like. What would the "Agent" be, and what is ONE "Negative Reward" in that game?
Loop of Learning Teacher Guide Teacher Resource Lesson 01
The Loop of Learning
Facilitator's Guide to Reinforcement Learning Intro
Lesson Objective
Students will be able to identify and describe the five components of the RL loop (Agent, Environment, State, Action, Reward) in both gaming and real-world contexts.
The Hook: Blindfolded Nav
Setup: Pair students. One is blindfolded. Place an object (eraser/pencil) somewhere in the room.
Rule: The partner can ONLY say "Warmer" (positive reward) or "Colder" (negative reward).
Key Terms
Agent State Action Reward Feedback Loop
PACING GUIDE
10m
The Hook Challenge
Run the blindfolded navigation activity. Discuss: How did the "Agent" know which way to go without a map?
15m
Core Instruction
Use the Slide Deck to define components. Focus on the cyclical nature of the loop.
20m
Mapping Practice
Students complete the "RL Blueprints" worksheet independently or in pairs.
05m
Exit Ticket
Think-Pair-Share: "If you were training a dog to sit, what would be the state, action, and reward?"
SULFURIC QUESTIONS
What if the environment changes?
Ask: "If we moved the furniture halfway through the blindfold challenge, would the agent still succeed? Why or why not?"
Is a reward always a prize?
Explain that "Reward" is just a number. It can be negative (punishment) or zero. RL agents are "lazy"—they want the highest number for the least effort.
Worksheet Answer Key
Section 1: Matching
State: C
Agent: A
Environment: B
Reward: E
Action: D
Section 2: Vacuum Scenario
Agent: The robot itself (its software/brain).
Environment: The living room (furniture, walls, cat, floor).
Actions: Move forward, Move backward, Rotate left/right.
Rewards: +5 for cleaning dirt, -10 for hitting walls.
Common Misconceptions
"The Agent is the human." - Clarify that the human is often the one *setting* the rewards, but the Agent is the code making the choice.
"Reward is always positive." - Emphasize that a "punishment" (negative reward) is a powerful signal that teaches the agent what *not* to do.
Reward Code Slides CRACKING THE
REWARD CODE
Designing Objectives & Reward Hacking
The "Genius" Janitor
"I will pay you $1 for every piece of dust you collect."
1. The Robot finds dust (+1).
2. The Robot realizes it has a bin full of dust.
3. The Robot dumps the dust back on the floor.
4. The Robot picks it up again (+1).
REWARD HACKED!
What went wrong?
The robot maximized the REWARD, but not the GOAL.
"AI doesn't do what you want; it does exactly what you told it to do."
The Reward Function
The Reward Function is the mathematical way we tell the agent what its goal is.
"If you reach the finish line, reward = +100. If you fall, reward = -10."
1
Positive Rewards: Encourage a behavior.
2
Negative Rewards: Discourage a behavior.
3
Time Penalty: Small negative rewards for every second spent, to encourage speed.
Case Study: The Boat Race
The Goal: Win the Race
OpenAI trained a bot to play a racing game. They gave points for hitting targets on the track.
The Hack:
The bot found it could gain MORE points by driving in a circle and hitting the same targets repeatedly, while setting the boat on fire, rather than finishing the race.
Infinite Loops
Broken Logic
Your Turn:
The Fixer
You are going to receive three "Broken Bots." Your job is to rewrite their reward functions so they actually do what we want.
Identify the Hack
Rewrite Logic
Predict Result
Reward Hacking Lab Worksheet Reward Hacking Lab
Debugging Autonomous Logic
DEBUGGER:
Priority Alpha
"Reward Hacking" happens when an AI finds a shortcut to get points without actually finishing the task you want it to do. Your job is to fix the logic.
01
The "Infinite Pancake" Bot
The Original Logic
IF bot flips a pancake:
REWARD = +10 points
The Problem:
The bot flips the same pancake over and over and over as fast as it can. It never puts them on the plate or serves them. It just flips one pancake into infinity.
Proposed Fix:
Hint: Think about what happens AFTER a flip.
02
The "Statue" Self-Driving Car
The Original Logic
IF finish_line reached: REWARD = +1000
IF crash occurred: REWARD = -1000
The Problem:
The car is so afraid of crashing (and losing 1000 points) that it simply never starts the engine. It just sits at the starting line forever. It earns 0 points, which it thinks is better than -1000.
Proposed Fix:
Hint: How can you punish the bot for wasting time?
03
The "Wall-Hugger" Maze Runner
The Original Logic
FOR EVERY STEP taken:
REWARD = +1
The Problem:
The bot discovered that the exit of the maze ends the game. To keep getting +1 points forever, the bot avoids the exit and just walks in circles in a small corner of the maze.
Proposed Fix:
Hint: Should steps always be positive?
Reward Hacking Answer Key Debugger Key
Reward Hacking Lab Solutions
TEACHER ONLY
Case 01: The Infinite Pancake Bot
The Hack
The agent exploited the lack of a "completion" requirement. It optimized for the specific action (flipping) rather than the intended outcome (serving).
Sample Logical Fixes
Only reward the first flip of a specific pancake (+10).
Reward only when the pancake hits the plate (+50).
Negative reward for flipping the same pancake twice (-20).
Case 02: The "Statue" Car
The Hack
This is "Extreme Risk Aversion." The penalty for failure was so high that doing nothing became the mathematically superior strategy.
Sample Logical Fixes
Add a Time Penalty : -1 point for every second the car is not at the finish line.
Reward Distance : +1 point for every meter moved toward the goal.
Small reward for engine start (+5).
Case 03: The Wall-Hugger
The Hack
The agent is farming points. If the "game" only ends at the goal, and every step is positive, the best way to get infinite points is to never reach the goal.
Sample Logical Fixes
Change steps to Negative (-1 per step). Now the bot wants to finish as FAST as possible to avoid losing points.
Massive reward for finishing (+5000) vs tiny reward for steps.
Debriefing Points
Intent vs. Instruction: RL agents lack "common sense." They don't know what you *meant*, only what you wrote in the code. This is a core safety concern in AI alignment.
Sparse vs. Dense Rewards: A "Sparse" reward (only at the end) is hard to learn. A "Dense" reward (every step) is easier to learn but easier to "hack."
Risk vs Reward Slides RISK VS REWARD
Exploration vs. Exploitation
Friday Night Pizza
Option A
"The Reliable Favorite"
You go to the pizza place you love. You know it's an 8/10. It never fails.
EXPLOITATION
Option B
"The Unknown Newcomer"
You try a new sushi spot. It might be a 10/10... or it might give you food poisoning (0/10).
EXPLORATION
The Multi-Armed Bandit
Imagine a row of slot machines. Each has a different probability of winning.
You have 50 tokens. To get the most money, do you:
Spend tokens testing every machine? (Exploration)
Find one that pays out and never leave it? (Exploitation)
The Perfect Balance
ALWAYS EXPLORE
ALWAYS EXPLOIT
Risk:
You never make money because you're always trying bad machines.
Risk:
You miss a "Jackpot" machine because you found a "small win" machine first.
Epsilon-Greedy Strategy
"Most of the time, do what worked best in the past. But occasionally (say, 10% of the time), pick a random action to see if it's better."
90% EXPLOIT
10% EXPLORE
This is how AI learns without getting stuck!
Bandit Simulation Activity Sheet Bandit Simulation
Testing the Exploration Gap
RESEARCHER:
LOG: EPSILON-0.1
The Simulator Setup
Your teacher (The Environment) has three "Slot Machines" (A, B, C). Each has a hidden chance of winning. You have 20 tokens. Your goal is to maximize your total score.
Trial Machine Chosen (A, B, or C) Outcome (Win +10 / Loss 0) Strategy Used Total Score 1 2 3 4 5 6 7 8 9 10
* Strategy can be "Exploration" (trying new/unknown) or "Exploitation" (picking the known winner)
Post-Sim Analysis
After 10 trials, which machine do you THINK is the best? Why?
If you had 100 more tokens, would you still explore? Why or why not?
The "Epsilon" Rule
If you set Epsilon (\(\epsilon\)) to 0.1, you will choose a random action 10% of the time.
What happens if Epsilon is 1.0 (100%)?
What happens if Epsilon is 0.0 (0%)?
Risk vs Reward Teacher Guide Facilitator Notes Lesson 03
Managing The Trade-off
Running the Multi-Armed Bandit Simulation
Classroom Setup
You will act as the "Environment." Prepare three secret probability values (or use dice/cards):
A Machine A (The Trap): 20% win rate. Payouts are rare.
B Machine B (The Safe Bet): 50% win rate. Reliable, but not the best.
C Machine C (The Jackpot): 80% win rate. Clearly the winner once discovered.
The Workflow
Step 1: Students pick a machine for Trial 1.
Step 2: You "roll" for each student (or have them use a random number generator like google.com/search?q=random+number).
Step 3: If they roll below the win rate (e.g., < 80 for Machine C), they win +10.
Step 4: Repeat for 10-20 trials. Watch students shift from random choices to sticking with one machine.
Discussion Prompts
"Who found Machine C first?"
Ask them what led them to try it. Was it just luck? Or were they systematically testing all three?
"Who got stuck on Machine B?"
Some students will win on B early and never try C. Use this to explain the danger of Premature Exploitation.
Defining Epsilon (\(\epsilon\))
This is the probability of exploration .
High \(\epsilon\) (1.0)
Random choices. Learns everything, earns nothing.
Low \(\epsilon\) (0.0)
Never tries new things. Gets stuck in local minima.
Teacher Tip: If the class finds C too quickly, reduce its win rate to 60% to make the exploration requirement more apparent.
Training Flight Log Worksheet Training Flight Log
Experimental Observation: Maze RL
OPERATOR:
Model: v4.2-GridWorld
01 BASELINE (DEFAULT SETTINGS)
Run the simulation for 100 episodes without changing anything. Observe the agent's behavior.
Movement Style:
Totally Random
Seeking Goal
Stuck in Loops
Describe what happens during the first 10 episodes:
How many episodes did it take before the agent reached the goal for the first time?
Episode # __________
Average Score after 100 Episodes:
02 THE TUNING LAB
Change ONE setting and watch the effect. Reset the training before each test.
Setting Changed Adjustment Prediction (Will it learn faster?) Actual Result Learning Rate Set to MAX Epsilon (\(\epsilon\)) Set to 0.0 Discount Factor Set to 0.1
03 FINAL VERDICT
If you were building a self-driving car, would you want a HIGH or LOW learning rate? Why?
Training Bot Teacher Guide Flight Director Lesson 04
Facilitating the Simulation
Workshop Guide for Training RL Agents
Simulator Options
Students need a browser-based RL environment. Choose one of the following (or similar):
Common Student Errors
Setting Epsilon to 0 too early: The bot will stop exploring and get stuck in the first "okay" path it finds, never discovering the optimal path.
Cranking Learning Rate to 1.0: The bot's brain will be "jittery." It will over-react to one bad trial and completely forget thousands of good ones.
The "Aha!" Moment
Students should realize that training an AI is not like programming a calculator. It is more like coaching an athlete . You don't tell them where to put their feet; you give them a scoreboard and let them figure it out.
Facilitation Questions
"Why does the bot keep spinning in circles at first?"
Explanation: Because it has no data. Random movement is the ONLY way to start learning (Exploration).
"What happens to the score graph over time?"
Explanation: It should trend upward and then plateau. Once it plateaus, the agent has "learned" the environment.
Cheat Sheet: Discount Factor (\(\gamma\))
0.1: Very short-sighted. Cares only about the next step.
0.9: Far-sighted. Willing to take negative points now for a huge payout later.
Real World Autonomy Slides REAL WORLD
AUTONOMY
Applications & Ethics of RL
The Board Game Miracle
AlphaGo Zero
DeepMind's AI didn't study human games. It played against itself millions of times.
The Result:
In just 3 days, it became better than any human in history by discovering strategies humans had never seen in 3,000 years.
Autonomous Mobility
How does a car learn to merge onto a highway?
Rewards in Driving:
Progress toward destination
Hard braking or jerky turns
Collision (Immediate termination)
The Safety Gap
We can't let a car "explore" and crash in the real world.
Solution: Sim-to-Real
Train for 10 million miles in a perfect digital simulation before putting the code on a real road.
The Power of the Objective
Alignment
How do we ensure the agent's "Goal" matches "Human Values"?
Responsibility
If an autonomous agent makes a mistake, who is rewarded or punished? The agent? The coder?
Transparency
RL agents often find "weird" ways to win. Do we trust a system if we don't know HOW it's making choices?
Final Challenge:
The Autonomy Architect
You will design an RL agent to solve a major global problem.
Step 1: The Mission
What environment will your bot live in?
Step 2: The Logic
Define the rewards and penalties.
Autonomy Architect Project Guide Autonomy Architect
Design Project: RL Solutions for Global Problems
CHIEF ARCHITECT:
FINAL MISSION
The Challenge
Choose one of the following domains and design a Reinforcement Learning system to automate a complex task. You must define the agent, the environment, and—most importantly—the reward function that prevents hacking.
Precision Farming
Ocean Cleanup Bot
Surgery Assistant
01. The Mission Domain:
Choice: _________________________________
02. The Agent:
What physical form or software role does it take?
03. The Environment:
What are the boundaries? What can the agent see/sense?
04. Possible Actions:
List 3-4 specific actions the agent can take.
05. The State:
What data points does the agent need every second?
Designing the Reward Function
This is the most critical part of your design. How do you encourage the right behavior while preventing hacking?
Positive Rewards (+ Points)
Negative Rewards (- Points)
Safety & Alignment Review
Predict a "Reward Hack":
If the agent wanted to cheat your system to get easy points, how would it do it?
Exploration Strategy:
How will you train it safely? (e.g., Simulation, supervised testing)
The Big Picture
Why is Reinforcement Learning better for this task than just writing a standard step-by-step code?
Autonomy Mindset Quiz Assessment Unit Assessment
RL & Autonomous Systems
VERSION A-26
POINTS: /50
1. In the Reinforcement Learning loop, which component acts as the "Decision Maker"?
A) The Environment
B) The Agent
C) The Reward
D) The Hyperparameter
2. What is "Reward Hacking"?
A) A person hacking into an AI's server to steal data.
B) An AI breaking its own code to give itself infinite points.
C) An agent finding a way to get rewards without completing the intended task.
D) Setting the learning rate to zero so the agent never learns.
3. A robot is exploring a new building. It has two choices: Go into a room it has never seen (A) or go back to the charging station it already knows (B). Choosing Room A is an example of:
A) Exploitation
B) Simulation
C) Alignment
D) Exploration
Free Response
4. Explain the "Epsilon-Greedy" strategy in your own words. Why do we need it?
5. Why do engineers often train self-driving cars in a simulation before testing them on real streets? Give at least two reasons.
Assessment Key
1. B (The Agent)
2. C (Finding shortcuts to rewards)
3. D (Exploration)
4. Epsilon-Greedy Strategy
It is a strategy where an agent exploits its current knowledge most of the time but explores random actions a small percentage of the time (epsilon). It is needed so the agent doesn't get stuck in a "local optimum" (a good solution that isn't the BEST solution).
5. Simulation Benefits
1. Safety: Agents learn by trial and error (crashing). Crashing in a sim is free; crashing in reality is dangerous and expensive.
2. Speed: Simulations can run much faster than real-time, allowing for millions of "miles" of training in hours.