generate-puzzle
关于
This skill generates jigsaw puzzle SVGs in R via `generate_puzzle()` or `geom_puzzle_*()` functions, supporting multiple puzzle types like rectangular, hexagonal, and voronoi. It validates parameters against a config file and is useful for creating SVG files, testing configurations, or building ggplot2 visualizations. Developers can use it to programmatically produce puzzles with controlled grid, size, seed, and layout settings.
快速安装
Claude Code
推荐npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/generate-puzzle在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Generate Puzzle
jigsawR unified API → generate puzzle.
Use When
- Create puzzle SVG w/ type + config
- Test generation w/ diff params
- Sample out for docs/demos
- ggplot2 puzzle viz w/ geom_puzzle_*()
In
- Required: type (
"rectangular","hexagonal","concentric","voronoi","random","snic") - Required: grid (type-dep:
c(cols, rows)orc(rings)) - Optional: size mm (default varies)
- Optional: seed (default 42)
- Optional: offset (0=interlocked, >0=separated)
- Optional: layout (
"grid"or"repel"rect) - Optional: fusion groups (PILES string)
Do
Step 1: Read config constraints
R_EXE="/mnt/c/Program Files/R/R-4.5.0/bin/Rscript.exe"
"$R_EXE" -e "cat(yaml::yaml.load_file('inst/config.yml')[['{TYPE}']]$grid$max)"
Or read inst/config.yml direct → valid ranges for type.
→ min/max for grid, size, tabsize known for type.
If err: config.yml missing or type key missing → in jigsawR root? pkg built once?
Step 2: Determine type + params
| Type | grid | size | Extra params |
|---|---|---|---|
| rectangular | c(cols, rows) | c(width, height) mm | offset, layout, tabsize |
| hexagonal | c(rings) | c(diameter) mm | do_warp, do_trunc, tabsize |
| concentric | c(rings) | c(diameter) mm | center_shape, tabsize |
| voronoi | c(cols, rows) | c(width, height) mm | n_interior, tabsize |
| random | c(cols, rows) | c(width, height) mm | n_interior, tabsize |
| snic | c(cols, rows) | c(width, height) mm | n_interior, compactness, tabsize |
→ Req mapped to generate_puzzle() args, values in config.yml range.
If err: unsure format → see table. Rect + voronoi → c(cols, rows); hex + concentric → c(rings).
Step 3: Create R script
Script file preferred over -e for complex cmds.
library(jigsawR)
result <- generate_puzzle(
type = "rectangular",
seed = 42,
grid = c(3, 4),
size = c(400, 300),
offset = 0,
layout = "grid"
)
cat("Pieces:", length(result$pieces), "\n")
cat("SVG length:", nchar(result$svg_content), "\n")
cat("Files:", paste(result$files, collapse = ", "), "\n")
Save to tmp script file.
→ R script saved w/ library(jigsawR) + call + diag output.
If err: syntax → verify string quoting + c() for num vectors. Use script files, avoid shell escape.
Step 4: Execute via WSL R
R_EXE="/mnt/c/Program Files/R/R-4.5.0/bin/Rscript.exe"
"$R_EXE" /path/to/script.R
→ Completes no errors. SVG → output/.
If err: check renv restored (renv::restore()). Pkg loaded (devtools::load_all()). NO --vanilla (renv needs .Rprofile).
Step 5: Verify out
- SVG in
output/ - Starts
<?xmlor<svg - Piece count matches: cols × rows (rect), ring formula (hex/concentric)
- ggplot2 → plot renders no err
→ SVG exists, content valid, piece count matches.
If err: SVG missing → check output/ exists. Count wrong → verify grid for type. ggplot2 → wrap tryCatch().
Step 6: Save out
Default → output/. result contains:
$svg_content— raw SVG string$pieces— piece data list$canvas_size— dims$files— paths
→ result has $svg_content, $pieces, $canvas_size, $files. Files on disk.
If err: $files empty → in-memory only. Explicitly: writeLines(result$svg_content, "output/puzzle.svg").
Check
- Script no err
- SVG well-formed XML
- Piece count matches grid
- Same seed → identical out
- Params in config.yml range
Traps
--vanilla: breaks renv. Never.- Complex
-e: script files → shell escape → Exit 5. - Grid vs size: grid=piece count, size=physical mm.
- Offset: 0=assembled, >0=exploded.
- SNIC: needs
snicpkg installed.
→
add-puzzle-type— scaffold new type E2Evalidate-piles-notation— validate fusion strings pre-callrun-puzzle-tests— test suite after gen changeswrite-testthat-tests— tests for new scenarios
GitHub 仓库
相关推荐技能
content-collections
元Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。
polymarket
元这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。
creating-opencode-plugins
元该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。
sglang
元SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。
