leestott/FoundryLocal-LearningAdventure

Learn AI development by playing a game! A fun, interactive JavaScript adventure that teaches you how to use Microsoft Foundry Local and AI tools - one level at a time.

โ˜… 7Forks 4JavaScriptGitHub โ†—Compare

README

๐ŸŽฎ Foundry Local Learning Adventure

Learn AI development by playing a game! A fun, interactive JavaScript adventure that teaches you how to use Microsoft Foundry Local and AI tools, one level at a time.

Node.js License: MIT Foundry Local GitHub Pages


๐ŸŒ Play Online Now!

No installation required! Play the web version directly in your browser:

๐Ÿ‘‰ Play Foundry Learning Adventure ๐Ÿ‘ˆ

The web version includes all 5 levels and works completely in your browser with simulated AI responses.

For the full AI experience, install Foundry Local. No port configuration needed. The CLI game uses the foundry-local-sdk npm package to discover, download, and load models automatically. The web game scans for the Foundry Local service on known ports.

# Install Foundry Local
winget install Microsoft.FoundryLocal

# CLI game: the SDK downloads and loads the model for you
cd game && npm install && npm start

๐Ÿ“‹ Table of Contents


๐ŸŽฏ What is This Game?

The Foundry Local Learning Adventure is an educational game designed for complete beginners who want to learn about:

  • ๐Ÿค– AI/ML Basics - How AI models work and respond
  • ๐Ÿ’ฌ Prompt Engineering - Writing effective prompts
  • ๐Ÿ” Embeddings - How AI understands meaning
  • โšก AI Workflows - Chaining operations together
  • ๐Ÿ”ง Tool Building - Extending AI capabilities

You do not need any prior AI experience! Just follow along, complete challenges, and earn badges as you learn.

Who is this for?

  • ๐Ÿ‘จโ€๐ŸŽ“ Students learning about AI
  • ๐Ÿ‘ฉโ€๐Ÿ’ป Developers new to AI tools
  • ๐ŸŽจ Anyone curious about how AI works
  • ๐Ÿ“š Educators teaching AI concepts

๐Ÿ“š What You'll Learn

Level Topic What You Will Master
1 Meet the Model Making your first AI API call
2 Prompt Mastery Writing effective prompts
3 Embeddings Explorer Semantic search & similarity
4 Workflow Wizard Building AI pipelines
5 Build Your Own Tool Creating custom AI tools

๐ŸŽฎ Play Online (GitHub Pages)

The web version runs entirely in your browser with no installation required:

  • All 5 levels with interactive challenges
  • Progress saved automatically (localStorage)
  • Works on desktop, tablet, and mobile
  • Starts in Demo Mode; connects to real Foundry Local automatically if installed
  • Model selector dropdown lets you switch between available models
  • Real-time connection status shows scanning, loading, and download progress

Tip for educators: Fork the repo, enable GitHub Pages, and share the link with your class. Students can start learning immediately with zero setup.

When you are ready for real AI interactions, try the CLI version with Foundry Local.


๐Ÿš€ Quick Start (5 Minutes)

Choose how you want to play:

Option Best For How to Start
๐ŸŒ Play Online Classrooms, quick demos, mobile Click the link (no install needed)
๐ŸŒ Run Web Locally Offline use, local development cd game then run scripts/start-web.ps1
๐Ÿ’ป CLI (Terminal) Power users, traceable prompts cd game && npm start

All three options start in Demo Mode (simulated AI). Install Foundry Local for real AI responses. The game discovers models automatically.


Option 1: Web App (Browser) - Easiest!

No installation required - play directly in your browser:

Online (GitHub Pages)

๐Ÿ‘‰ Play Now ๐Ÿ‘ˆ

Run Locally

Using startup scripts (easiest):

Windows (Batch):

cd game
scripts\start-web.bat

Windows (PowerShell):

cd game
powershell -ExecutionPolicy Bypass -File scripts\start-web.ps1

Mac/Linux:

cd game
chmod +x scripts/start-web.sh
./scripts/start-web.sh

Or manually start a server:

# Navigate to web folder
cd game/web

# Start a local server (choose one):
npx http-server -p 8080 -c-1
# OR
python -m http.server 8080
# OR
python3 -m http.server 8080

Then open http://localhost:8080 in your browser.


Option 2: CLI (Terminal) - Full Experience

For real AI responses with Foundry Local:

Windows Users

  1. Download or clone this repository

  2. Navigate to the game folder

  3. Run one of these options:

    Option A - Batch File (double-click):

    scripts\start-game.bat

    Option B - PowerShell (recommended):

    powershell -ExecutionPolicy Bypass -File scripts\start-game.ps1
  4. Follow the on-screen prompts

  5. Start playing!

Mac/Linux Users

# Clone the repository
git clone <repository-url>
cd game

# Make the script executable
chmod +x scripts/start-game.sh

# Run the game
./scripts/start-game.sh

Using npm Directly

cd game
npm install
npm start

๐Ÿ“– Detailed Installation Guide

Step 1: Install Node.js

Node.js is required to run this game. It is free and easy to install.

Windows

  1. Visit nodejs.org
  2. Download the LTS version (green button)
  3. Run the installer
  4. Click "Next" through all options
  5. Restart your terminal after installing
  6. Done! โœ…

macOS

# Using Homebrew (recommended)
brew install node

# Or download from nodejs.org

Linux (Ubuntu/Debian)

sudo apt update
sudo apt install nodejs npm

Verify Installation

Open a terminal/command prompt and type:

node --version

You should see something like v18.x.x or higher.


Step 2: Download the Game

Option A: Download ZIP

  1. Click the green "Code" button on the repository page
  2. Select "Download ZIP"
  3. Extract to a folder you can easily find (e.g., Desktop)

Option B: Clone with Git

git clone https://github.com/leestott/FoundryLocal-LearningAdventure.git
cd FoundryLocal-LearningAdventure

Step 3: Install Dependencies

Open a terminal in the game folder:

cd game
npm install

This downloads all required packages. You only need to do this once.


Step 4: For the Interactive AI Install Foundry Local

The game works without Foundry Local (in demo mode), but for the full AI experience:

Windows

winget install Microsoft.FoundryLocal

Start the Game

The CLI game uses the foundry-local-sdk to discover, download, and load models automatically. You do not need to start a model manually:

cd game
npm install
npm start

The SDK will find available models, download any that are missing, and load the best one for you.


Step 5: Run the Game!

Option A: Use the Startup Script (Recommended)

Windows (Batch):

cd game
scripts\start-game.bat

Windows (PowerShell):

cd game
powershell -ExecutionPolicy Bypass -File scripts\start-game.ps1

Mac/Linux:

cd game
chmod +x scripts/start-game.sh
./scripts/start-game.sh

Option B: Use npm

npm start

๐ŸŽฎ How to Play

When you start the game, you will see a welcome screen:

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘     ๐ŸŽฎ FOUNDRY LOCAL LEARNING ADVENTURE ๐ŸŽฎ                       โ•‘
โ•‘                                                                  โ•‘
โ•‘     Master Microsoft Foundry AI - One Level at a Time!           โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Basic Gameplay

  1. Start a level: Type play 1 to start Level 1
  2. Follow instructions: Each level explains what to do
  3. Complete the task: Try the challenge
  4. Get help if stuck: Type hint for tips
  5. Earn rewards: Complete levels to unlock badges!

Your Mentor: Sage ๐Ÿง™

Throughout the game, Sage will guide you:

  • ๐Ÿ“– Introduces each level
  • ๐Ÿ’ก Provides helpful hints
  • โ“ Answers your questions
  • ๐ŸŽ‰ Celebrates your wins!

Type ask [your question] anytime to chat with Sage.


๐Ÿ“š Level Guide

Level 1: Meet the Model ๐ŸŽฏ

What you will do: Send your first message to an AI and get a response.

What you will learn:

  • How AI models communicate
  • The request/response pattern
  • What happens when you call an AI

Example:

Your prompt: Hello! Please introduce yourself.

Tips:

  • Just type a friendly greeting
  • Watch how the AI responds
  • There is no wrong answer here!

Badge Earned: ๐ŸŽฏ Prompt Apprentice (100 points)


Level 2: Prompt Mastery โœ๏ธ

What you will do: Improve a poorly written prompt and compare results.

What you will learn:

  • Why prompt quality matters
  • How to be specific and clear
  • The difference good prompts make

The Challenge:

Bad prompt:  "tell me stuff about coding"
Your task:   Write a better version!

Tips:

  • Be specific (what topic? what language?)
  • Add context (your skill level, format wanted)
  • Ask for examples

Badge Earned: โœ๏ธ Prompt Engineer (150 points)


Level 3: Embeddings Explorer ๐Ÿ”

What you will do: Search a knowledge base using semantic similarity.

What you will learn:

  • How AI understands meaning (not just keywords)
  • What embeddings are and how they work
  • How semantic search finds related content

Example:

Your query: "How do I run AI offline?"
Result: Finds content about Foundry Local's offline capabilities

Tips:

  • Think about meaning, not exact words
  • Try different ways of asking the same thing
  • See how similar concepts connect

Badge Earned: ๐Ÿ” Embedding Explorer (200 points)


Level 4: Workflow Wizard โšก

What you will do: Build a 3-step AI pipeline that processes text.

What you will learn:

  • How to chain AI operations together
  • Passing output from one step to the next
  • Automating complex multi-step tasks

The Pipeline:

Step 1: Summarize text
    โ†“
Step 2: Extract keywords
    โ†“
Step 3: Generate questions

Tips:

  • Watch how each step uses the previous output
  • Think about other workflows you could build
  • This is how real AI applications work!

Badge Earned: โšก Workflow Wizard (250 points)


Level 5: Build Your Own Tool ๐Ÿ”ง

What you will do: Create a JavaScript function and let AI use it.

What you will learn:

  • What AI tools/functions are
  • How agents call external code
  • Extending what AI can do

Example Tool:

// A simple calculator tool
function add_numbers(a, b) {
    return a + b;
}

Tips:

  • Keep your function simple
  • Add clear descriptions
  • The AI will learn to call your tool!

Badge Earned: ๐Ÿ† Foundry Champion (300 points)


๐Ÿ“ธ Game Screenshots

Welcome Screen

When you first open the game, you will see a friendly welcome screen:

Welcome Screen

Main Menu - Level Selection

After entering your name, choose from 5 progressive levels:

Main Menu

Level 1 - Meet the Model

Your first interaction with an AI model:

Level 1

AI Response

Watch the AI respond to your prompts in real-time:

AI Response

Sage - Your AI Mentor

Get help anytime from Sage, your friendly mentor:

Mentor Chat

Hint System

Stuck? Use hints to guide your learning:

Hint System

Progress Tracking

Track your points, badges, and completion status:

Progress Modal

Badge Collection

Earn badges as you master each concept:

Badges

Note: Screenshots are captured automatically using Playwright. The terminal version has similar functionality with a text-based interface.

๐ŸŽฌ Demo Videos

See the game in action with our walkthrough videos:


๐Ÿ’ป Commands Reference

Command What It Does Example
play [n] Start level n play 1
levels Show all levels levels
progress View your stats progress
badges See earned badges badges
hint Get a hint hint
ask [text] Ask the mentor ask what are embeddings?
explain [x] Explain a concept explain prompt engineering
help Show commands help
reset Reset progress reset
quit Save & exit quit

๐Ÿ† Rewards & Badges

Badges You Can Earn

Badge Level Points For
๐ŸŽฏ Prompt Apprentice 1 100 First AI call
โœ๏ธ Prompt Engineer 2 150 Better prompts
๐Ÿ” Embedding Explorer 3 200 Semantic search
โšก Workflow Wizard 4 250 AI pipelines
๐Ÿ† Foundry Champion 5 300 All complete!

Point Milestones

Points Title Description
100 Beginner Just getting started!
250 Learner Making progress!
500 Practitioner Getting skilled!
750 Expert Almost a master!
1000 Master You have done it all!

Achievements

  • ๐Ÿ‘ฃ First Steps - Complete your first level
  • ๐ŸŒŸ Halfway Hero - Complete 50% of levels
  • โšก Speed Learner - Complete a level in under 5 minutes
  • ๐Ÿง  Hint-Free Hero - Complete without using hints
  • โ“ Curious Mind - Ask 10 questions
  • ๐ŸŽ“ Master Graduate - Complete everything!

๐ŸŒ Deploy to GitHub Pages

Deploy your own copy of the game to GitHub Pages for free hosting!

Option 1: Automatic (GitHub Actions) - Recommended

  1. Fork this repository to your GitHub account

  2. Enable GitHub Pages:

    • Go to your repo's Settings โ†’ Pages
    • Source: Select GitHub Actions
  3. Push to main branch - deployment happens automatically!

  4. Access your game at: https://YOUR-USERNAME.github.io/FoundryLocal-LearningAdventure/

Option 2: Manual Deployment

  1. Fork this repository

  2. Enable GitHub Pages:

    • Go to Settings โ†’ Pages
    • Source: Deploy from a branch
    • Branch: main
    • Folder: /game/web
  3. Wait 2-3 minutes for deployment

  4. Visit https://YOUR-USERNAME.github.io/FoundryLocal-LearningAdventure/

Local testing: See the Quick Start section for running the web version on your machine.


โ“ Troubleshooting

"Node.js not found" or "node is not recognised"

What happened: Node.js is not installed or is not in your PATH.

Fix:

  1. Download Node.js from nodejs.org
  2. Choose the LTS version
  3. Run the installer (accept defaults)
  4. Close and reopen your terminal
  5. Try again

"Foundry Local not detected"

What happened: The game cannot connect to Foundry Local.

This is fine! The game will work in "demo mode" with simulated responses.

To enable full AI:

  1. Install Foundry Local: winget install Microsoft.FoundryLocal
  2. Run npm start in the game folder
  3. The SDK will discover, download, and load a model automatically

Note: The CLI game uses the foundry-local-sdk npm package, which manages the Foundry Local service lifecycle (starting, model loading) internally. You do not need to start a model or configure a port manually. The web version scans common ports (61341, 5272, 51319, 5000, 8080) to find the running service.


"Cannot find module" or "MODULE_NOT_FOUND"

What happened: Dependencies are not installed.

Fix:

cd game
npm install
npm start

"Progress not saving"

What happened: The game cannot write to the progress file.

Fix:

  • Use quit command to exit (not Ctrl+C)
  • Check that data/progress.json exists
  • Make sure you have write permission
  • Try: npm run reset to create a fresh progress file

"Game is frozen" or "Taking too long"

What happened: The AI call is taking a while.

Fix:

  • Wait 10 to 15 seconds (AI can be slow)
  • If using Foundry Local, check it is still running
  • Press Ctrl+C to cancel and try again
  • The game will use demo mode if AI is unavailable

๐Ÿค” Frequently Asked Questions

Do I need to know programming?

No! The game teaches concepts through interaction. You will learn as you go.

Do I need internet access?

No! Everything runs on your computer. That is what "Local" means.

Do I need Foundry Local installed?

No! The game has a demo mode. But you will get better responses with it.

Can I skip levels?

No, levels unlock in order. Each one builds on previous concepts.

How long does it take to complete?

Most people finish in 1 to 2 hours. Take your time and enjoy!

What if I make a mistake?

No problem! That is how you learn. Use hint or ask for help.

Can I replay completed levels?

Yes! Type play [number] to replay any completed level.

How do I reset my progress?

Type reset in the game, or run npm run reset.


๐Ÿ“ Project Structure

FoundryLocal-LearningAdventure/
โ”œโ”€โ”€ README.md               # This file!
โ”œโ”€โ”€ AGENTS.md               # AI agent conventions
โ”œโ”€โ”€ changelog.md            # Version history
โ”œโ”€โ”€ LICENSE                 # MIT Licence
โ”œโ”€โ”€ CONTRIBUTING.md         # Contribution guidelines
โ”œโ”€โ”€ SECURITY.md             # Security policy
โ”œโ”€โ”€ .gitignore              # Git ignore rules
โ”œโ”€โ”€ .github/                # GitHub configuration
โ”‚   โ””โ”€โ”€ workflows/          # CI/CD workflows
โ”‚       โ”œโ”€โ”€ deploy.yml      # GitHub Pages deployment
โ”‚       โ””โ”€โ”€ test.yml        # Automated testing
โ””โ”€โ”€ game/                   # Game source code
    โ”œโ”€โ”€ src/                # Source code (Node.js version)
    โ”‚   โ”œโ”€โ”€ game.js         # Main game engine (uses foundry-local-sdk)
    โ”‚   โ”œโ”€โ”€ levels.js       # Level management and tasks
    โ”‚   โ””โ”€โ”€ mentor.js       # AI mentor (Sage)
    โ”œโ”€โ”€ web/                # Web version (GitHub Pages)
    โ”‚   โ”œโ”€โ”€ index.html      # Main HTML page
    โ”‚   โ”œโ”€โ”€ styles.css      # Game styling
    โ”‚   โ”œโ”€โ”€ game-web.js     # Web game engine
    โ”‚   โ””โ”€โ”€ game-data.js    # Levels, rewards, mentor data
    โ”œโ”€โ”€ data/               # Game data (JSON)
    โ”‚   โ”œโ”€โ”€ levels.json     # Level definitions
    โ”‚   โ”œโ”€โ”€ rewards.json    # Badges and achievements
    โ”‚   โ””โ”€โ”€ progress.json   # Your saved progress
    โ”œโ”€โ”€ screenshots/        # Game screenshots
    โ”œโ”€โ”€ tests/              # Test files
    โ”œโ”€โ”€ scripts/            # All startup scripts
    โ”‚   โ”œโ”€โ”€ start-game.bat  # Windows CLI launcher
    โ”‚   โ”œโ”€โ”€ start-game.ps1  # PowerShell CLI launcher
    โ”‚   โ”œโ”€โ”€ start-game.sh   # Mac/Linux CLI launcher
    โ”‚   โ”œโ”€โ”€ start-web.bat   # Windows Web launcher
    โ”‚   โ”œโ”€โ”€ start-web.ps1   # PowerShell Web launcher
    โ”‚   โ””โ”€โ”€ start-web.sh    # Mac/Linux Web launcher
    โ”œโ”€โ”€ config.json         # Settings
    โ””โ”€โ”€ package.json        # Node.js configuration (includes foundry-local-sdk)

