Back to Skills

generate-puzzle

pjt222
Updated 6 days ago
20 views
17
2
17
View on GitHub
Metawordaitestingdesign

About

This skill generates jigsaw puzzle SVGs and ggplot2 visualizations using the jigsawR package. It supports multiple puzzle types (rectangular, hexagonal, voronoi, etc.) with configurable parameters like grid, size, and seed. Use it for creating puzzle files, testing configurations, or producing sample outputs for documentation.

Quick Install

Claude Code

Recommended
Primary
npx skills add pjt222/agent-almanac -a claude-code
Plugin CommandAlternative
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternative
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/generate-puzzle

Copy and paste this command in Claude Code to install this skill

Documentation

生拼圖

用 jigsawR 包之統一 API 生拼圖。

  • 某型與配置造拼圖 SVG
  • 不同參數試生
  • 生樣品供文檔或示
  • 用 geom_puzzle_*() 造 ggplot2 拼圖視覺

  • :拼圖型("rectangular""hexagonal""concentric""voronoi""random""snic"
  • :格維(依型:c(cols, rows)c(rings)
  • :尺寸 mm(默依型異)
  • :種(可復性,默 42)
  • :偏移(0=互扣,>0=分離)
  • :布局("grid""repel",rect)
  • :融組(PILES 符號串)

一:讀配約束

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)"

或直讀 inst/config.yml 察所擇型之有效範圍。

得:所擇型之 grid、size、tabsize 諸參之最小最大已知。

敗:config.yml 缺或型鍵不存→查於 jigsawR 根且包至少建過一次。

二:定型與參

用戶請求映為有效 generate_puzzle() 引數:

TypegridsizeExtra params
rectangularc(cols, rows)c(width, height) mmoffset, layout, tabsize
hexagonalc(rings)c(diameter) mmdo_warp, do_trunc, tabsize
concentricc(rings)c(diameter) mmcenter_shape, tabsize
voronoic(cols, rows)c(width, height) mmn_interior, tabsize
randomc(cols, rows)c(width, height) mmn_interior, tabsize
snicc(cols, rows)c(width, height) mmn_interior, compactness, tabsize

得:請求映為 generate_puzzle() 有效引數,型、grid、size 皆於 config.yml 範圍內。

敗:參形式不明→參表。矩形與 voronoi 用 c(cols, rows);六與同心用 c(rings)

三:造 R 腳本

書腳本檔(複雜命令勝於 -e):

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")

存於臨時腳本。

得:R 腳本檔存於臨時位,含 library(jigsawR)generate_puzzle() 全參調用、診斷輸出。

敗:語法誤→查字串皆引、數值向量用 c()。複雜殼轉義→必用腳本檔。

四:經 WSL R 行

R_EXE="/mnt/c/Program Files/R/R-4.5.0/bin/Rscript.exe"
"$R_EXE" /path/to/script.R

得:腳本無誤完成。SVG 寫於 output/

敗:察 renv 已復(renv::restore())。驗包已載(devtools::load_all())。勿用 --vanilla 旗(renv 需 .Rprofile)。

五:驗出

  • SVG 檔存於 output/
  • SVG 內容以 <?xml<svg
  • 片數符:cols * rows(矩)、環式(六/同心)
  • ggplot2 法→驗圖對象無誤繪

得:SVG 檔存於 output/,內容以 <?xml<svg 開,片數符格規格(矩用 cols*rows,六/同心用環式)。

敗:SVG 檔缺→察 output/ 存。片數誤→驗格維合型式。ggplot2 出→以 tryCatch() 包察繪無誤。

六:存出

生成檔默存 output/result 對象含:

  • $svg_content:生 SVG 串
  • $pieces:片數據列
  • $canvas_size:維
  • $files:寫檔之徑

得:result 對象含 $svg_content$pieces$canvas_size$files$files 列之檔存於磁。

敗:$files 空→拼圖或僅生於內存。顯存以 writeLines(result$svg_content, "output/puzzle.svg")

  • 腳本無誤行
  • SVG 檔乃良構 XML
  • 片數符格規格
  • 同種生同出(可復)
  • 參於 config.yml 約束內

  • --vanilla:破 renv 啟動。絕勿用
  • 複雜 -e 命令:用腳本檔;殼轉義致 Exit 5
  • Grid 與 size 混:格乃片數,size 乃物理 mm 維
  • 偏移語義:0=組裝,正=散裂片
  • SNIC 無包:snic 型需 snic 包已裝

  • add-puzzle-type
  • validate-piles-notation
  • run-puzzle-tests
  • write-testthat-tests

GitHub Repository

pjt222/agent-almanac
Path: i18n/wenyan-ultra/skills/generate-puzzle
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

polymarket

Meta

This skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.

View skill

creating-opencode-plugins

Meta

This skill helps developers create OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It provides the plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript modules. Use it when you need to intercept, monitor, or extend the OpenCode AI assistant's lifecycle with custom event-driven logic.

View skill

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill