diff --git a/config.c b/config.c index d418167..55371f2 100644 --- a/config.c +++ b/config.c @@ -118,6 +118,12 @@ action_t config_parse_action(const char *s) { if (strcmp(pat, "blinker") == 0) return ACTION_SELECT_BLINKER; if (strcmp(pat, "block") == 0) return ACTION_SELECT_BLOCK; if (strcmp(pat, "toad") == 0) return ACTION_SELECT_TOAD; + if (strcmp(pat, "beacon") == 0) return ACTION_SELECT_BEACON; + if (strcmp(pat, "boat") == 0) return ACTION_SELECT_BOAT; + if (strcmp(pat, "tub") == 0) return ACTION_SELECT_TUB; + if (strcmp(pat, "beehive") == 0) return ACTION_SELECT_BEEHIVE; + if (strcmp(pat, "rpentomino") == 0) return ACTION_SELECT_RPENTOMINO; + if (strcmp(pat, "acorn") == 0) return ACTION_SELECT_ACORN; } return ACTION_NONE; } @@ -129,6 +135,12 @@ config_t config_defaults(void) { {"2", ACTION_SELECT_BLINKER}, {"3", ACTION_SELECT_BLOCK}, {"4", ACTION_SELECT_TOAD}, + {"5", ACTION_SELECT_BEACON}, + {"6", ACTION_SELECT_BOAT}, + {"7", ACTION_SELECT_TUB}, + {"8", ACTION_SELECT_BEEHIVE}, + {"9", ACTION_SELECT_RPENTOMINO}, + {"0", ACTION_SELECT_ACORN}, {"space", ACTION_ROTATE}, {"escape", ACTION_CANCEL}, {"ctrl+q", ACTION_QUIT}, @@ -157,6 +169,12 @@ static const char *default_file_content = "\"2\" = \"select:blinker\"\n" "\"3\" = \"select:block\"\n" "\"4\" = \"select:toad\"\n" + "\"5\" = \"select:beacon\"\n" + "\"6\" = \"select:boat\"\n" + "\"7\" = \"select:tub\"\n" + "\"8\" = \"select:beehive\"\n" + "\"9\" = \"select:rpentomino\"\n" + "\"0\" = \"select:acorn\"\n" "\"space\" = \"rotate\"\n" "\"escape\" = \"cancel\"\n" "\"ctrl+q\" = \"quit\"\n" diff --git a/include/config.h b/include/config.h index 7181fa5..6dfc12a 100644 --- a/include/config.h +++ b/include/config.h @@ -18,6 +18,12 @@ typedef enum { ACTION_SELECT_BLINKER, ACTION_SELECT_BLOCK, ACTION_SELECT_TOAD, + ACTION_SELECT_BEACON, + ACTION_SELECT_BOAT, + ACTION_SELECT_TUB, + ACTION_SELECT_BEEHIVE, + ACTION_SELECT_RPENTOMINO, + ACTION_SELECT_ACORN, ACTION_CLEAR, ACTION_PAUSE, ACTION_STEP, diff --git a/openspec/changes/archive/2026-11-08-more-patterns/.openspec.yaml b/openspec/changes/archive/2026-11-08-more-patterns/.openspec.yaml new file mode 100644 index 0000000..c0ad5ed --- /dev/null +++ b/openspec/changes/archive/2026-11-08-more-patterns/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-11-08 diff --git a/openspec/changes/archive/2026-11-08-more-patterns/design.md b/openspec/changes/archive/2026-11-08-more-patterns/design.md new file mode 100644 index 0000000..524146b --- /dev/null +++ b/openspec/changes/archive/2026-11-08-more-patterns/design.md @@ -0,0 +1,30 @@ +# Design + +## Context + +Pattern module currently has 4 patterns with static offsets. Config maps digits 1-4. + +## Goals / Non-Goals + +**Goals:** +- Add 6 patterns with correct offsets. +- Extend default config digits 5-0. + +**Non-Goals:** +- Pattern editor. +- Loading from files. + +## Decisions + +### D1: Pattern storage +- Add static offset arrays and entries in `patterns[]`. + +### D2: Key mapping +- 5=Beacon, 6=Loaf, 7=Boat, 8=Tub, 9=R-pentomino, 0=Acorn. + +### D3: Config enum +- Add `ACTION_SELECT_BEACON` etc. or refactor? Use new enum values for minimal change. + +## Open Questions + +None. \ No newline at end of file diff --git a/openspec/changes/archive/2026-11-08-more-patterns/proposal.md b/openspec/changes/archive/2026-11-08-more-patterns/proposal.md new file mode 100644 index 0000000..f72dcbd --- /dev/null +++ b/openspec/changes/archive/2026-11-08-more-patterns/proposal.md @@ -0,0 +1,26 @@ +# Proposal + +## Why + +The tool currently offers only 4 patterns. Adding a broader set (Beacon, Loaf, Boat, Tub, R-pentomino, Acorn) makes it more useful for exploring Life dynamics. + +## What Changes + +- Add 6 new built-in patterns. +- Extend pattern module and count to 10. +- Add default key bindings 5–0 for the new patterns. + +## Capabilities + +### New Capabilities + +None. + +### Modified Capabilities + +- `pattern-placement`: additional built-in patterns and their key bindings. + +## Impact + +- Affected code: `pattern.c/h`, `config.c`, `wlgol.c` (enum/actions if needed). +- No new dependencies. \ No newline at end of file diff --git a/openspec/changes/archive/2026-11-08-more-patterns/specs/pattern-placement/spec.md b/openspec/changes/archive/2026-11-08-more-patterns/specs/pattern-placement/spec.md new file mode 100644 index 0000000..56ab2f5 --- /dev/null +++ b/openspec/changes/archive/2026-11-08-more-patterns/specs/pattern-placement/spec.md @@ -0,0 +1,17 @@ +# Spec Delta + +## ADDED Requirements + +### Requirement: Additional built-in patterns are available +The system SHALL provide additional built-in patterns (Beacon, Loaf, Boat, Tub, R-pentomino, Acorn) selectable via keys 5-0. + +#### Scenario: Select beacon +- **WHEN** the user triggers `select:beacon` +- **THEN** a beacon preview is shown + +### Requirement: New patterns support rotation +The system SHALL support 90-degree rotation for all new patterns. + +#### Scenario: Rotate new pattern +- **WHEN** the user rotates a new pattern preview +- **THEN** its cells rotate accordingly \ No newline at end of file diff --git a/openspec/changes/archive/2026-11-08-more-patterns/tasks.md b/openspec/changes/archive/2026-11-08-more-patterns/tasks.md new file mode 100644 index 0000000..467e465 --- /dev/null +++ b/openspec/changes/archive/2026-11-08-more-patterns/tasks.md @@ -0,0 +1,16 @@ +# Tasks + +## 1. Pattern module + +- [x] 1.1 Add offset arrays for Beacon, Loaf, Boat, Tub, R-pentomino, Acorn. +- [x] 1.2 Register new patterns in patterns[] and update pattern_count to 10. + +## 2. Config + +- [x] 2.1 Add select actions for new patterns and default bindings 5-0. +- [x] 2.2 Update config defaults and default file content. + +## 3. Verification + +- [x] 3.1 Build and run ctest. +- [x] 3.2 Manual test selecting/rotating new patterns. \ No newline at end of file diff --git a/openspec/specs/pattern-placement/spec.md b/openspec/specs/pattern-placement/spec.md index 9bfa11f..5fb10ad 100644 --- a/openspec/specs/pattern-placement/spec.md +++ b/openspec/specs/pattern-placement/spec.md @@ -58,3 +58,17 @@ The system SHALL ignore left clicks when no placement tool is active. #### Scenario: No tool - **WHEN** the user left-clicks while no tool is active - **THEN** the grid is unchanged + +### Requirement: Additional built-in patterns are available +The system SHALL provide additional built-in patterns (Beacon, Loaf, Boat, Tub, R-pentomino, Acorn) selectable via keys 5-0. + +#### Scenario: Select beacon +- **WHEN** the user triggers `select:beacon` +- **THEN** a beacon preview is shown + +### Requirement: New patterns support rotation +The system SHALL support 90-degree rotation for all new patterns. + +#### Scenario: Rotate new pattern +- **WHEN** the user rotates a new pattern preview +- **THEN** its cells rotate accordingly diff --git a/pattern.c b/pattern.c index 8809ae6..6c66aed 100644 --- a/pattern.c +++ b/pattern.c @@ -16,14 +16,44 @@ static const cell_offset_t toad_cells[] = { {1,0},{2,0},{3,0},{0,1},{1,1},{2,1} }; +static const cell_offset_t beacon_cells[] = { + {0,0},{1,0},{0,1},{1,1},{2,2},{3,2},{2,3},{3,3} +}; + +static const cell_offset_t boat_cells[] = { + {0,0},{1,0},{0,1},{2,1},{1,2} +}; + +static const cell_offset_t tub_cells[] = { + {1,0},{0,1},{2,1},{1,2} +}; + +static const cell_offset_t beehive_cells[] = { + {1,0},{2,0},{0,1},{3,1},{1,2},{2,2} +}; + +static const cell_offset_t rpent_cells[] = { + {1,0},{2,0},{0,1},{1,1},{1,2} +}; + +static const cell_offset_t acorn_cells[] = { + {1,0},{3,1},{0,2},{1,2},{2,2},{3,2},{4,2} +}; + static const pattern_t patterns[] = { {"glider", 5, glider_cells}, {"blinker", 3, blinker_cells}, {"block", 4, block_cells}, {"toad", 6, toad_cells}, + {"beacon", 8, beacon_cells}, + {"boat", 5, boat_cells}, + {"tub", 4, tub_cells}, + {"beehive", 6, beehive_cells}, + {"rpentomino", 5, rpent_cells}, + {"acorn", 7, acorn_cells}, }; -int pattern_count(void) { return 4; } +int pattern_count(void) { return 10; } const pattern_t *pattern_get(int index) { if (index < 0 || index >= pattern_count()) return NULL; diff --git a/tests/test_pattern.c b/tests/test_pattern.c index 2dd945d..d129204 100644 --- a/tests/test_pattern.c +++ b/tests/test_pattern.c @@ -4,7 +4,7 @@ #include "pattern.h" int main(void) { - assert(pattern_count() == 4); + assert(pattern_count() == 10); const void *p = pattern_get(0); (void)p; int dx[16], dy[16]; diff --git a/wlgol.c b/wlgol.c index 5707175..ad8fa85 100644 --- a/wlgol.c +++ b/wlgol.c @@ -278,6 +278,18 @@ static void handle_key(uint32_t key, uint32_t state, xkb_keysym_t sym, uint32_t active_tool = 2; active_rotation = 0; printf("selected block\n"); break; case ACTION_SELECT_TOAD: active_tool = 3; active_rotation = 0; printf("selected toad\n"); break; + case ACTION_SELECT_BEACON: + active_tool = 4; active_rotation = 0; printf("selected beacon\n"); break; + case ACTION_SELECT_BOAT: + active_tool = 5; active_rotation = 0; printf("selected boat\n"); break; + case ACTION_SELECT_TUB: + active_tool = 6; active_rotation = 0; printf("selected tub\n"); break; + case ACTION_SELECT_BEEHIVE: + active_tool = 7; active_rotation = 0; printf("selected beehive\n"); break; + case ACTION_SELECT_RPENTOMINO: + active_tool = 8; active_rotation = 0; printf("selected rpentomino\n"); break; + case ACTION_SELECT_ACORN: + active_tool = 9; active_rotation = 0; printf("selected acorn\n"); break; case ACTION_CLEAR: printf("clear requested\n"); break;