Cat Trap
⬡ Algorithmic Containment on a Hex Grid
Cat Trap (classically known as Chat Noir or Circle the Cat) is a gamified application of Graph Theory. The game is played on a hexagonal lattice. The "Cat" is an intelligent agent programmed with a Breadth-First Search (BFS) algorithm to find the shortest path to the boundary. The player's goal is to remove nodes (darken the circles) to eliminate all possible paths to the edge.
This is a turn-based zero-sum game. Every move you make changes the topology of the graph. The challenge lies in the fact that hexagons have 6 degrees of freedom (neighbors), making them significantly harder to wall off than squares.
🧠 Predictive Logic & Breadth-First Search
To win, you must think like the algorithm:
- The Greedy Agent: The Cat will usually take the step that maximizes its distance from the center or minimizes distance to the edge.
- Visualizing the Net: Beginners try to build a wall directly next to the cat. This fails because the cat moves faster than you can build. You must visualize a wide perimeter radius (a "convex hull") and fill in the gaps 2-3 steps ahead of the cat.
🎮 Mechanics: Stochastic Start
Variability factors:
- Initial State: The board starts with several random blocks already placed. The difficulty of the round is largely determined by this random seed. Some configurations are mathematically unsolvable if the cat starts too close to an open edge.
- The "Reset" Loop: High-level play involves recognizing a bad seed immediately and restarting, rather than playing out a doomed scenario.
🏆 Mastery Strategy
1. The "Loose Net"
Build your wall at least 2 layers out from the cat. If the cat moves Right, do not block the immediate Right node. Block the node behind that one. You are herding the cat, not fighting it.
2. Fill the Gaps
Look for "chain" formations in the pre-existing blocks. Your goal is to connect these existing chains to form a closed loop. Prioritize closing the largest gaps first.
🛡️ Technical Implementation
AI notes:
- Pathfinding: The AI recalculates the path weights after every player click, ensuring it always exploits player mistakes instantly.
❓ FAQ
Is it always possible to win?
No. If the random starting blocks are sparse, the Cat (if played perfectly) has a mathematical guarantee of escape.
Why hexagons?
Hexagons provide more escape routes than squares, creating a richer tactical depth for containment puzzles.