Algorithm Design Workshop
Advanced Systems & Ethics - Final Preparation
๐ฏ Lesson 4: Algorithm Design Workshop & Advanced Ethics
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
๐จโ๐ซ Teacher Notes
Progress Tracker
Module 1: Algorithm Design Workshop
Review algorithm fundamentals and design solutions to real-world problems
Algorithm Fundamentals Review
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.
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
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
Algorithm Workspace
Logic Validation
- Ranked matches: base points ร 1.5
- Casual matches: base points ร 1.0
- Event matches: base points ร 2.0
Algorithm Workspace
Logic Validation
Algorithm Workspace
Logic Validation
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.
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!
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
Steps needed:
โข Remove corrupted match recordings
โข Handle disconnected players (missing data)
โข Standardize different game modes
โข Filter out lag-affected matches
Why crucial: If you only train on PC players:
โข Mobile players get falsely flagged
โข Console players seem "suspicious"
โข Different input methods = different patterns
โข 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:
- Collect Data: 1 million match results with player satisfaction ratings
- Clean Data: Remove matches with disconnects, server issues, or smurfs
- Balance Data: Equal representation of all skill levels, regions, and play styles
- Train AI: Learn patterns like "players enjoy close matches" and "avoid skill gaps > 500 MMR"
- 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!
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!
โข 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
โข 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
โข 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:
- Day 1: AI generates basic quest framework from description
- Day 2: AI creates 50 test scenarios to validate quest logic
- Day 3: AI optimizes database queries for quest tracking
- Day 4: AI suggests UI improvements based on player behavior patterns
- 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
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?"
โข 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!
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
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
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 โ
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
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
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
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
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
โข Trained on 500,000 voice chat samples
โข 95% accuracy on test data
โข Passed all technical quality checks
โข Management approved for full deployment โ
โข 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 โ
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.
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
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
Real-World Ethical Scenarios
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 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 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 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.
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)
Design an Appeals Process
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
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:"
- Algorithms: Which algorithm challenge was hardest for you? Why?
- AI & Security: What surprised you most about AI vulnerabilities?
- Ethics: Which ethical scenario was most difficult to decide? What made it hard?
- Real-world: How will you apply this thinking to your own programming projects?