Spaces:
Running
Running
| # Chess Emotions App - Plan | |
| ## My Understanding | |
| You want a chess app where: | |
| 1. **You play chess in the browser against Stockfish** | |
| 2. **Reachy Mini reacts with emotions based on how good/bad your moves are** | |
| The fun twist: Reachy is "rooting for" Stockfish (the computer), so when you make a bad move, Reachy is happy - and when you make a good move, Reachy gets nervous or upset! | |
| ## Technical Approach | |
| ### Architecture | |
| ``` | |
| ┌─────────────────────────────────────────────────────┐ | |
| │ Browser (static/) │ | |
| │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ | |
| │ │ Chess Board │ │ Stockfish │ │ Emotion │ │ | |
| │ │ (chessboard │ │ (WASM) │ │ Trigger │ │ | |
| │ │ .js) │ │ │ │ (to REST) │ │ | |
| │ └─────────────┘ └─────────────┘ └─────────────┘ │ | |
| └───────────────────────────┬─────────────────────────┘ | |
| │ REST API calls | |
| ▼ | |
| ┌─────────────────────────────────────────────────────┐ | |
| │ Reachy Mini Daemon (port 8000) │ | |
| │ /api/move/play/recorded-move-dataset/{dataset}/ │ | |
| │ {emotion} │ | |
| └─────────────────────────────────────────────────────┘ | |
| ``` | |
| ### Components | |
| 1. **Chess UI** - Using chess.js + chessboard.js libraries (both run in browser) | |
| 2. **Stockfish** - Using stockfish.js (WebAssembly, runs entirely in browser) | |
| 3. **Move Evaluation** - Stockfish provides centipawn scores to evaluate moves | |
| 4. **Emotion Mapping** - Map evaluation changes to emotions via REST API | |
| ### Emotion Mapping (Draft) | |
| | Move Quality | Eval Change | Reachy's Reaction | | |
| |--------------|-------------|-------------------| | |
| | Brilliant! | User gains 200+ cp | `fear1`, `scared1`, `anxiety1` | | |
| | Good move | User gains 50-200 cp | `worried`, `uncomfortable1` | | |
| | OK move | -50 to +50 cp | `attentive1`, `thoughtful1` | | |
| | Mistake | User loses 50-200 cp | `cheerful1`, `enthusiastic2` | | |
| | Blunder! | User loses 200+ cp | `laughing1`, `success1`, `dance1` | | |
| | User checkmates | Game over | `sad2`, `furious1`, `rage1` | | |
| | Stockfish wins | Game over | `enthusiastic1`, `dance2`, `proud3` | | |
| ### Libraries (all browser-based, no backend needed) | |
| - **chess.js** - Chess logic, move validation, game state | |
| - **chessboard.js** - Interactive board UI | |
| - **stockfish.js** - Stockfish WASM for move generation & evaluation | |
| --- | |
| ## Questions | |
| ### Q1: Reachy's allegiance? | |
| **Should Reachy root for Stockfish (funny) or for you (supportive)?** | |
| - [ x ] **Stockfish** - Reachy is happy when you blunder, sad when you play well (funnier!) | |
| - [ ] **You** - Reachy cheers your good moves, sad when you blunder (supportive) | |
| ### Q2: Stockfish difficulty? | |
| **Should Stockfish play at full strength or be adjustable?** | |
| - [ ] **Full strength** - Maximum pain, Reachy will be happy a lot | |
| - [ x ] **Adjustable** - Slider to set ELO (e.g., 800-3000) | |
| - [ ] **Fixed weaker** - Set to ~1500 ELO for casual play | |
| ### Q3: Reaction frequency? | |
| **How often should Reachy react?** | |
| - [ x ] **Every move** - Constant reactions (might be chaotic) | |
| - [ ] **Significant moves only** - Only react to mistakes/good moves (>50cp change) | |
| - [ ] **Dramatic moments** - Only blunders, brilliant moves, and game end | |
| ### Q4: Additional features? | |
| **Any extras you'd like?** | |
| - [ ] **Move commentary** - Brief text explaining why the move was good/bad | |
| - [ x ] **Sound effects** - Reachy makes sounds with emotions --> Note that the emotions already have sounds when played ! | |
| - [ ] **Game history** - Show evaluation graph over time | |
| - [ ] **Hints** - Button to ask Stockfish for a hint | |
| --- | |
| ## Implementation - DONE! | |
| ### How to Run | |
| 1. Make sure the Reachy Mini daemon is running (on port 8000) | |
| 2. Run the app: | |
| ```bash | |
| cd /home/remi/reachy_mini_apps/chess_emotions_app | |
| python -m chess_emotions_app.main | |
| ``` | |
| 3. Open http://localhost:8042/static/index.html in your browser | |
| 4. Play chess! Reachy will react to every move. | |
| ### What Was Implemented | |
| - **Web UI** with chessboard.js (drag & drop pieces) | |
| - **Stockfish 16 WASM** running in browser with adjustable ELO (800-2800) | |
| - **Live evaluation bar** showing position advantage | |
| - **Emotion mapping** based on centipawn changes: | |
| - Brilliant move (>200cp gain): Reachy gets scared/anxious | |
| - Good move (50-200cp): Reachy is uncomfortable | |
| - Neutral move: Reachy watches attentively | |
| - Mistake (-50 to -200cp): Reachy is cheerful | |
| - Blunder (>200cp loss): Reachy laughs and dances! | |
| - Game over: Rage if you win, celebration if Stockfish wins | |
| ### Files | |
| - `static/index.html` - Chess UI layout | |
| - `static/style.css` - Dark theme styling | |
| - `static/main.js` - Chess logic, Stockfish integration, emotion triggers | |
| - `main.py` - Minimal Python wrapper (serves static files) | |