Design the object model and move-validation flow for a two-player game on a `7 x 7` board. Make the API or object boundaries explicit, then cover invariants, edge cases, testing strategy, and operational trade-offs.
# Model a Turn-Based Cats and Rabbits Board Game
Design the object model and move-validation flow for a two-player game on a `7 x 7` board. Each player starts with two cats, two rabbits, and one snail. Cats move up to three squares horizontally or vertically; rabbits move up to two diagonally; snails move one square in any direction and cannot capture. Friendly pieces block movement. Cats and rabbits may capture enemy pieces they traverse, and movement ends at the first capture. A turn may not end with the player's snail capturable; if no legal move removes that danger, the player loses.
### Constraints & Assumptions
- Move rules must be extensible without duplicating board logic.
- A proposed move is validated before mutating game state.
### Clarifying Questions to Ask
- Can a cat or rabbit stop before its maximum distance without capturing?
- Is danger evaluated against every legal opponent move on the resulting board?
### What a Strong Answer Covers
- Piece-specific movement, occupancy, capture, and turn state.
- Transactional simulation for snail-safety validation.
- Legal-move generation and the no-escape loss condition.
### Follow-up Questions
- How would you add undo and replay?
- Which tests expose captures, blockers, and danger-check bugs?
Quick Answer: Design the object model and move-validation flow for a two-player game on a `7 x 7` board. Make the API or object boundaries explicit, then cover invariants, edge cases, testing strategy, and operational trade-offs.
Design the object model and move-validation flow for a two-player game on a 7 x 7 board. Each player starts with two cats, two rabbits, and one snail. Cats move up to three squares horizontally or vertically; rabbits move up to two diagonally; snails move one square in any direction and cannot capture. Friendly pieces block movement. Cats and rabbits may capture enemy pieces they traverse, and movement ends at the first capture. A turn may not end with the player's snail capturable; if no legal move removes that danger, the player loses.
Constraints & Assumptions
Move rules must be extensible without duplicating board logic.
A proposed move is validated before mutating game state.
Clarifying Questions to Ask Guidance
Can a cat or rabbit stop before its maximum distance without capturing?
Is danger evaluated against every legal opponent move on the resulting board?
What a Strong Answer Covers Guidance
Piece-specific movement, occupancy, capture, and turn state.
Transactional simulation for snail-safety validation.
Legal-move generation and the no-escape loss condition.
Follow-up Questions Guidance
How would you add undo and replay?
Which tests expose captures, blockers, and danger-check bugs?