Szork is an innovative voice-controlled, AI-powered text adventure game that reimagines the classic Zork experience for the modern era. Built with LLM4S, it demonstrates the power of combining Large Language Models with real-world tools to create immersive, dynamic gaming experiences.
- ๐ง AI Dungeon Master: An LLM agent acts as your DM, creating dynamic narratives and managing game state
- ๐๏ธ Voice Control: Speak your commands naturally (Speech-to-Text integration)
- ๐ฃ๏ธ Narrated Adventures: Responses are spoken aloud (Text-to-Speech)
- ๐จ AI-Generated Scenes: Each location is illustrated with AI-generated artwork
- ๐ฌ Natural Language: No need to remember specific commands - just speak naturally
- ๐พ Auto-Save: Game state is automatically saved and can be resumed anytime
- ๐ Hot Reload Development: Changes to code automatically restart the server
- ๐ Web-Based Interface: Modern Vue.js frontend with WebSocket real-time communication
- ๐ญ Multiple Themes: Choose from various adventure themes and art styles
- ๐บ Persistent State: Game state, inventory, and progress are maintained
- ๐ต Dynamic Music: AI-generated background music that adapts to the scene mood
- ๐ผ๏ธ Smart Caching: Images and audio are cached for improved performance
- Start Your Adventure: Launch the game and choose your theme
- Explore Naturally: Speak or type commands like "look around", "go north", or "pick up the sword"
- Experience the Story: The AI DM describes scenes, manages inventory, and responds to your actions
- See Your World: AI generates images for each new location you discover
- Hear Your Tale: Text-to-speech narrates the adventure as it unfolds
- Java 17+
- Scala 2.13
- sbt 1.8+
- Node.js 18+ (for frontend)
- API Keys for:
- OpenAI (GPT-4 for DM, DALL-E for images, Whisper for speech)
- OR Anthropic (Claude for DM)
Copy .env.example
to .env
and fill in your local values. Never commit .env
.
cp .env.example .env
# Edit .env and add your keys (OPENAI_API_KEY/ANTHROPIC_API_KEY, etc.)
# Clone the repository
git clone https://github.com/llm4s/szork.git
cd szork
# Start the server (default port 8090)
sbt szorkStart
# Or with hot reload for development
sbt "~szorkStart"
# In a new terminal
cd frontend
npm install
npm run dev
Open your browser to http://localhost:3090
- Primary interface: WebSocket
ws://localhost:9002
(typed JSON messages). - Selected HTTP endpoints remain for utility:
GET /api/health
โ health checkGET /api/feature-flags
โ capability discovery (LLM/image/music/tts/stt availability)GET /api/games
,GET /api/game/list
โ list saved gamesPOST /api/game/save/:sessionId
,GET /api/game/load/:gameId
โ persistence helpers
See frontend/src/types/WebSocketProtocol.ts
for the client protocol and src/main/scala/org/llm4s/szork/protocol/WebSocketProtocol.scala
for server types.
- Backend: Scala 2.13 with Cask web framework
- AI Integration: LLM4S library for LLM orchestration
- Frontend: Vue 3 + Vuetify 3 + TypeScript
- Real-time: WebSockets for streaming responses
- Build Tool: sbt with hot reload support
szork/
โโโ src/main/scala/org/llm4s/szork/
โ โโโ SzorkServer.scala # Main server with all endpoints
โ โโโ GameEngine.scala # Core game logic and LLM integration
โ โโโ StreamingAgent.scala # Streaming LLM responses
โ โโโ GameTools.scala # Tool definitions for the AI agent
โ โโโ ImageGeneration.scala # AI image generation
โ โโโ TextToSpeech.scala # TTS integration
โ โโโ MusicGeneration.scala # Dynamic music generation
โ โโโ GamePersistence.scala # Save/load game state
โโโ frontend/ # Vue.js web interface
โโโ talk/ # Presentation materials
# Start with file watching - automatically restarts on code changes
sbt "~szorkStart"
sbt szorkStart
- Start the serversbt szorkStop
- Stop the serversbt szorkRestart
- Restart the serversbt szorkStatus
- Check server statussbt compile
- Compile the projectsbt test
- Run tests
The server exposes capabilities and allows perโsession overrides.
- Backend configuration (env vars):
SZORK_IMAGE_GENERATION_ENABLED
,SZORK_TTS_ENABLED
,SZORK_STT_ENABLED
,SZORK_MUSIC_ENABLED
- Capability discovery (frontend):
GET /api/feature-flags
โ{ llm, image, music, tts, stt }
- The selection screen shows capability chips from this endpoint.
- WebSocket protocol (perโsession):
- Client โ Server
newGame
(optional overrides):{ tts?: boolean, stt?: boolean, music?: boolean, imageGeneration?: boolean }
- Server โ Client
gameStarted
(effective flags):{ ttsEnabled, sttEnabled, imageEnabled, musicEnabled }
- Client โ Server
- UI behavior:
- When a capability is disabled by server, related controls are disabled (e.g., mic button when STT is off, TTS/mute toggle when TTS is off, image/music toggles when disabled).
- Validation errors from server are surfaced as a toast and also appear in the chat stream.
The game supports extensive configuration through environment variables:
SZORK_PORT
- Server port (default: 8090)SZORK_AUTO_SAVE
- Enable auto-save (default: true)SZORK_CACHE_ENABLED
- Enable caching (default: true)SZORK_IMAGE_GENERATION_ENABLED
- Enable image generation (default: true)SZORK_TTS_VOICE
- TTS voice selectionSZORK_MUSIC_ENABLED
- Enable background music
- Development Guide - Detailed development setup and build instructions
- SBT Revolver Guide - Hot reload configuration with file watching
- Frontend README - Frontend development, features, and configuration
- Claude Code Guide - Guide for AI assistants working with this codebase
- Documentation Index - Complete documentation directory and archive
For additional design documents and historical information, see the docs/ directory.
This project was created as a demonstration for the talk "Scala Meets GenAI: Build the Cool Stuff with LLM4S":
- ๐ Scala Days 2025 - August 21, 2025
- ๐ SwissTech Convention Center, EPFL, Lausanne ๐จ๐ญ
- ๐ Talk Details
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
- LLM4S - The Scala toolkit powering Szork's AI capabilities
- Original Zork - The classic text adventure that inspired this project
Experience the magic of text adventures reimagined with the power of AI! ๐