Algorithm Design Workshop

Advanced Systems & Ethics - Final Preparation

๐ŸŽฏ Lesson 4: Algorithm Design Workshop & Advanced Ethics

โฑ๏ธ Duration: 60 minutes
๐Ÿ“Š Level: Review & Integration

Learning Objectives

By the end of this lesson, Bodhi will be able to:

  • Design algorithms from scratch to solve practical problems
  • Explain how AI systems create both opportunities and vulnerabilities in security
  • Apply ethical decision-making frameworks to real software engineering scenarios
  • Design fair and transparent processes for automated systems

Lesson Timeline

0-20 min
Algorithm Design Workshop
Review fundamentals, practice algorithm creation
20-35 min
AI & Security Integration
Learn AI basics, analyze security scenarios
35-50 min
Ethics Framework
Apply ethical decision-making to real cases
50-60 min
Process Design
Design fair appeals process, lesson wrap-up

๐Ÿ‘จโ€๐Ÿซ Teacher Notes

๐Ÿ’ก Start Strong: Begin with the algorithm comparison feature to show progress
๐Ÿ—ฃ๏ธ Discussion Focus: Ethics scenarios work best when discussed together
โธ๏ธ Pause Points: Look for "๐Ÿ›‘ Discussion Time" markers throughout
๐Ÿ“ Assessment: End with reflection questions to check understanding

Progress Tracker

Module 1
Module 2
Module 3
Module 4

Module 1: Algorithm Design Workshop

Review algorithm fundamentals and design solutions to real-world problems

Algorithm Fundamentals Review

๐Ÿ›‘ Discussion Time (3 minutes)
Teacher: "Before we start, let's quickly review. Bodhi, can you explain what an algorithm is in your own words? Give me an example from a game you know."
๐Ÿ’ก Look for understanding of step-by-step instructions and logical sequences

What Are Algorithms?

Algorithms are step-by-step instructions to solve problems. In gaming: matchmaking algorithms pair players of similar skill, loot algorithms determine item drops, and pathfinding algorithms help NPCs navigate maps.

๐Ÿ” Search Patterns
Find specific data (player by username, item in inventory)
๐Ÿ”„ Iteration Patterns
Process collections (calculate team total score, update all players)
โš–๏ธ Decision Patterns
Choose actions based on conditions (unlock achievement, apply buff)
๐Ÿ“Š Accumulation Patterns
Build results over time (total damage dealt, experience gained)

Algorithms in Our Previous Lessons

  • Databases: SQL queries use search and filtering algorithms
  • Security: Authentication systems use validation algorithms
  • Web Applications: Form processing uses input validation algorithms
๐Ÿ‘ฅ Work Together: Algorithm Walkthrough (5 minutes)

Teacher: "Let's build a simple algorithm together before you try the challenges. I'll think out loud while we solve this problem:"

Problem: How would you check if a player's chosen username is already taken?

Guide through: Input โ†’ Loop through existing names โ†’ Compare each one โ†’ Return result

๐Ÿ’ก Let Bodhi suggest the next step at each stage

Practice Challenges

Challenge 1: Username Validation System
Design an algorithm to verify if a username is already taken from a list of existing players. Your algorithm should accept a proposed username and a list of existing usernames, then return whether the username is available or not.

Algorithm Workspace

Logic Validation

?
Algorithm accepts required inputs
?
Uses iteration or search logic
?
Handles both found and not found cases
?
Returns appropriate result
Hint: Think about how you would manually check if a name exists in a list. You'd probably look at each name one by one until you either find a match or reach the end of the list.
๐Ÿ›‘ Discussion Time (2 minutes)
Teacher: "After trying Challenge 1, let's look at your solution together. What approach did you take? Let's compare it with the optimal solution."
๐Ÿ’ก Use the "Compare Solutions" button to show differences and discuss algorithm patterns
Challenge 2: Progression Points Calculator
Create an algorithm to calculate a player's total progression points from multiple match results. Different match types have different scoring rules:
  • Ranked matches: base points ร— 1.5
  • Casual matches: base points ร— 1.0
  • Event matches: base points ร— 2.0
Your algorithm should process an array of match records and return the total points.

Algorithm Workspace

Logic Validation

?
Processes array of match records
?
Applies correct multiplier based on match type
?
Accumulates total points correctly
?
Returns final calculated total
Hint: You'll need a running total and a way to check each match type. Consider using conditional statements (IF/ELSE) to apply the correct multiplier.
Challenge 3: Optimal Configuration Recommender
Design an algorithm to recommend the optimal equipment loadout based on player statistics. The algorithm should analyze a player's performance data (wins, losses, preferred playstyle) and recommend a configuration from available options that best matches their strengths.

Algorithm Workspace

Logic Validation

?
Analyzes player performance data
?
Compares against available options
?
Uses scoring or ranking system
?
Returns best matching recommendation
Hint: Think about giving each configuration a "compatibility score" based on how well it matches the player's statistics, then selecting the highest scoring option.

Module 2: Security & AI Integration Matrix

Learn AI fundamentals and analyze how AI systems intersect with security architecture

Artificial Intelligence & Machine Learning Fundamentals

What is Artificial Intelligence (AI)?

AI is software that can perform tasks that normally require human intelligence - like recognizing images, understanding speech, or making decisions. In gaming, AI controls enemy behavior, generates procedural worlds, and powers recommendation systems.

What is Machine Learning (ML)?

ML is a type of AI that learns patterns from data rather than following pre-programmed rules. Instead of coding "if player does X, then do Y," ML systems analyze thousands of examples to learn what actions work best.

๐ŸŽฎ Game AI Examples
Enemy bots that adapt to your playstyle, NPCs with realistic behavior
๐Ÿ—บ๏ธ Content Generation
Procedural worlds, quest generation, dynamic difficulty adjustment
๐Ÿ‘ฅ Player Matching
Matchmaking systems, friend recommendations, team balancing
๐Ÿ›ก๏ธ Anti-Cheat
Detecting suspicious behavior, identifying cheats, monitoring gameplay

How AI Learns (Simple Example)

Traditional Programming: "IF player misses 3 shots in a row, THEN reduce enemy accuracy by 10%"

Machine Learning: Show the system 10,000 matches where players had fun vs. boring matches. It learns patterns like "players enjoy games where they win 40-60% of encounters" and automatically adjusts difficulty.

AI Data & Training Fundamentals

The Golden Rule of AI: "Garbage In, Garbage Out" - AI systems are only as good as their training data. Think of it like teaching someone to play Dead by Daylight by only showing them matches against beginners - they'd never learn to handle skilled players!

๐Ÿ“Š Training Data
What it is: Thousands of examples AI learns from
Gaming example: To train an anti-cheat AI, you'd need:
โ€ข 50,000 normal gameplay recordings
โ€ข 10,000 confirmed cheating examples
โ€ข Player inputs, mouse movements, reaction times
๐Ÿงน Data Preprocessing
What it is: Cleaning and preparing raw data
Steps needed:
โ€ข Remove corrupted match recordings
โ€ข Handle disconnected players (missing data)
โ€ข Standardize different game modes
โ€ข Filter out lag-affected matches
โš–๏ธ Balanced Datasets
What it is: Fair representation across all groups
Why crucial: If you only train on PC players:
โ€ข Mobile players get falsely flagged
โ€ข Console players seem "suspicious"
โ€ข Different input methods = different patterns
๐Ÿ“ Performance Metrics
Key measurements:
โ€ข Accuracy: 95% correct detections
โ€ข False Positives: Innocent players flagged
โ€ข False Negatives: Cheaters missed
โ€ข Fairness: Equal accuracy across all player types
๐ŸŽฎ Real Gaming Example: Matchmaking AI

