Skip to content

Conversation

@dmccoystephenson
Copy link
Member

No description provided.

…entRepository, keyDownEventHandler, and ophidian modules
…ository

refactor: update snake part management to use SnakePartRepository
…ository

feat: implement EnvironmentRepository for managing game environment
…prove initialization in PyEnvLibEnvironmentRepository
Copilot AI and others added 30 commits September 26, 2025 02:28
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
…b-ff30-4755-a820-b56b627b15c5

Fix: Maintain Proportional Scaling and Centering on Window Resize with Complete Window Size Persistence
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
…e-e934-442b-a458-2d5a2e1c718c

Implement comprehensive Options Menu Screen with enhanced button feedback and ESC key navigation
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Created GameEngine class for pure gameplay logic
- Added InputHandler abstraction with implementations for GUI and Text UI
- Added GameRenderer abstraction for rendering
- Refactored Ophidian class to use abstractions
- Maintains backward compatibility through property delegates
- Added comprehensive architecture documentation

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Added InputAction.SELECT for menu selection
- Updated TextUIInputHandler to map Enter key (\r, \n) to SELECT action
- Fixed run_text_menu to use InputAction.SELECT instead of raw key check
- Resolves issue where pressing Enter wouldn't start the game

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Added 13 tests for GameEngine (core gameplay logic)
  - Tests initialization, game state, direction input, updates, and integration
- Added 25 tests for InputHandler abstraction
  - Tests InputAction constants, DirectionMapper mappings, and TextUIInputHandler
  - Validates critical direction mappings (UP=0, LEFT=1, DOWN=2, RIGHT=3)
  - Tests all key bindings including Enter, ESC, WASD, and arrow keys
- All 38 new tests passing
- Tests ensure game functionality won't break with future changes

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Fixed environment tests: Added 'difficulty' attribute to mock config
- Fixed keyDownEventHandler tests: Added 'key_bindings', 'fullscreen', and 'limit_tick_speed' attributes to mock config
- All 131 tests now passing (previously 17 were failing)

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Fixed bug where restarting game spawned duplicate food and snake entities
- Removed duplicate initialization code in Ophidian.initialize()
- GameEngine._initialize_level() already handles entity spawning
- Added test to prevent regression: test_multiple_initializations_spawn_single_entities
- All 132 tests passing

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Fixed KeyError that occurred when restarting game in pygame UI mode
- Root cause: renderer held stale references to old environment after reinitialize
- Solution: delegate to game_engine.check_for_level_progress_and_reinitialize() and recreate renderer with fresh environment references
- Added 2 tests to prevent regression: test_reinitialize_clears_old_environment and test_multiple_reinitializations_no_stale_entities
- All 134 tests passing

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Created .github/workflows/text-ui-gameplay.yml workflow
- Added comprehensive integration test: tests/integration/test_text_ui_gameplay.py
- Test verifies: initial state, game mechanics (movement), restart functionality, and text renderer output
- Workflow runs on push/PR to main and develop branches
- All 134 existing tests still passing
- New integration test passes successfully

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Fixed termios error in GitHub Actions by gracefully handling missing TTY
- Added skip_terminal_init parameter to Ophidian for testing/CI environments
- Updated TextRenderer.enable_raw_mode() to catch termios/OSError exceptions
- Integration test now runs successfully in CI without requiring terminal
- All 77 existing unit tests still passing
- Integration test verified locally

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Performance Enhancements:
- Added configurable framerate limiting (default 30 FPS)
- Optimized screen clearing with ANSI escape codes (Unix/Linux/Mac)
- Batch rendering: build frame in memory, single print operation
- Decoupled input handling from game speed for better responsiveness
- Reduced CPU usage from ~100% to ~5-15%

Configuration Changes:
- Added text_ui_target_fps setting (default: 30)
- Saved/loaded in config/settings.json

Code Improvements:
- Delta-time based frame timing in run_text_ui()
- Sleep during idle periods to prevent busy-waiting
- Fixed short input timeout (0.01s) for responsive controls
- Single-call rendering reduces I/O operations

Testing:
- All 77 existing tests passing
- Integration test verified
- Updated test for new clear_screen implementation
- Added comprehensive performance documentation

Documentation:
- Created docs/TEXT_UI_PERFORMANCE.md with detailed analysis
- Documented before/after metrics and technical details

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
…sed-ui-option

Add text-based UI option with clean architecture, comprehensive testing, CI/CD verification, and performance optimizations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants