用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill search-algorithms命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | search-algorithms |
| description | Search algorithms in AI |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"machine-learning-engineers","category":"artificial-intelligence"} |
Use me when:
import heapq
def astar(start, goal, neighbors, heuristic):
frontier = [(0, start)]
came_from = {start: None}
cost_so_far = {start: 0}
while frontier:
_, current = heapq.heappop(frontier)
if current == goal:
return reconstruct_path(came_from, current)
for next_node in neighbors(current):
new_cost = cost_so_far[current] + cost(current, next_node)
if next_node not in cost_so_far or new_cost < cost_so_far[next_node]:
cost_so_far[next_node] = new_cost
priority = new_cost + heuristic(next_node, goal)
heapq.heappush(frontier, (priority, next_node))
came_from[next_node] = current
return None
def minimax(board, depth, is_maximizing):
if is_terminal(board) or depth == 0:
return evaluate(board)
if is_maximizing:
max_eval = -inf
for move in get_moves(board):
eval = minimax(make_move(board, move), depth - 1, False)
max_eval = max(max_eval, eval)
return max_eval
else:
min_eval = inf
for move in get_moves(board):
eval = minimax(make_move(board, move), depth - 1, True)
min_eval = min(min_eval, eval)
return min_eval
# Alpha-beta pruning
def alphabeta(board, depth, alpha, beta, is_maximizing):
if is_terminal(board) or depth == 0:
return evaluate(board)
if is_maximizing:
max_eval = -inf
for move in get_moves(board):
eval = alphabeta(make_move(board, move), depth - 1,
alpha, beta, False)
max_eval = max(max_eval, eval)
alpha = max(alpha, eval)
if beta <= alpha:
max_eval
:
min_eval = inf
move get_moves(board):
= alphabeta(make_move(board, move), depth - ,
alpha, beta, )
min_eval = (min_eval, )
beta = (beta, )
beta <= alpha:
min_eval