A modern recreation of the classic TRON (1982) arcade game Light Cycles, built with vanilla JavaScript and Vite.
Play online: https://lightcycles.matthewrcrigger.com/
- Play against AI opponents with sophisticated pathfinding algorithms
- Five difficulty levels with dynamic enemy count and behavior
- Enhanced AI based on Google AI Challenge 2010 winning algorithms
- High-performance collision detection system
- Canvas-based rendering with smooth animations and light trails
- Immersive audio system with synthesized sound effects
- Responsive design with mobile touch controls
- Modern ES6 module architecture
- Vanilla JavaScript (ES6+) - No frameworks, pure JS
- Vite - Fast build tool and development server
- Canvas API - Hardware-accelerated 2D rendering
- Web Audio API - Dynamic audio management
- Node.js 22.0.0 or higher
- npm (comes with Node.js)
-
Clone the repository:
git clone <repository-url> cd lightcycles
-
Install dependencies:
npm install
Start the development server:
npm run devThe game will open automatically at http://localhost:3000
Build for production:
npm run buildThe optimized output will be in the dist/ folder, ready for deployment.
lightcycles/
├── js/ # Source JavaScript modules
│ ├── main.js # Application entry point
│ ├── game-controller.js # Game loop and input handling
│ ├── board.js # Game board and team management
│ ├── light-cycle.js # Light cycle entity logic
│ ├── enhanced-ai.js # Advanced AI pathfinding
│ ├── ai-integration.js # AI system integration
│ ├── collision-grid.js # Spatial hash collision detection
│ ├── canvas-renderer.js # Canvas rendering system
│ ├── sound-generator.js # Web Audio API synthesized sounds
│ ├── config.js # Game configuration
│ ├── coordinate.js # Grid coordinate utilities
│ ├── difficulty-description.js # Difficulty settings UI
│ └── performance-monitor.js # FPS and performance tracking
├── css/
│ └── styles.css # Game styling
├── media/ # Audio files and assets
├── dist/ # Production build output (generated)
├── index.html # Main HTML file
├── vite.config.js # Vite configuration
├── package.json # Dependencies and scripts
└── README.md # This file
- Arrow Keys or WASD - Control your light cycle
- Spacebar - Pause/Resume game
- Touch Controls - On-screen directional buttons
- Pause Button - Top-right corner of control pad
Choose from five AI difficulty levels:
- Very Easy - Slow AI with basic strategy (1 opponent)
- Easy - Moderate AI with improved tactics (1 opponent)
- Medium - Balanced gameplay with smart AI (1 opponent)
- Hard - Fast AI with advanced strategies (2 opponents)
- Very Hard - Expert AI with maximum challenge (3 opponents)
Higher difficulties introduce multiple AI opponents and more aggressive pathfinding.
The enhanced AI uses sophisticated algorithms including:
- Voronoi-based territory control - AI claims and defends space
- Flood fill analysis - Evaluates available space in real-time
- Minimax with alpha-beta pruning - Strategic decision making
- Adaptive behavior - Difficulty-based strategy adjustments
- Multi-agent coordination - Team-based AI on harder difficulties
Based on winning strategies from the Google AI Challenge 2010.
Dynamic synthesized sound design using the Web Audio API:
- Game Start - Countdown beeps during initialization
- Engine Sounds - Accelerating motor sounds for player and AI cycles
- Collision Effects - Multi-layer explosion sounds on impact
- Victory Sound - Triumphant melodic fanfare for player wins
- Defeat Sound - Somber descending melody for player losses
All sounds are generated in real-time using JavaScript oscillators, eliminating the need for external audio files.
- Spatial Hash Grid - O(1) collision detection
- RequestAnimationFrame - Smooth 60 FPS rendering
- Offscreen Canvas Rendering - Background caching
- Code Splitting - Separate chunks for core, AI, and UI
- Asset Optimization - Minified and compressed output
Modern browsers with ES6 module support:
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
npm run dev # Start development server with hot reload
npm run build # Build optimized production bundle
npm run preview # Preview production build locallyThe game is configured for static hosting. The dist/ folder contains everything needed:
- Build the project:
npm run build - Upload only the
dist/folder to your web server - Point your domain/subdomain to the
dist/folder
Compatible with:
- Static hosting (Netlify, Vercel, GitHub Pages)
- CDN deployment
- Traditional web servers (Apache, Nginx)
Environment variables can be used to inject deployment-specific URLs at build time:
# Copy and configure for your deployment
cp .env.example .envSee CONFIGURATION.md for detailed setup instructions.
Game mechanics can be adjusted in js/config.js:
- Board dimensions
- Player speeds
- AI difficulty parameters
- Collision detection settings
- Audio timing
- Debug options
Code: MIT License (see LICENSE file)
This project is a fan-created recreation of the Light Cycles minigame for educational purposes. The MIT license covers the source code only, not the game concept or TRON brand.
- TRON is owned by Walt Disney Company
- Original arcade game by Bally Midway (1982)
- See LICENSE file for full disclaimer
- Original TRON arcade game by Bally Midway (1982)
- AI algorithms inspired by Google AI Challenge 2010
- Slapped together by Matthew Crigger and Claude Code
- Play tested by Matthew Crigger, his daughter, and friends.