mcpField
G
godot-genre-puzzle

godot-genre-puzzle

github.com/thedivergentai開発907299 回インストール2 週間前に更新
リポジトリ

godot-genre-puzzle について

Godot のパズルゲーム開発者向けの設計・実装スキルガイドです。グリッド状態、取り消し、検証、再利用可能な部品を扱い、ソフトロックを防ぎながら試行を取り消せる設計を重視します。

主な機能

  1. 01Vector2i によるグリッド状態管理
  2. 02UndoRedo による操作履歴
  3. 03移動確定時の勝利・ソフトロック判定
  4. 04グリッド入力のスナップと移動 Tween
  5. 05Match-3 と A* 経路探索の部品

活用シーン

  1. 01Sokoban 型の押し出しパズルの実装
  2. 02Match-3 の解決処理の構築
  3. 03グリッドパズルへの経路探索ヒント追加

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/thedivergentai/game-dev-agentic-skills --skill godot-genre-puzzle

インストール後、Claude Code で/godot-genre-puzzleを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
migration-notes.md
puzzle-elite-implementations.md
scripts/
command_undo_redo.gd
grid_input_manager.gd
grid_manager.gd
grid_tween_mover.gd
match_three_logic.gd
perspective_overlay.gd
puzzle_history.gd
puzzle_pathfinder.gd
puzzle_saver.gd
puzzle_state_validator.gd
puzzle_undo_manager.gd
puzzle_validator.gd
shuffle_bag.gd
sleepy_block.gd
tile_animator.gd

詳細

絶対に避けること(熟練者が陥りがちなアンチパターン)

設計とプレイヤー体験
  • 実験を絶対に罰しないでください。リスクなしで仮説を試せるよう、Undo/Reset 機能を必ず用意してください。
  • ロジックパズルでピクセル単位の正確な入力を絶対に要求しないでください。必ず グリッドスナップ を使用するか、許容範囲の広い大きなヒットボックスを用意してください。
  • 検出できない ソフトロック(解決不能な状態)を絶対に許さないでください。必ずプレイヤーに通知するか、すぐに元に戻せるようにしてください。
  • 世界のルールを絶対に隠さないでください。視覚的なフィードバックが即座に、明確に伝わるよう徹底してください(例:通電中のワイヤーは光らせる必要があります)。
  • 非言語チュートリアルの段階を絶対に省略しないでください。仕組みを組み合わせる前に、それぞれを個別に導入してください。
グリッドロジックと状態
  • グリッド座標に浮動小数点数(Vector2)を絶対に使わないでください。精度のずれを防ぐため、必ず Vector2i を使用してください。
  • グリッド状態や勝利条件の検証に _process() を絶対に使わないでください。必ずピースが動いたときだけチェックを実行してください。
  • 真実の情報源として SceneTree の構造に絶対に依存しないでください。グリッドデータは必ず別のスクリプト/辞書で管理してください。
  • 反復処理中に Dictionary や Array のサイズを絶対に変更しないでください。変更には必ずコピーまたは別のキューを使用してください。
  • 負荷の高い再帰的なソルバーを _process() で絶対に計算しないでください。解答チェックの結果をキャッシュするか、必ずスレッドワーカーを使用してください。
  • 経路探索で斜め移動のルールを絶対に無視しないでください。AStarGrid2D.diagonal_mode を必ず適切に設定してください。
アーキテクチャとパフォーマンス
  • Undo の権限を二重に持たせて絶対にリリースしないでください。puzzle_undo_manager.gd を通じて Godot 組み込みの UndoRedo を必ず使用し、独自実装の Command スタックも併用しないでください。
  • 「実行」と「Undo」のロジックを同じ関数に絶対に混在させないでください。予測可能なロールバックのため、必ず分離してください。
  • 浮動小数点数の完全一致(==)を絶対に使わないでください。空間的な制約には必ず is_equal_approx() を使用してください。
  • 大きな部屋を動的にリセットする際に load() を絶対に使わないでください。必ず ResourceLoader.load_threaded_request() を使用してください。
  • Tween オブジェクトを参照されない状態で絶対に残さないでください。同じオブジェクトで新たな移動を開始する前に、必ず実行中の Tween を停止してください。

