Inspiration
We were inspired by the idea of transforming chess from a silent, calculation-heavy game into an interactive, personality-driven experience. Traditional chess engines like Stockfish are incredibly strong but completely emotionless. We wanted to create something different—where your opponent isn't just calculating moves, but trash-talking, strategizing aloud, and reacting dynamically to your gameplay. By leveraging Google's Gemini AI and other leading language models, we reimagined chess as a conversational battle where every move comes with commentary, creating an engaging experience that feels like playing against a real grandmaster with personality.
What it does
LMC Arena is an AI-powered chess platform where players battle against leading language models (Gemini, GPT, NVIDIA) that act as chess opponents with distinct personalities. The platform:
- Enforces all legal chess moves with real-time visual feedback (highlighted squares, blocked illegal moves)
- Provides AI commentary after each move, making the opponent feel alive and engaging
- Features AutoPilot mode where two AIs battle each other while you spectate
- Tracks comprehensive stats including wins, losses, draws, and match history
- Implements daily play limits (3 free matches per day) to manage API costs responsibly
- Offers draw mechanics where players can propose draws after 10 moves, and the AI can accept or decline
- Displays captured pieces and move history in a clean, Chess.com-inspired interface
- Supports multiple AI models with different playing styles and personalities
How we built it
Frontend:
- Built with React 18 for modern UI components and state management
- Used chess.js library for complete chess rule validation and legal move generation
- Styled with Tailwind CSS 3 for a responsive, neo-brutalist design
- Implemented Firebase SDK for authentication (email/password + Google OAuth)
- Created custom components for board, squares, move history, and player info
Backend:
- Set up Firebase Cloud Functions (Node.js) as serverless API endpoints
- Integrated Google Gemini 2.0 Flash API for primary AI opponent
- Connected OpenRouter API to access GPT-4o-mini and NVIDIA models
- Implemented Cloud Firestore for storing users, matches, and daily limits
- Created security rules to protect user data
AI Integration:
- Crafted persona-driven prompts for each AI model (arrogant grandmaster, tactical warrior, etc.)
- Built validation system to catch AI hallucinations (invalid moves) with fallback to random legal moves
- Implemented retry logic and error handling for API failures
- Added commentary extraction to display AI's thoughts after each move
Deployment:
- Deployed frontend to Vercel for global CDN distribution
- Used Firebase Hosting as backup deployment option
- Set up environment variables for secure API key management
- Configured CORS and domain authorization
Challenges we ran into
AI Hallucinations: Language models sometimes suggested illegal chess moves (e.g., moving knights like bishops). We solved this by validating every AI move with chess.js and implementing a fallback system that plays a random legal move when the AI makes an error.
API Rate Limits: Gemini and OpenRouter APIs have usage quotas. We implemented a daily match limit (3 games per day) and optimized API calls to reduce costs while maintaining a good user experience.
Real-time Move Validation: Ensuring users could only make legal moves required complex state management. We built a system that highlights legal moves when a piece is selected and blocks invalid moves with helpful toast notifications.
Firebase Cold Starts: Cloud Functions had initial latency issues. We optimized by keeping functions warm and implementing loading states with "AI is thinking..." indicators.
Prompt Engineering: Getting consistent JSON responses from AI models was tricky. We refined prompts to explicitly request JSON-only output and added parsing logic to strip markdown formatting.
Draw Mechanics: Implementing the 50-move rule was costly (50 API calls without progress). We reduced it to 15 moves for Gemini to balance gameplay and API costs.
State Synchronization: Managing board state, move history, captured pieces, and AI commentary required careful React state management to avoid bugs and race conditions.
Accomplishments that we're proud of
- 100% Legal Move Enforcement: Every single move is validated—no illegal moves possible
- Multi-Model Support: Successfully integrated 3 different AI providers (Google, OpenAI via OpenRouter, NVIDIA)
- AutoPilot Mode: A unique feature where two AIs battle each other, showcasing creative AI vs AI gameplay
- Professional UI: Built a Chess.com-quality interface with smooth animations and intuitive controls
- Robust Error Handling: Graceful fallbacks for API failures, invalid moves, and network issues
- Complete Authentication Flow: Secure login with email/password and Google OAuth
- Comprehensive Stats Tracking: Full game history with wins/losses/draws stored in Firestore
- Draw Negotiation System: First chess app where you can propose draws and AI responds dynamically
- Scalable Architecture: Firebase backend scales automatically with user growth
- Daily Limit System: Fair play mechanism that balances free usage with API costs
What we learned
- Prompt Engineering is Critical: Small changes in AI prompts drastically affect move quality and commentary style
- Firebase is Powerful: Cloud Functions + Firestore + Auth = complete backend with minimal setup
- Chess.js is Essential: Would be nearly impossible to implement legal moves without this library
- AI Models Have Different Personalities: Gemini plays aggressive, GPT plays tactical, NVIDIA plays analytical—even with similar prompts
- User Feedback Matters: Toast notifications and visual highlights dramatically improve user experience
- Rate Limiting is Necessary: Without daily limits, API costs would be unsustainable for a free app
- State Management is Complex: Chess requires careful tracking of board state, turn order, captured pieces, and game status
- Deployment Best Practices: Environment variables, CORS configuration, and security rules are crucial for production apps
- Error Handling Saves Projects: AI APIs fail sometimes—fallback logic keeps the app running smoothly
What's next for LMChess Arena
Short-term (Next 1-2 Months):
- Add more AI models: Claude 3.5, LLaMA 3, Mistral, DeepSeek
- Implement ELO ratings: Track skill levels for both users and AI models
- Add difficulty levels: Adjust AI temperature and thinking time for easier/harder opponents
- Voice commands: Use Google Speech-to-Text for move input ("Knight to F3")
- Mobile app: React Native version for iOS/Android
- Leaderboard: Global rankings for players with most wins
Medium-term (3-6 Months):
- Multiplayer mode: Play against other humans with AI commentary
- Tournament system: Weekly tournaments with prizes
- Game analysis: Post-game breakdown showing best moves and mistakes
- Opening library: Learn chess openings with AI coaching
- Puzzle mode: Daily chess puzzles with AI hints
- Payment integration: Subscription for unlimited matches
Long-term (6-12 Months):
- Computer vision: Scan physical chess boards with phone camera
- AR mode: Overlay AI suggestions on real chess boards using AR
- Live streaming: Watch top players battle AI opponents
- AI training: Upload your games to create a personalized AI that plays like you
- Custom AI personas: Create your own trash-talking AI opponents
- Chess variants: Support for Chess960, 3-check, King of the Hill
- Social features: Friends, chat, game sharing, replays
Built With
- firebase
- gemini
- openrouter
- tailwind
- typescript

Log in or sign up for Devpost to join the conversation.