wrdler / specs /requirements.md
Surn's picture
fix word distribution
5f8a848

ο»Ώ# 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.