一键导入
find-shortest-path
For pathfinding and search: shortest path, maze solving, game AI, route planning, graph traversal, BFS/DFS, Dijkstra, A* problems.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
For pathfinding and search: shortest path, maze solving, game AI, route planning, graph traversal, BFS/DFS, Dijkstra, A* problems.
用 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 | find-shortest-path |
| description | For pathfinding and search: shortest path, maze solving, game AI, route planning, graph traversal, BFS/DFS, Dijkstra, A* problems. |
Use A* search with a problem abstraction that separates:
from heapq import heappush, heappop
def astar_search(problem, h=lambda n: 0):
"""A* search: expand nodes with minimum f(n) = g(n) + h(n)."""
start = problem.initial
frontier = [(h(start), 0, start, [])] # (f, g, state, path)
reached = {start: 0}
while frontier:
f, g, state, path = heappop(frontier)
if problem.is_goal(state):
return path + [state]
for action, next_state, cost in problem.actions(state):
new_g = g + cost
if next_state not in reached or new_g < reached[next_state]:
reached[next_state] = new_g
new_f = new_g + h(next_state)
heappush(frontier, (new_f, new_g, next_state, path + [state]))
return None # No path found
class GridProblem:
"""Find shortest path on a grid."""
def __init__(self, grid, start, goal):
self.grid, self.initial, self.goal = grid, start, goal
def is_goal(self, state):
return state == self.goal
def actions(self, state):
"""Yield (action, next_state, cost) tuples."""
for neighbor in self.grid.neighbors(state):
yield (neighbor, neighbor, 1)
def h(self, state):
"""Manhattan distance heuristic."""
return abs(state[0] - self.goal[0]) + abs(state[1] - self.goal[1])
# Usage
problem = GridProblem(grid, start=(0, 0), goal=(10, 10))
path = astar_search(problem, h=problem.h)