Training Process:

  1. Collect Data: 1 million match results with player satisfaction ratings
  2. Clean Data: Remove matches with disconnects, server issues, or smurfs
  3. Balance Data: Equal representation of all skill levels, regions, and play styles
  4. Train AI: Learn patterns like "players enjoy close matches" and "avoid skill gaps > 500 MMR"
  5. Test Performance: Measure if new matches result in higher satisfaction

๐Ÿš€ AI Revolutionizing Software Engineering Workflow

The Game Changer: AI isn't just another tool - it's transforming every stage of software development. Think of AI as your coding companion that never gets tired and learns from millions of developers!

๐Ÿ’ป Code Generation
Tools: GitHub Copilot, ChatGPT, Amazon CodeWhisperer
What it does:
โ€ข Write functions from comments: "// Create login system" โ†’ Full code
โ€ข Auto-complete code as you type
โ€ข Convert pseudocode to real programming languages
Gaming example: "Create a player inventory system" โ†’ AI generates complete database, UI, and game logic!
๐Ÿงช Testing Automation
Smart testing:
โ€ข AI generates thousands of test scenarios
โ€ข Predicts where bugs are likely to occur
โ€ข Creates realistic test data automatically
Gaming example: AI generates 10,000 different player loadouts to test game balance, finds broken combinations humans missed
โšก Performance Optimization
Code improvement:
โ€ข Identifies slow database queries
โ€ข Suggests more efficient algorithms
โ€ข Optimizes memory usage automatically
Gaming example: AI spots that rendering 1000 NPCs is lagging the game, suggests LOD (Level of Detail) system
๐ŸŽฏ User Experience
Personalization:
โ€ข Adapts UI based on user behavior
โ€ข Predicts user needs before they ask
โ€ข A/B tests different designs automatically
Gaming example: AI notices you prefer ranged combat, automatically highlights bow upgrades in shop
๐ŸŽฎ Case Study: AI-Powered Game Development

Before AI: Developer spends 2 weeks coding a quest system

With AI:

  1. Day 1: AI generates basic quest framework from description
  2. Day 2: AI creates 50 test scenarios to validate quest logic
  3. Day 3: AI optimizes database queries for quest tracking
  4. Day 4: AI suggests UI improvements based on player behavior patterns
  5. Day 5: Developer focuses on creative quest narratives instead of boilerplate code!

Result: 2 weeks โ†’ 1 week, with higher quality and more creative focus!

Why AI + Security Matters

AI Enhances Security (From Lesson 3)

Remember our security principles? AI can strengthen them:

  • Defense in Depth: AI adds intelligent layers that detect new attack patterns
  • Authentication: AI powers facial recognition, behavior analysis, and fraud detection
  • Input Validation: AI can detect malicious inputs that rule-based systems miss

AI Creates New Vulnerabilities

But AI systems can also be attacked:

  • Data Poisoning: Feeding bad training data to corrupt the AI's learning
  • Adversarial Attacks: Crafting inputs specifically designed to fool AI systems
  • Model Theft: Stealing the AI system to understand and exploit its weaknesses
๐Ÿ” AI as Detective
Analyzing patterns to find threats humans might miss
๐ŸŽฏ AI as Target
Attackers specifically targeting AI systems' unique weaknesses
โš–๏ธ AI as Judge
Making security decisions automatically (ban users, block traffic)
๐Ÿ› ๏ธ AI as Tool
Attackers using AI to create better attacks
๐Ÿ›‘ Discussion Time (3 minutes)
Teacher: "Now that we've learned AI basics, let's connect this to what you already know. How do you think AI could help with the security concepts from Lesson 3? What about new risks?"
๐Ÿ’ก Guide toward: AI enhances security but also creates new attack vectors
๐Ÿ›‘ Discussion Time: Traditional vs. AI Development (3 minutes)
Teacher: "We've learned how AI systems work, but let's think about building them. Imagine you're tasked with creating two systems for the same game:"

System A: Traditional login system - checks username/password against database
System B: AI-powered chat moderation - automatically detects toxic behavior

