Spatial PlanningSpatial

Observe → Think → Place → Verify

What is it

Read the board, think it through, then make your move — Tetris, 2048, and Klotski are all built on this.

How it plays

You are in no hurry: you run a few moves in your head first; after each placement the board reshapes itself, and an even cleverer solution appears — every move is quiet mental gymnastics.

Why learn it

This is the skeleton of all board and layout play — once "state → rule → new state" clicks, puzzle and strategy games all fall into place.

Core Loop
Board → Cell → Rule → State Change
Key Abstractions
Board · Grid · Path · Positional Relationship · State Space

Instant Playable Demo

Spatial Planning Demo
Loading game…
Rule Hints
Observe the board → Choose an action → Apply rules → Update the spatial state → Check for objectives → Generate a new board or next level.
Concept

Spatial planning patterns center around board, grid, path, or positional relationships as core data structures. Players observe the state, infer rules, and perform moves, swaps, or placements to transition the system from its current state to a target state. The fun comes from the "aha" moment—discovering an optimal or unique solution within constrained space. The primary design principle for spatial gameplay is "rules that are instantly understandable yet endlessly varied"—fewer initial rules lead to richer state evolution. Designers often face two major trade‑offs: first, rule simplicity versus exploding state space; simplifying rules lets players pick up quickly, but overly simple rules can make gameplay stale; conversely, adding rules increases depth but causes exponential growth in state space, making level design by hand or algorithm difficult. Second, spatial size versus strategic depth; expanding the grid offers more layout combinations and strategic options, but too large a grid hampers players’ ability to see the whole picture at once, weakening intuition. An counterintuitive insight is that modestly limiting the number of movable steps can actually spark creativity: when players must finish a goal within a limited number of moves, they must find more efficient paths or use the grid’s "blank" spaces to create chains, often encouraging exploration of hidden combinations more than unlimited freedom.

Role

This pattern transforms abstract rules into observable, manipulable spatial structures. It lets players rely on visual and spatial intuition instead of complex calculations, serving as the underlying framework for many mechanics such as puzzle, match‑clear, merge, and path‑planning. Spatial planning games typically feature simple rules but massive state spaces, yielding a "easy to learn, hard to master" quality.

Significance

The spatial planning pattern is a natural teaching tool for understanding state machines, search algorithms, combinatorial explosion, and heuristic evaluation. Developers can learn how to translate complex logical problems into intuitive grid operations, and how to shape the experience curve through level design rather than code complexity.

Core Gameplay System Breakdown

Core Loop Flowchart
Core Loop Flowchart
3.1 Problems Solved
  • Transform abstract rules into spatial actions that players can see.
  • Use a limited grid to create rich combinations and constraints.
  • Provide ongoing freshness through state changes without relying on complex narrative.
3.2 Learning Goals
  • Master grid/graph data structures and their traversal algorithms.
  • Design clear and extensible rule‑evaluation systems.
  • Control player experience through level generation and difficulty scaling.
3.3 Minimal Ruleset
  • Define the game space (grid, board, area).
  • Define interactive elements and their placement/movement rules.
  • Define win/lose or scoring conditions.
  • Update the spatial state after each action according to the rules.

Common Combos & Variants

Spatial + Match
Create instant feedback and chain reactions through matching rules.
Spatial + Merge
Combine positional strategy with resource upgrades to form long‑term goals.
Spatial + Limitation
Increase decision density with step, time, or area constraints.
Advanced Design & Algorithms (collapsed)Click to expand
Design Warnings
  • State‑space explosion can make solving or generation difficult; heuristics or constraint solving may be required.
  • Overly complex rules can strip players of intuition; keep them instantly understandable.
  • Dead‑lock detection and hint mechanisms are crucial for retention.
Algorithm Examples
  • 2D array / graph representation with BFS/DFS traversal.
  • Connected‑component detection and shape matching.
  • Backtracking / constraint‑satisfaction problem (CSP) solving.
Key Code(Solvability Search (DFS Pruning))
ts· 11 lines
function solvable(board, depth = 0): boolean {
  if (isGoal(board)) return true;
  if (depth > MAX_DEPTH) return false;
  for (const move of legalMoves(board)) {
    const next = apply(board, move);
    if (seen.has(hash(next))) continue;      // prune: skip already-visited states
    seen.add(hash(next));
    if (solvable(next, depth + 1)) return true;
  }
  return false;
}