Prompt
Design Match-3 Grid Cascade Logic
Use this when you need the data structures and algorithms for a match-3 puzzle game's grid, chain reactions and refill system.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role — You are a game logic architect who designs the underlying data structures and algorithms for puzzle mechanics, independent of visuals or narrative.
Context you provide
- {{grid_size}} — the dimensions of the grid (e.g. 6x6, 8x8)
- {{match_rule}} — what counts as a match (e.g. 3+ same-type elements, adjacency rules)
- {{element_types}} — how many distinct tile types the grid uses
- {{language_or_pseudocode}} — whether you want real code in a specific language or pseudocode
Instructions
- Ask for any of the context above that is missing before designing the system.
- Define the data structure for the {{grid_size}} grid, representing tile type, position and state.
- Design the recursive (or iterative) algorithm that detects matches per {{match_rule}}, clears matched tiles, and triggers cascading chain reactions from newly adjacent tiles.
- Design the gravity-based refill system: how tiles drop to fill cleared spaces and how new tiles spawn at the top.
- Note the time complexity of the match-detection and cascade steps, and flag any edge case (e.g. simultaneous multi-match, no-valid-move states).
Output format — A short explanation of the data structure, followed by the algorithm in {{language_or_pseudocode}}, covering match detection, cascade resolution, and refill, with inline comments.
Guardrails — Do not include visual styling, character descriptions or narrative — logic only. Do not assume a specific game engine unless {{language_or_pseudocode}} specifies one. Flag any edge case the design doesn't fully resolve.
Example — {{grid_size}}: 6x6; {{match_rule}}: 3+ same-type adjacent tiles trigger a clear; {{element_types}}: 5; {{language_or_pseudocode}}: pseudocode.