Files
wlgol/openspec/changes/input-and-placement/specs/cell-grid/spec.md
T
arek 5e7abfb56b docs: add input-and-placement OpenSpec change and update AGENTS.md
Plan input handling and pattern placement before Game of Life mechanics:
keyboard bindings config, mouse placement with preview/rotation,
HiDPI scaling, and cell grid. Update AGENTS.md project notes.
2026-11-08 14:30:09 +01:00

2.2 KiB

Spec Delta

Purpose

Stores and renders the Game of Life cell grid with a fixed cell size and wall boundaries, independent of future simulation rules.

ADDED Requirements

Requirement: Grid stores alive and dead cells

The system SHALL maintain a grid of cells, each either alive or dead, addressable by column and row.

Scenario: Cell access

  • WHEN a cell is set to alive
  • THEN reading that cell returns alive
  • AND cells never set remain dead

Requirement: Boundary cells are treated as dead

The system SHALL treat any cell outside the grid bounds as dead and shall not store state outside the grid.

Scenario: Out of bounds read

  • WHEN a cell position outside the grid is queried
  • THEN the result is dead

Requirement: Grid resizes while preserving overlapping cells

The system SHALL preserve cells that remain within bounds when the grid dimensions change, clearing only cells that fall outside the new bounds.

Scenario: Enlarge grid

  • WHEN the grid grows in either dimension
  • THEN previously alive cells within the old bounds remain alive

Scenario: Shrink grid

  • WHEN the grid shrinks in either dimension
  • THEN cells outside the new bounds are discarded
  • AND remaining cells keep their state

Requirement: Cell size is fixed in logical pixels

The system SHALL use a cell size of 8 logical pixels, so grid dimensions derive from the logical surface size.

Scenario: Dimension calculation

  • WHEN the logical surface is 400 pixels wide
  • THEN the grid has 50 columns

Requirement: Alive cells are rendered

The system SHALL render alive cells distinctly from dead cells.

Scenario: Render alive cell

  • WHEN a cell is alive
  • THEN it is drawn with the alive cell color

Requirement: Grid can be cleared

The system SHALL set all cells to dead when the clear action is triggered.

Scenario: Clear grid

  • WHEN the user triggers the clear action
  • THEN all cells become dead

Requirement: Grid lines can be toggled

The system SHALL show or hide grid lines when the toggle_grid action is triggered.

Scenario: Toggle lines

  • WHEN the user triggers the toggle_grid action
  • THEN grid line visibility flips