"What would be different about developing these two systems? What extra steps would System B need that System A doesn't?"
๐Ÿ’ก Guide toward these key differences:
โ€ข Data Requirements: System A needs no training data, System B needs thousands of examples
โ€ข Uncertainty: System A always gives same result, System B gives probabilities
โ€ข Testing: System A tests functionality, System B tests fairness across user groups
โ€ข Maintenance: System A stays consistent, System B may need retraining as language evolves

If stuck, prompt: "What would you need to teach the AI what 'toxic' means? How would you know if it's working fairly for all players?"

๐Ÿ”„ AI Development Lifecycle (Software Engineering Perspective)

The Big Picture: Building AI systems is like training a new employee vs. programming a robot. Traditional software follows exact instructions, but AI systems learn patterns and make educated guesses!

1๏ธโƒฃ Data Collection & Preparation
Traditional: No data needed - just write the logic
AI: Must gather thousands/millions of examples
Example: Chat moderation system needs:
โ€ข 100K toxic messages (labeled as "toxic")
โ€ข 500K normal messages (labeled as "safe")
โ€ข Messages from different games, languages, contexts
2๏ธโƒฃ Model Training & Learning
Traditional: Code does exactly what you program
AI: System finds patterns in data automatically
Example: AI discovers that toxic messages often:
โ€ข Use specific word combinations
โ€ข Have ALL CAPS text
โ€ข Contain personal attacks
โ€ข Have angry emoji patterns
3๏ธโƒฃ Validation & Testing
Traditional: Test if features work correctly
AI: Test accuracy, fairness, edge cases
Example: Testing chat moderation:
โ€ข 95% accuracy on test data โœ…
โ€ข Works across different game genres โœ…
โ€ข Doesn't bias against certain languages โœ…
โ€ข Handles creative insults humans make up โ“
4๏ธโƒฃ Monitoring & Retraining
Traditional: Once deployed, works consistently
AI: Performance can drift over time
Example: Chat moderation might fail when:
โ€ข New slang emerges players use
โ€ข Toxicity patterns evolve
โ€ข Game community changes
โ†’ Needs retraining with new data!
๐Ÿ”ง Key Difference: Deterministic vs. Probabilistic
Traditional Software

Input: Player health = 0

Output: Always "Game Over"

Same result every time โœ…

AI System

Input: Chat message "ur trash"

Output: 87% likely toxic (maybe ban?)

Confidence levels, not certainty โš–๏ธ

Real-World Scenario Analysis

๐Ÿ‘ฅ Work Together: Scenario Analysis (3 minutes)

Teacher: "Let's work through the first scenario together. Read the background, then tell me what you think before choosing an answer."

๐Ÿ’ก Discuss the scenario first, then click through the choice together

๐Ÿ›ก๏ธ

AI-Enhanced Defense

Background: A gaming company's login system uses a traditional Web Application Firewall (WAF) that blocks known SQL injection attacks with pre-written rules.

The Innovation: They add a Machine Learning model trained on millions of attack patterns. This AI can now detect brand-new SQL injection attempts that have never been seen before.

Question: What core security principle does this enhancement represent?
โš ๏ธ

AI Vulnerability

Background: A gaming company uses facial recognition AI to verify streamers' identities and prevent account sharing.

The Attack: A hacker takes photos of a popular streamer and uses AI to generate thousands of slightly modified versions. By testing these against the recognition system, they eventually create a fake image that the AI incorrectly identifies as the real streamer.

Question: This attack exploits which type of AI vulnerability?
๐Ÿ”

AI Service Security

Background: A gaming company creates an AI service that generates custom character artwork for players. The service is expensive to run - each image costs them $0.50 in processing power.

The Problem: They offer this via a web API, but if anyone can access it without limits, attackers could generate millions of images and cost them thousands of dollars.

Question: What's the most critical security control to prevent unauthorized usage and cost abuse?
๐Ÿงช

Real-World Case: AI Development Gone Wrong

