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>") 受而無「未知類」之訛。
敗則: 驗類名入 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 函經 @export 於 NAMESPACE 導出。
編 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。默生可行之謎。
敗則: 以 yaml::yaml.load_file("inst/config.yml") 驗 YAML。確默格與默徑生合宜之謎。
編 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() 返 0 訛、0 警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 函之文