An intelligent AI assistant for The Space Bar adventure game that provides contextual hints.
-
๐ฌ Watch the video to get oriented to Thudbot
-
๐งช Try out Thudbot locally
-
Follow the Quick Start steps below
-
Try these Example Questions
-
Thudbot is an AI-powered player companion for The Space Bar, a cult-classic adventure game from legendary game designer Steve Meretzky.
It provides contextual, spoiler-sensitive hints through an immersive, in-universe interface: the playerโs Personal Digital Assistant (PDA), Zelda.
Designed as a standalone web tool, Thudbot keeps you grounded in the game worldโeven when you need help solving its trickiest puzzles.
Built with LangGraph, FastAPI, and Next.js, Thudbot is a stepping stone toward fully agentic NPCs for the Boffo Games universe.
See Thudbot in action
Not familiar with "The Space Bar" game? No problem! Here are ready-to-test examples:
Q: "Where is the bus token?"
Expected: Thud explains it's in a cup, with character-specific advice
Q: "How do I get the token from the cup?"
Expected: Step-by-step hint about asking Thud for help or looking carefully
Q: "When does the shuttle to Karkas 4 leave?"
Expected: Specific time (22:50) with character commentary about checking monitors
- ๐ฎ Game Hint System: RAG-powered hints for The Space Bar adventure game puzzles
- ๐ก๏ธ Robust Error Handling: Graceful error recovery
- ๐ Web Interface: Next.js frontend
- โก FastAPI Backend: High-performance Python API server
- ๐งช Comprehensive Testing: Robust test suite
# Clone the repo
git clone https://github.com/BQ31X/thudbot.git
cd thudbot
# Add your API keys to .env (copy from .env.example)
cp .env.example .env
# Edit .env with your OPENAI_API_KEY
# Start everything with Docker
cd infra
docker compose up --build
# โจ Thudbot backend now at: http://localhost:8000- Python 3.13+
- Node.js 20+
# ๐ฆ Clone the repo
git clone https://github.com/BQ31X/thudbot.git
cd thudbot
# Install Python dependencies (backend)
cd apps/backend
uv sync
# Install Node.js dependencies (frontend)
cd ../frontend
npm install# Return to project root and copy environment template
cd ../..
cp .env.example .env
# Edit .env and add your API keys:
# OPENAI_API_KEY=your_api_key_here
# LANGCHAIN_API_KEY=your_langchain_key_here # Optional: for LangSmith tracingTerminal 1 - Backend:
cd apps/backend
uv run python -m thudbot_coreTerminal 2 - Frontend:
cd apps/frontend
npm run devAccess: Open http://localhost:3000 in your browser!
For production deployment using Docker Swarm with secure secret management:
# Initialize Docker Swarm (if not already done)
docker swarm init
# Create Docker secrets for API keys
echo "your_openai_api_key_here" | docker secret create openai_api_key -
echo "your_langchain_api_key_here" | docker secret create langchain_api_key -Prerequisites:
- Two servers (app node + retrieval node)
- Docker + Docker Buildx on local machine
- Docker Swarm on app node
- Docker + Docker Compose on retrieval node
# Build all images (backend, frontend, retrieval)
make build-all
# Or build individually
make build-backend
make build-frontend
make build-retrieval
# Verify multi-arch support
make inspect-images# Deploy qdrant + retrieval service
make deploy-retrieval
# Verify
make logs-retrieval
make logs-qdrant# Create Docker secrets on app node (one-time)
ssh bq@<app-node-ip>
echo "your_openai_key" | docker secret create openai_api_key -
echo "your_langchain_key" | docker secret create langchain_api_key -
docker swarm init
# Deploy backend + frontend + redis
make deploy-prod
# Verify
make logs
make logs-frontend# Deploy both nodes with one command
make deploy-all- ๐ Two-Node Architecture: Separates compute (app) from retrieval (embeddings + vector search)
- ๐ Docker Secrets: Secure API key management on app node (no secrets on retrieval node)
- ๐ฆ Multi-Arch Images: ARM64 (Mac dev) + AMD64 (Linode prod)
- ๐ Auto-restart: Automatic service recovery with restart policies
- ๐ฏ Local Embeddings: BGE CPU-only embeddings
# App node operations
make logs # View backend logs
make logs-frontend # View frontend logs
make restart-backend # Restart backend service
# Retrieval node operations
make logs-retrieval # View retrieval service logs
make logs-qdrant # View qdrant logs
make restart-retrieval # Restart retrieval service
make stop-retrieval # Stop retrieval stack
# Build operations
make build-all # Build and push all images
make inspect-images # Verify multi-arch builds๐ Production Access: Backend available at http://your-server:8000
โ๏ธ Configuration:
- Edit
Makefileto set your server IPs (APP_LINODE_HOST, RETRIEVAL_LINODE_HOST) - Retrieval API URL is set in
infra/compose.prod.app.yml
Frontend (Next.js)
โ
Backend (FastAPI + LangGraph) โโโ App Node (<app-node-ip>)
โ HTTP
Retrieval Service (FastAPI) โโโ Retrieval Node (<retrieval-node-ip>)
โ local
Qdrant (server-mode)
Production Deployment:
- App Node: Backend + Frontend + Redis (Docker Swarm)
- Retrieval Node: Qdrant + Retrieval API (docker compose)
- Communication: Backend โ Retrieval API via
RETRIEVAL_API_URL
Built with:
- Backend: FastAPI + LangChain + OpenAI GPT-4
- Frontend: Next.js + React + Tailwind CSS
- Retrieval: FastAPI + Qdrant (server-mode) + BGE embeddings (local, CPU-only)
- Data: Server-mode Qdrant collection + Multi-query retrieval
- Build: Offline collection builder with OpenAI or local BGE embeddings
Storage Architecture:
- Build-time:
tools/build_qdrant_collection.pycreates server-mode collections - Run-time: Backend calls retrieval API; retrieval service queries Qdrant directly
Data-driven retriever selection using comprehensive evaluation:
- ๐ Full evaluation in:
00_Thud_construction.ipynb - ๐งช Framework: RAGAS metrics (context recall, entity recall, noise sensitivity)
- ๐ Golden dataset: 12 synthetically generated test queries
- ๐ฅ Platinum dataset: Selected subset of 5 queries, produced by applying a LangChain-based rewriting prompt to the golden dataset, followed by manual selection for evaluation focus and cost control
- โ๏ธ Compared retrievers: Naive, BM25, Multi-query
- ๐ฏ Result: Multi-query retrieval selected based on superior performance
Key findings:
- Multi-query retrieval significantly improved context precision
- Enhanced handling of ambiguous game terminology
- Better retrieval of relevant hints for complex puzzles
See notebook for detailed metrics, comparison tables, and methodology.
Run the comprehensive test suite:
# Run all tests
uv run pytest
# Run tests with the commit script
./check_and_commit.sh "your commit message"Test coverage includes:
- Data validation (CSV exists & structure)
- Module imports (all components load)
- File organization (required files present)
- Basic functionality verification
Ask about game puzzles:
"How do I get the token from the cup?"
โ "The bus token is in the cup; make sure Thud has it before you hop on the bus."
Get general game help
"When is the shuttle to Karkas 4?"
โ "The shuttle to Karkas 4 departs at 22:50."
thudbot2/
โโโ apps/
โ โโโ backend/ # Python FastAPI backend
โ โ โโโ thudbot_core/ # Core application code
โ โ โ โโโ *_node.py # LangGraph workflow nodes
โ โ โ โโโ api.py # FastAPI backend server
โ โ โ โโโ langgraph_flow.py # Main workflow orchestration
โ โ โ โโโ state.py # Shared state management
โ โ โโโ data/ # CSV hint database
โ โ โโโ tests/ # Backend test suite
โ โ โโโ pyproject.toml # Python dependencies & config
โ โ โโโ Dockerfile # Backend container image
โ โโโ frontend/ # Next.js frontend
โ โโโ app/ # Next.js app directory
โ โโโ public/ # Static assets (PDA interface)
โ โโโ package.json # Node.js dependencies
โโโ infra/
โ โโโ compose.yml # Docker Compose (default)
โ โโโ compose.prod.yml # Production Docker Compose
โโโ docs/ # Project documentation
โโโ notebooks/ # Jupyter notebooks used for prototype development
โโโ .env # Environment variables (not in git)
โโโ README.md # This file
โโโ check_and_commit.sh # Test runner and commit script
- Make sure
.envis properly configured with a valid OpenAI key. - Restart both frontend and backend if switching API keys or files.
- Backend logs appear in the terminal where you run
uv run python -m thudbot_core. - For Docker Compose issues, try
docker compose downthendocker compose up --build.
This project is copyrighted and all rights are reserved. Leo DaCosta 2025