Skip to content

Add FEN Support and Debug Panel for Testing#78

Open
walshb421 wants to merge 5 commits intomainfrom
add-fen-support
Open

Add FEN Support and Debug Panel for Testing#78
walshb421 wants to merge 5 commits intomainfrom
add-fen-support

Conversation

@walshb421
Copy link
Owner

Summary

Implements FEN (Forsyth-Edwards Notation) support for loading arbitrary chess positions, along with a debug panel UI for testing. This addresses Issue #77 and provides the testing infrastructure needed for future feature development like check detection (#76).

Changes

Backend (Python)

  • engine/fixtures.py: New module with 20+ predefined test positions organized by category (checkmates, special moves, check scenarios, etc.)
  • engine/board.py:
    • Added load_fen() method to parse FEN strings and initialize board state
    • Added to_fen() method to export current position as FEN
    • Added WebSocket callbacks for load_fen, load_fixture, get_fixtures
    • Track en passant target square for FEN compatibility
    • Include turn and FEN in game state JSON

Frontend (Vue.js)

  • src/composables/chess.js: Added loadFen(), loadFixture(), getFixtures() methods and reactive state for turn, currentFen, fixtures
  • src/components/DebugPanel.vue: New debug panel component with:
    • Current game state display (turn, player, move number)
    • Current FEN display with copy-to-clipboard
    • FEN input field for loading arbitrary positions
    • Dropdown with categorized test fixtures
    • Reset board button
  • src/App.vue: Integrated DebugPanel with 'D' key toggle

Test Plan

  • Load starting position FEN and verify board displays correctly
  • Load a checkmate position (e.g., "fools_mate") and verify pieces are placed correctly
  • Load an en passant position and verify en passant capture works
  • Load a castling position and verify castling is available/blocked appropriately
  • Verify to_fen() exports correct FEN after making moves
  • Verify debug panel toggle works with 'D' key
  • Verify copy FEN button works
  • Verify fixture dropdown loads positions correctly

Closes #77

MCP Agent added 5 commits January 11, 2026 01:28
Add engine/fixtures.py with predefined chess positions for testing:
- Basic positions (starting, empty)
- Checkmate scenarios
- Special moves (en passant, castling)
- Check scenarios
- Pawn promotion positions
- Stalemate and endgame positions
- Add load_fen() method to parse FEN strings and set board state
- Add to_fen() method to export current position as FEN
- Add WebSocket callbacks for load_fen, load_fixture, get_fixtures
- Track en_passant_target for FEN compatibility
- Include turn and FEN in game state JSON
- Update en passant logic to work with FEN-loaded positions
- Convert indentation from tabs to spaces
- Add loadFen() to load arbitrary FEN positions
- Add loadFixture() to load named test fixtures
- Add getFixtures() to request fixture list from server
- Add reactive refs for turn, currentFen, and fixtures
- Update data watcher to handle new state fields
- Display current game state (turn, player, move number)
- Show current FEN with copy-to-clipboard button
- FEN input field to load arbitrary positions
- Dropdown with categorized test fixtures
- Reset board button
- Dark theme styling to match app
- Add DebugPanel component with toggle visibility
- Press D key to show/hide debug panel
- Add sidebar layout for debug panel
- Ignore keypress when typing in input fields
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.

Add FEN Support and Debug Panel for Testing

1 participant