NEVER Do (Expert Anti-Patterns)
Design & Player Experience
- NEVER punish experimentation; strictly provide Undo/Reset functionality to allow risk-free hypothesis testing.
- NEVER require pixel-perfect input for logic puzzles; strictly use Grid Snapping or large, forgiving hitboxes.
- NEVER allow undetected Soft-Locks (unsolvable states); strictly notify the player or provide immediate backtracking.
- NEVER hide the rules of the world; strictly ensure visual feedback is instant and unambiguous (e.g., powered wires must glow).
- NEVER skip the Non-Verbal Tutorial phase; strictly introduce mechanics in isolation before combining them.
Grid Logic & State
- NEVER use floating-point numbers (
Vector2) for grid coordinates; strictly use Vector2i to prevent precision drift. - NEVER use
_process()for grid-state or win-condition validation; strictly trigger checks only when a piece moves. - NEVER rely on the
SceneTreestructure as the source of truth; strictly maintain grid data in a separate script/dictionary. - NEVER modify a Dictionary or Array size while iterating over it; strictly use a copy or a separate queue for modifications.
- NEVER calculate heavy recursive solvers in
_process(); strictly cache results or use threaded workers for solve-checks. - NEVER ignore diagonal rules in pathfinding; strictly configure
AStarGrid2D.diagonal_modecorrectly.
Architecture & Performance
- NEVER ship dual undo authorities; strictly use Godot's built-in UndoRedo via puzzle_undo_manager.gd — do not also maintain a hand-rolled Command stack.
- NEVER intermingle "do" and "undo" logic in the same function; strictly maintain separation for predictable rollbacks.
- NEVER use exact floating-point equality (==); strictly use
is_equal_approx()for spatial constraints. - NEVER use
load()for resetting large rooms dynamically; strictly useResourceLoader.load_threaded_request(). - NEVER leave Tween objects unreferenced; strictly kill active tweens before starting new movement on the same object.
🛠 Expert Components (scripts/)
MANDATORY reads before implementing the matching system:
1. puzzle_undo_manager.gd — sole undo authority (
UndoRedo)
2. grid_manager.gd — Vector2i grid as truth
3. puzzle_state_validator.gd — soft-lock / win checks on commit
Original Expert Patterns
- puzzle_undo_manager.gd - Godot
UndoRedowrapper for move do/undo (golden path).
Modular Components
- grid_manager.gd - Vector2i board state decoupled from SceneTree.
- grid_tween_mover.gd - Kill-before-recreate Tweens for piece moves.
- puzzle_state_validator.gd - Win / soft-lock validation after commits.
- grid_input_manager.gd - Snapped grid input.
- match_three_logic.gd - Match-3 resolve / cascade helpers.
- puzzle_pathfinder.gd -
AStarGrid2Dhints (diagonal_mode). - puzzle_saver.gd - Level / snapshot serialization.
- puzzle_validator.gd - Broader solvability checks.
- puzzle_history.gd - Thin UndoRedo action helpers (complements undo manager).
- tile_animator.gd - Tile juice without owning state.
- shuffle_bag.gd - Fair random piece bags.
- perspective_overlay.gd - Perspective / overlay puzzles.
- sleepy_block.gd - Timed / sleeping block mechanic sample.
Do NOT load command_undo_redo.gd — legacy hand-rolled Command stack superseded by
UndoRedo.
Core Loop
- Observe → 2. Hypothesize → 3. Commit move → 4. Validate → 5. Undo/Reset if needed
Decision Trees
Genre → scripts
| Puzzle type | MANDATORY reads |
|-------------|-----------------|
| Sokoban / push grid | grid_manager.gd, grid_tween_mover.gd, puzzle_undo_manager.gd, puzzle_state_validator.gd |
| Match-3 | match_three_logic.gd, grid_tween_mover.gd, puzzle_undo_manager.gd |
| Physics / spatial | Snap on settle → then same undo/validator path; do not treat rigid bodies as truth |
| Hints / solvers | puzzle_pathfinder.gd (AStarGrid2D.diagonal_mode) |
Undo authority
| Need | Action |
|------|--------|
| Player undo/redo | Only puzzle_undo_manager.gd |
| Level editor history | Still UndoRedo — wrap editor actions the same way |
Skill Chain
| Phase | Skills | Purpose |
|-------|--------|---------|
| 1. Data | dictionaries, resources | Grid truth, level .tres |
| 2. Input | godot-input-handling | Snapped moves |
| 3. Motion | godot-tweening | Piece Tweens |
| 4. AI/hints | godot-navigation-pathfinding | A* hints |
| 5. Persist | godot-save-load-systems | Level / progress |
Common Pitfalls
| Pitfall | Solution |
|---------|----------|
| Dual undo APIs | Delete Command-stack path; use UndoRedo manager only |
| Win check in _process | Validate on move commit via state validator |
| Float grid coords | Vector2i only |
MANDATORY for depth beyond decision trees and script catalog: puzzle-elite-implementations.md. Do NOT Load on first-pass wiring — use bundled
scripts/first.
Architecture Overview
1. Command Pattern (Undo System)
Essential for puzzle games. Never punish testing.