Skip to content

Latest commit

 

History

History
58 lines (36 loc) · 2.47 KB

PROJECT_MEMORY.md

File metadata and controls

58 lines (36 loc) · 2.47 KB

Retro Snake - Project Memory

Date: 2026-01-10 Framework: .NET 10 Platform: Windows (Console)

1. Project Overview

"Retro Snake" is a modular, SOLID-compliant Snake game implementation. It uses a Strategy pattern for levels and is decoupled via interfaces for Rendering, Input, and Audio.

2. Architecture

  • Engine (GameEngine.cs): Passive orchestrator of game state (refactoring in progress).
  • Logic (Logic/): Game rules via IGameLogic. LevelManager handles level progression.
  • Infrastructure: Implementations for Spectre.Console, NAudio, and File IO.
  • Remote Level (gRPC): Level 4+ is handled by SnakeGame.Server via gRPC.

3. Game Mechanics & Levels

  • Level 1 (Classic): Standard rules.
  • Level 2 (Gluttony): Yellow food -> Growth + Slow Motion.
  • Level 3 (Snaketris): Falling Tetris blocks (Collision kills).
  • Level 4 (Tron Mode - gRPC):
    • Remote AI Snake avoids player.
    • Player can trap AI Snake to "win" (AI dies).
    • Full audio feedback (Eat, Game Over) integrated.
    • Transition artifacts (frozen animations) fixed via state clearing.

4. Current Tasks & Refactoring (Completed 2026-01-16)

  • Fixed TUI Level Transition Speed: Reset game loop timer after blocking animations in ConsoleFrontend.

  • Fixed MonoGame Level Cleanup: Ensured TetrisBlocks and SpecialFoodPositions are cleared in LevelManager.

  • Prevented 180-Degree "Suicide" Turns:

    • Implemented DirectionQueue in GameState.

    • Updated all IInputHandler implementations to validate and buffer inputs.

    • GameEngine now dequeues one valid move per logical tick.

  • Enhanced Engine Robustness: Added frame-clamping to Tick() to prevent speed-bursts after lag spikes.

5. Architecture Notes

  • Input Handling: Now follows a "Producer-Consumer" pattern. Input handlers produce directions into a queue; the engine consumes them. This makes the game feel much more responsive and eliminates input-based bugs.

  • State Management: LevelManager is now the central authority for cleaning up level-specific state during transitions.

6. Future Improvements

  • Settings Persistence: Expand settings to include sound volume and window sizes.
  • Multiplayer: Support for local or network-based competitive play.
  • Advanced AI: Improve Tron AI to use better pathfinding (A*).
  • Unit Tests: Implement comprehensive tests for game logic and level strategies.