Background: "VoiceGuard" - an AI system for toxic behavior detection in voice chat

Development Phase:
โ€ข Trained on 500,000 voice chat samples
โ€ข 95% accuracy on test data
โ€ข Passed all technical quality checks
โ€ข Management approved for full deployment โœ…
Deployment Disaster:
โ€ข British players: 40% false positive rate (flagged as toxic when innocent)
โ€ข Players with speech impediments: 60% false positive rate
โ€ข Non-native English speakers: 75% false positive rate
โ€ข Community outrage, #AIBias trending, lawsuits threatened โŒ
Root Cause Investigation reveals: Training data was 90% North American English speakers from a single game genre

Question: What fundamental AI development principle was violated that traditional software testing wouldn't catch?

Module 3: Ethical Analysis Framework

Learn software engineering ethics and practice structured ethical decision-making

Software Engineering Ethics Fundamentals

Why Ethics Matter in Software Engineering

As software engineers, our code affects millions of people's lives. We make decisions about privacy, fairness, safety, and access to technology. Unlike other fields, our ethical choices get built into systems that operate at massive scale.

โš–๏ธ Algorithmic Fairness
Ensuring AI systems don't discriminate against groups of people
๐Ÿ”’ Privacy by Design
Building privacy protection into systems from the start
๐ŸŒ Social Impact
Considering how technology affects employment and society
๐Ÿ‘๏ธ Transparency
Making systems understandable and accountable

Common Ethical Dilemmas in Gaming

  • Monetization: Is it ethical to design addictive mechanics that encourage spending?
  • Data Collection: How much player data should we collect for "better experiences"?
  • AI Moderation: Should automated systems decide who gets banned?
  • Competitive Balance: How do we ensure fair play for all skill levels?

How to Make Ethical Decisions

The 4-Step Ethical Analysis Process

1. Identify Stakeholders
Who is affected? Users, employees, society, business
2. Consider Consequences
What are short and long-term impacts for each group?
3. Apply Principles
Fairness, transparency, privacy, safety, autonomy
4. Design Solutions
Create processes that balance competing interests

Connection to Previous Lessons

  • Algorithms (Module 1): The logic we create embeds our values and biases
  • AI Systems (Module 2): Machine learning can amplify both good and bad human decisions
  • Security (Lesson 3): Protecting users is both a technical and ethical responsibility
๐Ÿ›‘ Discussion Time (4 minutes)
Teacher: "Ethics isn't just about following rules - it's about thinking through consequences. Let's practice the 4-step process together: Pick a simple example (like data collection in games) and walk through: Who's affected? What are the consequences? What principles apply? How do we design a solution?"
๐Ÿ’ก Use a familiar gaming example before tackling complex scenarios

Real-World Ethical Scenarios

๐Ÿ‘ฅ Think-Pair-Share: Ethics Cases (5 minutes each)

Teacher: "For each case study, we'll: 1) Read together, 2) You think about your choice, 3) Discuss your reasoning, 4) Make the decision together"

๐Ÿ’ก Focus on the reasoning process, not just the "right" answer

โš–๏ธ

Case Study 1: Algorithmic Bias in Hiring

The Situation: A gaming company's AI recruitment system consistently rejects qualified candidates from certain demographic groups, even though it was trained on "objective" historical hiring data.

The Problem: The AI learned from 10 years of past hiring decisions that contained unconscious human biases, now automating those same biases at scale.

Your Decision: As the lead engineer, how should you address this algorithmic bias?
๐Ÿค–

Case Study 2: Automation vs. Employment

The Situation: Your team has developed an automation system that will improve customer service efficiency by 40% but will eliminate 200 support roles over 18 months.

The Problem: The system is technically sound and will help the company stay competitive, but many employees will lose their jobs.

Your Decision: How should the company proceed with implementation?
๐Ÿ”’

Case Study 3: Privacy vs. Security Trade-offs

The Situation: Your proposed monitoring system would prevent 90% of security incidents and protect player accounts, but requires continuous analysis of detailed user behavior patterns.

The Problem: The system needs access to private user data to work effectively, creating a tension between security and privacy.

Your Decision: How do you balance security needs with privacy concerns?

Ethical Process Design

Why Process Design Matters

When we build automated systems (like AI content moderation), we need fair processes for when things go wrong. A good appeals process protects users from unfair automated decisions and maintains trust in the system.

โš–๏ธ Due Process
Users deserve a fair chance to challenge automated decisions
๐Ÿ‘ค Human Oversight
Important decisions should involve human review
๐Ÿ“ Transparency
Users should understand why decisions were made
โฑ๏ธ Timely Response
Appeals should be processed quickly and fairly

Essential Elements of Fair Appeals

  • Clear Starting Point: Users must know how to submit an appeal
  • Evidence Review: The system should check relevant data and context
  • Human Review: A person should evaluate complex or serious cases
  • Clear Decision: Users should receive an explanation of the outcome
  • Notification: Users should be informed promptly of results

Gaming Example: Anti-Cheat Appeals

Imagine a player gets banned by an AI anti-cheat system. They should be able to:

  • Submit an appeal with evidence (like explaining unusual gameplay)
  • Have their match data reviewed by human moderators
  • Receive a clear explanation of the decision
  • Get a timely response (not weeks of waiting)
๐Ÿ›‘ Discussion Time (3 minutes)
Teacher: "Before we design our own process, think about a time when you felt something was unfair in a game. What would have made it better? What would a fair appeals process look like to you as a player?"
๐Ÿ’ก Connect to personal experience before technical design

Design an Appeals Process

๐Ÿ‘ฅ Collaborative Design (8 minutes)

Teacher: "Let's design this process together. I'll help you think through each step. As you select options, explain why you're choosing them."

๐Ÿ’ก Guide through the ethical implications of each choice

Scenario: Your gaming company uses AI to automatically detect and remove toxic chat messages. Sometimes the AI makes mistakes and removes legitimate messages. Design a fair appeals process for players who want to challenge these decisions.

Step-by-Step Process Design

Select the steps you want to include in your appeals process (in order):

๐ŸŽฏ Lesson Wrap-up & Reflection

โœ… Quick Knowledge Check (3 minutes)

Teacher: "Let's do a quick review. Can you explain to me:"

  • What makes a good algorithm? (Clear steps, handles edge cases, efficient)
  • How can AI both help and hurt security? (Enhanced detection vs. new attack vectors)
  • What are the key principles of ethical software design? (Fairness, transparency, accountability)
  • Why do we need fair processes for automated systems? (Human oversight, due process)

๐Ÿค” Reflection Questions (5 minutes)

Teacher: "Think about these questions, then we'll discuss:"

  1. Algorithms: Which algorithm challenge was hardest for you? Why?
  2. AI & Security: What surprised you most about AI vulnerabilities?
  3. Ethics: Which ethical scenario was most difficult to decide? What made it hard?
  4. Real-world: How will you apply this thinking to your own programming projects?

๐Ÿ“š What We Covered Today

Algorithm Design
Created algorithms from scratch, learned problem-solving patterns
AI & Security
Understood AI fundamentals and security implications
Ethics Framework
Applied 4-step ethical decision-making to real scenarios
Process Design
Designed fair appeals processes for automated systems

๐Ÿ‘จโ€๐Ÿซ Teacher Assessment Notes

โ–ก Shows understanding of algorithm design principles
โ–ก Can explain AI-security relationship
โ–ก Applies ethical reasoning to scenarios
โ–ก Engages thoughtfully with process design
โ–ก Makes connections between topics
โ–ก Asks good questions during discussions

๐Ÿš€ Next Steps

For next lesson: Review algorithm patterns and think about a small project where you could apply ethical decision-making.

Optional practice: Try designing an algorithm for a simple game mechanic you're interested in.

← Back to Tutoring Home