๐Ÿงช Running Tests

Make sure everything is working:

# Run all tests
npm test

# Check Foundry Local status (Windows)
npm run test:foundry

# Reset your progress
npm run reset

Running Web Screenshot Tests

Capture screenshots automatically using Playwright:

# Navigate to game folder
cd game

# Install Playwright (first time only)
npm run test:install

# Capture all screenshots
npm run test:screenshots

Screenshots are saved to game/screenshots/.

Test output shows:

  • โœ… Passed tests (green)
  • โŒ Failed tests (red)
  • โญ๏ธ Skipped tests (yellow - usually means Foundry Local not running)

โš™๏ธ Configuration

Edit config.json to customise:

{
  "foundryLocal": {
    "defaultModel": "Phi-3.5-mini-instruct-generic-cpu:1",
    "sdkAppName": "FoundryLearningAdventure",
    "sdkLogLevel": "warn"
  },
  "azureFoundry": {
    "enabled": false,
    "endpoint": "https://YOUR-RESOURCE.openai.azure.com",
    "apiKey": "YOUR-API-KEY",
    "apiVersion": "2024-02-01",
    "deploymentName": "gpt-4o-mini"
  },
  "game": {
    "maxHintsPerLevel": 3,
    "demoModeEnabled": true
  }
}

Connection Modes

The game automatically detects available AI services:

Priority Mode Description
1 Foundry Local Uses local AI model via the foundry-local-sdk (CLI) or HTTP port scanning (web)
2 Azure OpenAI Uses Azure cloud if configured
3 Demo Mode Simulated responses (fallback)

Using Azure OpenAI (Cloud)

To use Azure OpenAI instead of local models:

  1. Create an Azure OpenAI resource at Azure Portal
  2. Deploy a model (e.g., gpt-4o-mini)
  3. Update config.json:
    {
      "azureFoundry": {
        "enabled": true,
        "endpoint": "https://your-resource.openai.azure.com",
        "apiKey": "your-api-key",
        "deploymentName": "gpt-4o-mini"
      }
    }
  4. Run the game - it will connect to Azure!

Common Changes

  • Different model: Change defaultModel to your preferred model alias
  • More hints: Increase maxHintsPerLevel
  • SDK logging: Set sdkLogLevel to "info" or "debug" for more detailed output

๐Ÿค Contributing

We welcome contributions! Here is how:

  1. Fork the repository
  2. Create a branch: git checkout -b my-feature
  3. Make your changes
  4. Test: npm test
  5. Commit: git commit -m "Add my feature"
  6. Push: git push origin my-feature
  7. Open a Pull Request

Ideas for Contributions

  • ๐Ÿ†• New levels teaching more concepts
  • ๐ŸŒ Translations to other languages
  • ๐ŸŽจ Visual/UX improvements
  • ๐Ÿ› Bug fixes
  • ๐Ÿ“– Documentation improvements
  • ๐Ÿงช More tests

๐Ÿ“š Learn More


๐Ÿ“„ Licence

MIT Licence - Feel free to use, modify, and share!

See LICENSE for details.


๐Ÿ’ฌ Get Help

  • ๐Ÿ› Bug? Open an issue
  • ๐Ÿ’ก Idea? Start a discussion
  • โ“ Question? Check FAQ or open an issue

๐ŸŽฎ Happy Learning! โœจ

Built with โค๏ธ for the Foundry Local community

โฌ† Back to Top

Contributors

leestottHVbajoria

Issues