# Wrdler: Implementation Requirements **Version:** 0.0.2 **Status:** All Features Complete - Ready for Deployment **Last Updated:** 2025-01-31 This document breaks down the implementation tasks for Wrdler using the game rules described in `specs.md`. Wrdler is based on BattleWords but with a simplified 8x6 grid, horizontal-only words, and free letter guesses at the start. **Current Status:** ✅ All Phase 1 requirements complete, 100% tested (25/25 tests passing) ## Key Differences from BattleWords - 8x6 grid instead of 12x12 - One word per row (6 total) instead of flexible placement - Horizontal words only (no vertical) - No radar/scope visualization - 2 free letter guesses at game start ## Implementation Details (v0.0.2) - **Tech Stack:** Python 3.12.8, Streamlit 1.51.0, numpy, matplotlib - **Architecture:** Single-player, local state in Streamlit session state - **Grid:** 8 columns × 6 rows (48 cells) with exactly six words - **Word Placement:** Horizontal-only, one word per row, no overlaps - **Entry Point:** `app.py` - **Testing:** pytest with 25/25 tests passing (100%) - **Development Time:** ~12.75 hours across 7 sprints ## Streamlit Components (Implemented in v0.0.2) - State & caching ✅ - `st.session_state` for `puzzle`, `grid_rows`, `grid_cols`, `revealed`, `guessed`, `score`, `last_action`, `can_guess` - `st.session_state.points_by_word` for per-word score breakdown - `st.session_state.letter_map` derived from puzzle - `st.session_state.selected_wordlist` for sidebar picker - `st.session_state.show_incorrect_guesses` toggle - `st.session_state.show_challenge_share_links` toggle (default OFF) - `st.session_state.free_letters` and `free_letters_used` for free letter tracking - Layout & structure ✅ - `st.title`, `st.subheader`, `st.markdown` for headers - `st.columns(8)` to render the 8×6 grid (6 rows) - `st.sidebar` for secondary controls - `st.expander` for high scores and stats - Widgets (interaction) ✅ - `st.button` for each grid cell (48 total) with unique `key` - Circular green gradient free letter choice buttons (2 at game start) - `st.form` + `st.text_input` + `st.form_submit_button("OK")` for word guessing - `st.button("New Game")` to reset state - Sidebar `selectbox` for wordlist selection (classic, fourth_grade, wordlist) - Visualization ✅ - Ocean-themed gradient background - No animated radar (removed in Sprint 3) - Responsive 8×6 grid layout - Cell state indicators (unrevealed, letter, empty, completed) - Control flow ✅ - App reruns on interaction using `st.rerun()` - Game over dialog with final score and tier display ## Folder Structure (Implemented) - `app.py` – Streamlit entry point ✅ - `wrdler/` – Python package ✅ - `__init__.py` (version 0.0.2) - `models.py` – data models and types (rectangular grid support) - `word_loader.py` – load/validate/cached word lists - `generator.py` – word placement (8x6, horizontal only, one per row) - `logic.py` – game mechanics (reveal, guess, scoring, tiers, free letters) - `ui.py` – Streamlit UI composition (8×6 grid rendering) - `audio.py` – background music system - `sounds.py` – sound effects management - `game_storage.py` – HF storage wrapper for Challenge Mode - `modules/` – shared utilities (storage, constants, file_utils) - `words/` – word list files (classic.txt, fourth_grade.txt, wordlist.txt) - `specs/` – documentation (specs.md, requirements.md, sprint reports) - `tests/` – unit tests (test_sprint6_integration.py with 7 comprehensive tests) - `static/` – PWA assets (manifest.json, service-worker.js, icons) ## Phase 1: Wrdler v0.0.2 (Complete) ✅ **Goal:** A playable 8x6 grid game with free letter guesses, horizontal-only words, and Challenge Mode support. **Status:** ✅ All requirements complete, 7/7 sprints finished, 100% test pass rate ### 1) Data Models ✅ (Sprint 1) - ✅ `Coord(x:int, y:int)` with `in_bounds_rect()` for rectangular grid validation - ✅ `Word(text:str, start:Coord, direction:str{"H"}, cells:list[Coord])` (H only) - ✅ `Puzzle(words:list[Word], grid_rows:int, grid_cols:int, uid:str)` - ✅ `GameState(grid_rows:int, grid_cols:int, puzzle:Puzzle, revealed:set[Coord], guessed:set[str], score:int, free_letters:set[str], free_letters_used:int, ...)` **Acceptance:** ✅ Types implemented and fully integrated (13/13 tests passing) ### 2) Word List ✅ (Sprint 1) - ✅ English word list filtered to alphabetic uppercase, lengths in {4,5,6} - ✅ Loader centralized in `word_loader.py` with caching - ✅ Three word lists: classic, fourth_grade, wordlist **Acceptance:** ✅ Loading function returns lists by length with >= 25 words per length ### 3) Puzzle Generation (8x6 Horizontal) ✅ (Sprint 2) - ✅ Randomly place 6 words on 8x6 grid, one per row - ✅ **Word length requirement:** Each puzzle must have exactly 2 four-letter words, 2 five-letter words, and 2 six-letter words - ✅ Constraints: - Horizontal (left→right) only - One word per row (no stacking) - No overlapping letters - ✅ Retry strategy with max attempts - ✅ Deterministic seeding support **Acceptance:** ✅ Generator returns valid `Puzzle` with 6 words, no collisions, in-bounds (5/5 tests passing) ### 4) Free Letter Guesses ✅ (Sprint 4) - ✅ At game start, show 2 circular green gradient buttons for letter selection - ✅ On selection, reveal all instances of that letter in the grid - ✅ Mark as used; disable buttons after 2 uses - ✅ Sound effects play on reveal (hit/miss) - ✅ Set `can_guess=True` after revealing letters **Acceptance:** ✅ Both free letters properly reveal all matching cells; buttons disabled appropriately; UI renders correctly ### 5) Game Mechanics ✅ (Sprint 1, 6) - ✅ Reveal: Click a covered cell to reveal letter or mark empty - ✅ Guess: After revealing, guess word (4-6 letters) - ✅ Scoring: Base + bonus for unrevealed cells - ✅ End: All words guessed or all word letters revealed - ✅ Incorrect guess limit: 10 per game - ✅ Auto-mark completed words when all letters revealed **Acceptance:** ✅ Unit tests cover reveal, guess gating, scoring, tiers, auto-completion (7/7 integration tests passing) ### 6) UI (Streamlit) ✅ (Sprint 5) - ✅ Layout: - Title and instructions - Left: 8×6 grid using `st.columns(8)` with 6 rows - Right: Score panel, guess form, incorrect guess history - Sidebar: New Game, wordlist select, game mode, settings - ✅ Visuals: - Ocean gradient background - Covered vs revealed cell styles (40px buttons) - Completed word highlighting - Free letter selection UI with circular buttons **Acceptance:** ✅ Users can play end-to-end; all features functional; responsive design ### 7) Challenge Mode ✅ (Inherited from BattleWords) - ✅ Parse `game_id` from query params - ✅ Load game settings from HF repo - ✅ Share button generates shareable URL - ✅ Display top 5 leaderboard in Challenge Mode banner - ✅ "Show Challenge Share Links" toggle (default OFF) **Acceptance:** ✅ URL with `game_id` loads correctly; share button works; leaderboard displays properly ### 8) Comprehensive Tests ✅ (Sprint 6) - ✅ Placement validity (bounds, no overlaps, correct counts) - ✅ Scoring logic and bonuses - ✅ Free letter reveal behavior (2-letter limit) - ✅ Guess gating and word validation - ✅ Game completion detection - ✅ Auto-mark completed words - ✅ State consistency validation **Test Results:** ✅ 25/25 tests passing (100%) ## Sprint Completion Summary (v0.0.2) | Sprint | Description | Time | Tests | Status | |--------|-------------|------|-------|--------| | Sprint 1 | Core Data Models | 3h | 13/13 ✅ | Complete | | Sprint 2 | Puzzle Generator | 3h | 5/5 ✅ | Complete | | Sprint 3 | Remove Radar | 0.5h | N/A | Complete | | Sprint 4 | Free Letters UI | 2h | Manual ✅ | Complete | | Sprint 5 | Grid UI Updates | 1.25h | Syntax ✅ | Complete | | Sprint 6 | Integration Testing | 2h | 7/7 ✅ | Complete | | Sprint 7 | Documentation | 1h | N/A | Complete | | **Total** | **All Features** | **12.75h** | **25/25** | **Complete ✅** | **All known issues resolved. All TODO items completed.** ## Future Roadmap ### v0.3.0 (Next Phase) - 📋 Local persistent storage in `~/.wrdler/data/` - 📋 High score tracking and display - 📋 Player statistics - 📋 Enhanced UI animations ### v1.0.0 (Long Term) - 📋 Multiple difficulty levels - 📋 Daily puzzle mode - 📋 Internationalization (i18n) - 📋 Performance optimizations ## Deployment Targets ✅ ### Supported Platforms (v0.0.2) - ✅ **Hugging Face Spaces** (primary) - Dockerfile deployment - ✅ **Docker** - Containerization with provided Dockerfile - ✅ **Local Development** - Run with `streamlit run app.py` - ✅ **PWA** - Installable as Progressive Web App on desktop and mobile ### Deployment Status **Ready for production deployment!** All features tested and documented. --- **Last Updated:** 2025-01-31 **Version:** 0.0.2 **Status:** All Features Complete - Ready for Deployment 🚀 ## Test File Location All test files must be placed in the `/tests` folder. This ensures a clean project structure and makes it easy to discover and run all tests.