🛠 熟練者向けコンポーネント(scripts/)

必須:対応するシステムを実装する前に、以下を読んでください。

  1. puzzle_undo_manager.gd — 唯一の Undo 管理機構(UndoRedo)
  2. grid_manager.gd — Vector2i グリッドを真実の情報源として使用
  3. puzzle_state_validator.gd — コミット時のソフトロック/勝利チェック
オリジナルの熟練者向けパターン
  • puzzle_undo_manager.gd - 移動の実行/Undo を扱う Godot UndoRedo ラッパー(推奨パターン)。
モジュール式コンポーネント

command_undo_redo.gd は読み込まないでください。UndoRedo に置き換えられた、独自実装のレガシー Command スタックです。


コアループ

  1. 観察する → 2. 仮説を立てる → 3. 手を打つ → 4. 検証する → 5. 必要に応じて 元に戻す/リセットする

判断ツリー

ジャンル → スクリプト
パズルの種類必須の読み込み対象
倉庫番/押し動かすグリッドgrid_manager.gd, grid_tween_mover.gd, puzzle_undo_manager.gd, puzzle_state_validator.gd
マッチ3match_three_logic.gd, grid_tween_mover.gd, puzzle_undo_manager.gd
物理/空間停止時にスナップしてから、同じ Undo/バリデーターの経路を使用します。リジッドボディを真実として扱わないでください
ヒント/ソルバーpuzzle_pathfinder.gd(AStarGrid2D.diagonal_mode)
Undo の管理元
要件対応
プレイヤーの Undo/Redopuzzle_undo_manager.gd のみ
レベルエディターの履歴引き続き UndoRedo を使用します。同じ方法でエディターの操作をラップしてください

スキルチェーン

フェーズスキル目的
1. データdictionaries, resourcesグリッドの真の状態、レベル .tres
2. 入力godot-input-handlingスナップされた移動
3. モーションgodot-tweeningピースの Tween
4. AI/ヒントgodot-navigation-pathfindingA* ヒント
5. 永続化godot-save-load-systemsレベル/進行状況

よくある落とし穴

落とし穴解決策
Undo API が二重にあるCommand スタックの経路を削除し、UndoRedo マネージャーのみを使用します
_process 内で勝利判定するステートバリデーターを使い、手の確定時に検証します
グリッド座標が浮動小数点数Vector2i のみを使用します

判断ツリーとスクリプトカタログの範囲を超えて詳しく知る場合は、必ず puzzle-elite-implementations.md を参照してください。初回の配線時には読み込まないでください。まず同梱の scripts/ を使用してください。

アーキテクチャの概要

1. コマンドパターン(Undo システム)

パズルゲームに不可欠です。テストをためらわせる設計にしないでください。


## Godot-Specific Tips

*   **Tweens**: Use `create_tween()` for all grid movements. It feels much better than instant snapping.
*   **Custom Resources**: Store level data (layout, starting positions) in `.tres` files for easy editing in the Inspector.
*   **Signals**: Use signals like `state_changed` to update UI/Visuals decoupled from the logic.

---

## Reference

> Progressive disclosure: open Official Documentation links only when researching a specific API;
> load Related Skills when routing work to a peer domain — do not preload the whole lattice.

