🧩

Grid Stealth

gameType: "grid-stealth"

Grid-based stealth puzzles where the player must navigate from a start position to a goal while avoiding patrol entities. Patrols follow defined paths in loop or ping-pong patterns. This is the generator that powers Spinnerzeit's Nightly Feed game — the first "proven" GameplayGen generator. Difficulty scales via patrol count, path length, wall density, and patrol coverage.

Interactive Example

🧩 Grid Stealth Puzzle

Navigate from start to goal while avoiding patrol routes & vision cones

difficulty: 0.52verified ✓
S
G
Start Goal WallGuard AGuard BGoal GuardVision

Grid Size

8×8

Patrols

3

Solution Steps

0

Difficulty

0.52

Try it

await pf.generate({
  gameType: "grid-stealth",
  params: {
    width: 8, height: 8,
    patrolCount: { min: 1, max: 4 },
    patrolLength: { min: 3, max: 8 },
    guardVisionRange: 2,
    guardSpeed: 1
  },
  count: 1,
  difficulty: { target: 0.60 }
})

API Parameters

ParamTypeRequiredDefaultDescription
widthnumberYesGrid width. Range 4–64.
heightnumberYesGrid height. Range 4–64.
patrolCount{ min: number; max: number }YesRange for number of patrol entities. Actual count scaled by difficulty within this range.
patrolLength{ min: number; max: number }YesRange for patrol path lengths (number of waypoints). Scaled by difficulty.
entityTypesstring[]No["guard"]Types of patrol entities to use. E.g. ["guard", "camera", "drone"]. Entities are randomly assigned from this list.
hasDetectionbooleanNofalseWhether entities have detection zones (vision cones).
detectionRadiusnumberNoDetection radius for entities (if hasDetection is true).
allowObservationbooleanNofalseAllow the player a waiting/observation phase before the first move.

Common Request Options

ParamTypeRequiredDefaultDescription
countnumberYesHow many puzzles to generate.
difficulty.targetnumberNo0.5Numeric difficulty (0.0–1.0). Controls patrol count, path length, and wall density. Higher = more guards, longer paths, denser walls.
seednumberNoSeed for reproducible generation.

Generation Details

The grid stealth generator:

  1. Places start position at the left center and goal at the right center
  2. Creates a 2-cell exclusion zone around start and goal (no walls or patrol starts here)
  3. Generates walls with density scaling from 10–25% based on difficulty, reduced near start/goal
  4. Creates patrol paths via random walks, avoiding the exclusion zone
  5. Each patrol gets a random type from entityTypes and mode (bounce by default; loop at higher difficulties if path forms a closed circuit)
  6. Validates that at least one viable path exists from start to goal avoiding all patrols

Content Output

ParamTypeRequiredDefaultDescription
widthnumberGrid width.
heightnumberGrid height.
start[number, number]Player start position [x, y].
goal[number, number]Goal position [x, y].
walls[number, number][]Wall/obstacle positions.
patrolsPatrol[]Array of patrol objects: { type: string, path: [number, number][], mode: "bounce" | "loop", patrolMode: "bounce" | "loop" }. Bounce = ping-pong (default), Loop = closed circuit (requires last waypoint adjacent to first).
collectibles[number, number][]Optional collectible positions.

Example Request

bash
curl -X POST https://api.gameplaygen.com/generate \
  -H "Authorization: Bearer gg_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "gameType": "grid-stealth",
    "params": {
      "width": 12,
      "height": 10,
      "patrolCount": { "min": 2, "max": 6 },
      "patrolLength": { "min": 3, "max": 8 },
      "entityTypes": ["guard", "camera"]
    },
    "count": 3,
    "difficulty": { "target": 0.5 }
  }'

Example Response

json
{
  "content": [
    {
      "id": "gg_gs4k2m1",
      "gameType": "grid-stealth",
      "content": {
        "width": 12,
        "height": 10,
        "start": [0, 5],
        "goal": [11, 5],
        "walls": [[3, 2], [3, 3], [5, 7], [7, 4], [8, 4]],
        "patrols": [
          {
            "type": "guard",
            "path": [[4, 1], [4, 2], [4, 3], [5, 3], [6, 3]],
            "mode": "bounce",
            "patrolMode": "bounce"
          },
          {
            "type": "camera",
            "path": [[7, 6], [7, 7], [7, 8], [8, 8]],
            "mode": "loop",
            "patrolMode": "loop"
          },
          {
            "type": "guard",
            "path": [[9, 2], [9, 3], [9, 4]],
            "mode": "bounce",
            "patrolMode": "bounce"
          }
        ]
      },
      "metrics": {
        "verified": true,
        "difficulty": 0.52,
        "balance": 0.88,
        "novelty": 1.0,
        "quality": 0.80,
        "solution": ["R","R","D","R","R","R","U","R","R","R","R","R"],
        "notes": ["3 patrols, viable path length 12, 2 guard types"]
      }
    }
  ],
  "requested": 3,
  "delivered": 3,
  "stats": {
    "totalCandidates": 5,
    "totalValidated": 3,
    "totalRejected": 2,
    "totalTime": 890,
    "avgDifficulty": 0.51,
    "difficultyRange": [0.42, 0.61]
  }
}

Tips for Game Integration

  • Patrol animation: Use the patrolMode field to animate patrols. "bounce" (default) means the guard ping-pongs back and forth (A→B→C→B→A). "loop" means the patrol wraps from the last waypoint back to the first (only when they are adjacent).
  • Turn-based or real-time: The grid works for both. In turn-based mode, advance patrols one step per player move. In real-time, animate them at a fixed interval.
  • Multiple entity types: Use different entity types for different behaviors. E.g., guards move, cameras rotate, drones have wider detection.
  • Proven in production: This generator powers Spinnerzeit's Nightly Feed game. The exclusion zone around start/goal ensures the player always has a safe opening and clear ending.