Skip to content

Extract Game of Life engine into a shared .NET library #56

Description

@hybridmachine

Context

The Engine/ directory is duplicated between the two .NET ports of GameOfLife3D:

  • GameOfLife3D.NET/src/GameOfLife3D.NET/Engine/* (desktop / Silk.NET)
  • GameOfLife3DWeb.NET/Engine/* (Blazor WebAssembly)

The web port was created by copy-pasting the desktop port's engine and only changing the namespace. The two copies are already diverging:

  • DeserializeGrid input validation was added to the web copy only
  • GameState switched from { get; set; } to { get; init; } in the web copy
  • PatternInfo default Author value and sealed modifier differ between copies

A bug fix to one copy will silently miss the other. This was flagged as the top architectural recommendation in a recent code review of feature/gameoflife-net-web.

Goal

Single source of truth for Game of Life simulation logic, consumed by both ports via project reference.

Proposed Shape

  • New project: GameOfLife3D.Engine (targeting net10.0 or netstandard2.1, whichever keeps both ports happy)
  • Contains: GameEngine, Generation, GameState, PatternInfo, RulePresets, Vector2Int
  • Namespace: GameOfLife3D.Engine
  • Both GameOfLife3D.NET and GameOfLife3DWeb.NET add <ProjectReference> and delete their local Engine/ copies
  • Tests move to GameOfLife3D.Engine.Tests and cover both ports

Tasks

  • Create shared library project
  • Resolve divergence points (pick one version of GameState, PatternInfo, DeserializeGrid validation)
  • Wire both ports to reference it
  • Move/merge GameOfLife3DWeb.NET.Tests/Engine/* into shared test project
  • Verify both ports build and run identically
  • Decide whether PatternLoader (desktop-only today) belongs in shared library or stays in the desktop port

Out of Scope

  • Any rule/engine behavior changes
  • UI or renderer changes

References

  • Code review from feature/gameoflife-net-web branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions