Skip to content
Back to skills

Solve Grid Maze

ASecurity

For 2D grid problems: mazes, board games, tile maps, pixel grids, coordinate systems, cellular automata, flood fill. Uses dict-based Grid class pattern.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 7, 2026
ai-agentspythongo

Security analysis

A100/100

Scanned November 7, 2026

npx -y skills add jimmc414/claude-code-plugin-marketplace --skill solve-grid-maze --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Solve Grid Maze?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Solve Grid Maze
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jimmc414-solve-grid-maze/badge)](https://www.skillsdirectory.com/skills/jimmc414-solve-grid-maze)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: solve-grid-maze
description: "For 2D grid problems: mazes, board games, tile maps, pixel grids, coordinate systems, cellular automata, flood fill. Uses dict-based Grid class pattern."
---

# solve-grid-maze

## When to Use
- Working with 2D coordinates (x, y) or (row, col)
- Board games (chess, checkers, Go, tic-tac-toe)
- Tile-based maps or level editors
- Cellular automata (Game of Life)
- Maze generation or solving
- Flood fill algorithms
- Any spatial grid structure

## When NOT to Use
- Dense matrices where every cell is used (use numpy arrays instead)
- 3D or higher-dimensional grids (extend the pattern carefully)
- When you need matrix operations (multiplication, transposition)

## The Pattern

Represent grids as `dict[(x, y) -> contents]` instead of 2D arrays.

```python
Cell = Tuple[int, int]
Grid = Dict[Cell, Any]

# Sparse representation - only store what matters
world = {(3, 1): '#', (1, 2): '.', (1, 3): '#'}

# Neighbors via direction vectors
directions4 = [(1, 0), (0, 1), (-1, 0), (0, -1)]  # E, S, W, N
directions8 = directions4 + [(1, 1), (1, -1), (-1, 1), (-1, -1)]

def neighbors(point, directions=directions4):
    x, y = point
    return [(x + dx, y + dy) for dx, dy in directions]

def add(p, q):
    return (p[0] + q[0], p[1] + q[1])
```

## Example (from pytudes Life.ipynb)

```python
from collections import Counter

Cell = Tuple[int, int]
World = Set[Cell]  # Only store live cells (sparse!)

def neighbor_counts(world: World) -> Dict[Cell, int]:
    """Count live neighbors for each cell."""
    return Counter(n for cell in world for n in neighbors(cell))

def next_generation(world: World) -> World:
    """Apply Game of Life rules."""
    counts = neighbor_counts(world)
    return {cell for cell, count in counts.items()
            if count == 3 or (count == 2 and cell in world)}
```

## Key Principles
1. **Sparse is elegant**: Only store occupied/interesting cells
2. **Direction vectors**: Define movement as tuples to add
3. **Set operations**: Union, intersection work naturally on cell sets
4. **Counter for neighbors**: Count "backwards" from cells to neighbors
5. **Immutable cells**: Tuples are hashable, can be dict keys or set members

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.