一键导入
generate-tree-structure
For tree/maze generation: spanning trees, random mazes, graph coverage. Uses frontier-based exploration with configurable traversal order.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
For tree/maze generation: spanning trees, random mazes, graph coverage. Uses frontier-based exploration with configurable traversal order.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Conducts iterative deep research on any topic using web search, progressive exploration, and structured synthesis. Use when asked for comprehensive research, deep investigation, thorough analysis, or multi-source exploration of any topic. Triggers: research, investigate, deep dive, comprehensive analysis, explore thoroughly, find everything about.
For cross-cutting concerns: add behavior without modifying functions, caching, timing, logging, validation wrappers.
For performance work: measure before changing, profile to find bottlenecks, compare before and after.
For symbolic computation: ASTs, mathematical expressions, code that manipulates code structure, expression transformations.
For ordered processing: A* search, Dijkstra, event simulation, task scheduling. Efficient min/max extraction with heap-based queue.
For dynamic programming: overlapping subproblems, recursive solutions with repeated computations, memoization to avoid redundant work.
| name | generate-tree-structure |
| description | For tree/maze generation: spanning trees, random mazes, graph coverage. Uses frontier-based exploration with configurable traversal order. |
Use frontier-based exploration where the pop strategy determines tree shape.
from collections import deque
import random
def random_tree(nodes, neighbors, pop=deque.pop):
"""Build spanning tree by frontier exploration.
pop strategy determines tree shape:
- deque.pop (DFS): long winding paths
- deque.popleft (BFS): short bushy branches
- random.choice: random structure
"""
tree = set()
nodes = set(nodes)
root = nodes.pop()
frontier = deque([root])
while nodes:
# Pop from frontier according to strategy
current = pop(frontier)
# Find unvisited neighbors
unvisited = [n for n in neighbors(current) if n in nodes]
if unvisited:
# Pick random neighbor, add edge
chosen = random.choice(unvisited)
tree.add((current, chosen))
nodes.remove(chosen)
# Add both back to frontier
frontier.append(current)
frontier.append(chosen)
return tree
from collections import deque
import random
def make_maze(width, height):
"""Generate a random maze using DFS-based tree generation."""
def neighbors(cell):
x, y = cell
candidates = [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]
return [(nx, ny) for nx, ny in candidates
if 0 <= nx < width and 0 <= ny < height]
all_cells = {(x, y) for x in range(width) for y in range(height)}
# DFS creates long winding passages
edges = random_tree(all_cells, neighbors, pop=deque.pop)
return Maze(width, height, edges)
def solve_maze(maze, start, goal):
"""BFS to find shortest path through maze."""
frontier = deque([(start, [start])])
visited = {start}
while frontier:
current, path = frontier.popleft()
if current == goal:
return path
for neighbor in maze.neighbors(current):
if neighbor not in visited:
visited.add(neighbor)
frontier.append((neighbor, path + [neighbor]))
return None