# Frontier Based Explore

> For graph exploration: frontier collection with configurable pop order, BFS/DFS/random via strategy change.

- **Type:** Skill
- **Install:** `agentstack add skill-jimmc414-claude-code-plugin-marketplace-frontier-based-explore`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [jimmc414](https://agentstack.voostack.com/s/jimmc414)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [jimmc414](https://github.com/jimmc414)
- **Source:** https://github.com/jimmc414/claude-code-plugin-marketplace/tree/master/plugins/norvig-patterns/skills/frontier-based-explore

## Install

```sh
agentstack add skill-jimmc414-claude-code-plugin-marketplace-frontier-based-explore
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# frontier-based-explore

## When to Use
- Graph/tree traversal
- When traversal order matters
- Want to switch between DFS/BFS easily
- Maze generation
- Coverage algorithms

## When NOT to Use
- Simple recursion suffices
- Fixed traversal order
- No exploration needed

## The Pattern

Maintain a frontier collection; how you pop determines traversal order.

```python
from collections import deque

def explore(start, neighbors, pop_strategy=deque.pop):
    """Explore graph with configurable traversal order.

    pop_strategy:
      deque.pop     -> DFS (depth-first, LIFO)
      deque.popleft -> BFS (breadth-first, FIFO)
      lambda d: d.pop(random.randrange(len(d))) -> Random
    """
    visited = set()
    frontier = deque([start])

    while frontier:
        current = pop_strategy(frontier)

        if current in visited:
            continue
        visited.add(current)

        yield current  # Process node

        for neighbor in neighbors(current):
            if neighbor not in visited:
                frontier.append(neighbor)
```

## Example (from pytudes Maze.ipynb)

```python
from collections import deque
import random

def random_tree(nodes, neighbors, pop=deque.pop):
    """Build spanning tree with configurable exploration.

    Different pop strategies create different tree shapes:
    - deque.pop (DFS): long winding paths
    - deque.popleft (BFS): short bushy branches
    - random pop: mixed/natural looking
    """
    tree = set()
    nodes = set(nodes)
    root = nodes.pop()
    frontier = deque([root])

    while nodes:
        current = pop(frontier)
        unvisited = [n for n in neighbors(current) if n in nodes]

        if unvisited:
            chosen = random.choice(unvisited)
            tree.add((current, chosen))
            nodes.remove(chosen)
            frontier.append(current)
            frontier.append(chosen)

    return tree

# Generate different maze styles
def dfs_maze(width, height):
    """Long, winding corridors."""
    return random_tree(all_cells(width, height), grid_neighbors, deque.pop)

def bfs_maze(width, height):
    """Short, branching paths."""
    return random_tree(all_cells(width, height), grid_neighbors, deque.popleft)

def random_maze(width, height):
    """Natural-looking structure."""
    def random_pop(d):
        i = random.randrange(len(d))
        d[i], d[-1] = d[-1], d[i]
        return d.pop()
    return random_tree(all_cells(width, height), grid_neighbors, random_pop)
```

## Key Principles
1. **Frontier abstraction**: deque supports both ends
2. **Pop strategy = behavior**: Same code, different traversals
3. **Yield for processing**: Generate results lazily
4. **Visited set**: Prevent cycles
5. **Strategy as parameter**: Inject behavior, don't hardcode

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [jimmc414](https://github.com/jimmc414)
- **Source:** [jimmc414/claude-code-plugin-marketplace](https://github.com/jimmc414/claude-code-plugin-marketplace)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-jimmc414-claude-code-plugin-marketplace-frontier-based-explore
- Seller: https://agentstack.voostack.com/s/jimmc414
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