### Official Documentation
- [UndoRedo](https://docs.godotengine.org/en/stable/classes/class_undoredo.html) — Built-in action history for do/undo/redo so puzzle experimentation does not require a hand-rolled command stack.
- [AStarGrid2D](https://docs.godotengine.org/en/stable/classes/class_astargrid2d.html) — Uniform-grid pathfinding (`diagonal_mode`, `jumping_enabled`) for hints and reachability on Sokoban-style boards.
- [Tween](https://docs.godotengine.org/en/stable/classes/class_tween.html) — Interruptible `create_tween()` motion for cell-to-cell feedback while logical `Vector2i` state updates immediately.
- [Using TileMaps](https://docs.godotengine.org/en/stable/tutorials/2d/using_tilemaps.html) — TileMapLayer workflows for painting walls/targets while keeping puzzle truth in a separate grid dictionary.
- [Saving games](https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html) — Persist level progress, stars, and mid-puzzle snapshots without relying on scene reload as save.
- [Using InputEvent](https://docs.godotengine.org/en/stable/tutorials/inputs/inputevent.html) — Device-agnostic click/drag/action routing for forgiving grid selection and move commits.
- [Resources](https://docs.godotengine.org/en/stable/tutorials/scripting/resources.html) — Store layouts and starting piece sets as `.tres`/`Resource` data editable in the Inspector.
- [Physics introduction](https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html) — RigidBody sleep, layers, and integration hooks for physics-driven puzzle pieces.
- [Idle and Physics Processing](https://docs.godotengine.org/en/stable/tutorials/scripting/idle_and_physics_processing.html) — Why win/soft-lock checks belong on move commits, not every `_process` frame.
- [Data preferences](https://docs.godotengine.org/en/stable/tutorials/best_practices/data_preferences.html) — Prefer integer grid keys (`Vector2i`) and explicit dictionaries over SceneTree-as-truth.
- [Runtime file loading and saving](https://docs.godotengine.org/en/stable/tutorials/io/runtime_file_loading_and_saving.html) — `FileAccess`/`user://` patterns for custom level JSON and editor export packs.
- [JSON](https://docs.godotengine.org/en/stable/classes/class_json.html) — Serialize compact puzzle boards when splitting `Vector2` fields for portable level files.

### Related Skills

#### Prerequisites
- [godot-input-handling](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-input-handling/SKILL.md) — Buffered InputEvent/action maps so grid clicks and directional moves stay device-agnostic and forgiving.
- [godot-signal-architecture](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-signal-architecture/SKILL.md) — Safe `state_changed` / `level_complete` wiring so UI and VFX stay decoupled from grid truth.
- [godot-project-foundations](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-project-foundations/SKILL.md) — Autoload/project layout baselines before stacking undo managers, savers, and level packs.

#### Complements
- [godot-tweening](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-tweening/SKILL.md) — Deeper Tween composition when cell moves, match clears, and resets need interruptible juice without logic races.
- [godot-save-load-systems](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-save-load-systems/SKILL.md) — Progress ownership, versioning, and threaded loads beyond per-level JSON snapshots.
- [godot-tilemap-mastery](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-tilemap-mastery/SKILL.md) — TileMapLayer painting, custom data, and terrain patterns that visualize walls while scripts own solvability.
- [godot-navigation-pathfinding](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/SKILL.md) — Broader Navigation/A* stacks when puzzle hints outgrow a single `AStarGrid2D` region.
- [godot-2d-physics](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-2d-physics/SKILL.md) — RigidBody sleep, layers, and queries for physics puzzles that still need deterministic settle/win checks.
- [godot-state-machine-advanced](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-state-machine-advanced/SKILL.md) — Phase FSMs (observe → move → resolve → win) when puzzles mix animation locks with input gates.
- [godot-camera-systems](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-camera-systems/SKILL.md) — Camera2D/3D framing and unproject helpers for perspective/world-space puzzle overlays.
- [godot-ui-containers](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-ui-containers/SKILL.md) — Minimal undo/reset HUD layouts that stay non-intrusive during non-verbal tutorials.

#### Downstream / consumers
- [godot-monte-carlo-balancer](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-monte-carlo-balancer/SKILL.md) — Sample solvability, move-count distributions, and soft-lock rates so level packs stay fair as mechanics combine.
- [godot-procedural-generation](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-procedural-generation/SKILL.md) — Generate candidate boards that still pass this skill's validators, undo constraints, and win-condition contracts.
- [godot-genre-roguelike](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-genre-roguelike/SKILL.md) — Consumes grid/undo patterns when dungeon runs embed discrete puzzle rooms or locked-door logic.

#### Master
- [godot-master](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-master/SKILL.md) — Library router and mirrored module entry for discovering this genre skill beside sibling domains.

コメント