brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
add-puzzle-typeScaffold a new puzzle type across all 10+ pipeline integration points in jigsawR. Creates the core puzzle module, wires it into the unified pipeline (generation, positioning, rendering, adjacency), adds ggpuzzle geom/stat layers, updates DESCRIPTION and config.yml, extends the Shiny app, and creates a comprehensive test suite. Use when adding a completely n…
Independent GitHub snapshot · Automated classification · Original documentation governs
於 jigsawR 諸接點建新拼類。
"triangular")建 R/<type>_puzzle.R 內生函:
#' Generate <type> puzzle pieces (internal)
#' @noRd
generate_<type>_pieces_internal <- function(params, seed) {
# 1. Initialize RNG state
# 2. Generate piece geometries
# 3. Build edge paths (SVG path data)
# 4. Compute adjacency
# 5. Return list: pieces, edges, adjacency, metadata
}
循 R/voronoi_puzzle.R 或 R/snic_puzzle.R 之構。
得:函返列含 $pieces、$edges、$adjacency、$metadata。
敗:比 generate_voronoi_pieces_internal() 之返構以識缺元或型誤。
改 R/jigsawR_clean.R:
"<type>" 於 valid_types"<type>" → "<type>_")# In valid_types
valid_types <- c("rectangular", "hexagonal", "concentric", "voronoi", "snic", "<type>")
得:generate_puzzle(type = "<type>") 受而無「unknown type」誤。
敗:驗類串入 valid_types 字字相符,且參析涵諸類專參。
改 R/unified_piece_generation.R:
generate_pieces_internal()# In the switch/dispatch
"<type>" = generate_<type>_pieces_internal(params, seed)
得:類分派時片得生。
敗:驗分派串字字相符且 generate_<type>_pieces_internal 已定且自拼模出。
改 R/piece_positioning.R:
增類定位分派。多類用共定位邏輯,少數需專處。
得:apply_piece_positioning() 處新類無誤、片置正座。
敗:察新類需專定位邏輯否或可重用共路。如默路不適則增分派。
改 R/unified_renderer.R:
render_puzzle_svg()get_<type>_edge_paths()get_<type>_piece_name()得:新類 SVG 出,片廓、邊路皆正。
敗:驗 get_<type>_edge_paths() 返有效 SVG 路且 get_<type>_piece_name() 出各片獨識。
改 R/adjacency_api.R:
增鄰分派使 get_neighbors()、get_adjacency() 用於新類。
得:get_neighbors(result, piece_id) 返任片之正鄰。
敗:察鄰分派返正構。以小格驗、手核鄰係對幾何。
改 R/geom_puzzle.R:
以 make_puzzle_layer() 廠建 geom_puzzle_<type>():
#' @export
geom_puzzle_<type> <- function(mapping = NULL, data = NULL, ...) {
make_puzzle_layer(type = "<type>", mapping = mapping, data = data, ...)
}
得:ggplot() + geom_puzzle_<type>(aes(...)) 繪而無誤。
敗:驗 make_puzzle_layer() 受正類串且 geom 函於 NAMESPACE 經 @export 出。
改 R/stat_puzzle.R:
compute_panel()得:stat 層算幾正、出預期多角。
敗:察 compute_panel() 分派返必欄之數框(x、y、group、piece_id)且默參合新類。
改 DESCRIPTION:
Suggests:(若外依)Collate: 含新 R 檔(字序)得:devtools::document() 成。無未列檔之 NOTE。
敗:察新 R 檔列於 Collate: 字序且新 Suggests 包字字相符附版限。
改 inst/config.yml:
增新類默與限:
<type>:
grid:
default: [3, 3]
min: [2, 2]
max: [20, 20]
size:
default: [300, 300]
min: [100, 100]
max: [2000, 2000]
tabsize:
default: 20
min: 5
max: 50
# Add type-specific params here
得:配為有效 YAML。默生可用拼於 generate_puzzle()。
敗:以 yaml::yaml.load_file("inst/config.yml") 驗 YAML。確默 grid 與 size 出合理拼。
改 inst/shiny-app/app.R:
得:Shiny 應於下拉示新類、選則生拼。
敗:察類入 UI 選之 choices,類專條件板用 conditionalPanel(condition = "input.type == '<type>'"),伺端傳正參。
建 tests/testthat/test-<type>-puzzles.R:
test_that("<type> puzzle generates correct piece count", { ... })
test_that("<type> puzzle respects seed reproducibility", { ... })
test_that("<type> adjacency returns valid neighbors", { ... })
test_that("<type> fusion merges pieces correctly", { ... })
test_that("<type> geom layer renders without error", { ... })
test_that("<type> SVG output is well-formed", { ... })
test_that("<type> config constraints are enforced", { ... })
若類需外包則以 skip_if_not_installed() 包之。
得:諸測皆過。除外依缺則無跳。
敗:分察各接。常缺分派——行 grep -rn "switch\|valid_types" R/ 尋諸分派處。
generate_puzzle(type = "<type>") 出有效devtools::test() 含新測過devtools::check() 零誤零警devtools::document() 成(NAMESPACE 更)paste(a, b, sep = "-") 建鄰鍵時負片標出 "1--1"。用 "|" 分、以 "\\|" 析cat() 出:恆用 cli 包記裝(log_info、log_warn 等)yaml::yaml.load_file("inst/config.yml") 驗generate-puzzle — 建後測新類run-puzzle-tests — 行全測套驗接validate-piles-notation — 以新類測融write-testthat-tests — 通測寫紋write-roxygen-docs — 文新 geom 函