Wrecs 1.0.0
See the version list below for details.
dotnet add package Wrecs --version 1.0.0
NuGet\Install-Package Wrecs -Version 1.0.0
<PackageReference Include="Wrecs" Version="1.0.0" />
<PackageVersion Include="Wrecs" Version="1.0.0" />
<PackageReference Include="Wrecs" />
paket add Wrecs --version 1.0.0
#r "nuget: Wrecs, 1.0.0"
#:package Wrecs@1.0.0
#addin nuget:?package=Wrecs&version=1.0.0
#tool nuget:?package=Wrecs&version=1.0.0
Wrecs
A deterministic ECS for coordinated state transitions, with optional patterns for agents, events, and turns.
Overview
- Entities are lightweight identities.
- Systems own state and expose immutable state snapshots.
- Mutations are proposed as deferred
UpdateSettransactions, then resolved, constrained, and committed in phases.
Wrecs emphasizes deterministic coordination and composable game/simulation logic through deferred, phased commits.
This makes Wrecs highly suited for:
- Turn-based games and simulations.
- Commercial or economic simulations requiring transactional atomicity (e.g., transfers of currency/resources).
- Autonomous agent environments where entities require a static, read-only snapshot of the world while "thinking."
High-Level Architecture
In Wrecs, data mutations are primarily deferred. A single simulation tick (Sim.Tick()) moves through a rigid set of phases:
- Dependency Injection Gate: At tick start, the simulation ensures
IRequire<T>dependencies are injected for systems and requiring entities. This runs lazily (first tick, and again after systems/entities are changed). - Preparation + Proposal Phase: Systems prepare internal updates (
ISystemInternalUpdatePreparer) and propose cross-system update sets (ISystemUpdateProposer) before any agent logic executes. - Agent Intent Translation Phase: Agents read context snapshots, produce intents, and translators convert each action into update sets. Per-action update sets are merged so each action becomes a single atomic
UpdateSet. - Conflict Resolution Phase: Each proposed
UpdateSetis passed through allISystemUpdateResolverimplementations, allowing in-place conflict resolution while preserving proposal order. - Constraint Validation Phase: Each resolved
UpdateSetis validated by allISystemConstraintimplementations. Invalid sets are rejected; constraint-produced events are queued. - Event Collection + Dispatch Phase: System-raised events (
ISystemEventRaiser) are collected, appended to queued constraint events, then dispatched to allISystemEventHandlerimplementations. - Commit Phase: Internal updates are applied (
ISystemInternalUpdateApplier), then accepted external/entity updates are applied (ISystemUpdateAcceptor) from all validUpdateSetentries.
Because state isn't mutated in the middle of a tick, an agent evaluating the world will not read a partially updated state caused by another agent that happened to act earlier in the same phase.
Data Structures and Interfaces
Entities and State
IEntity: The fundamental building block. Unlike Object-Oriented models, entities in Wrecs don't store their own data or components. An Entity is essentially just anIdand a human-readableName.ISystem: The base interface for systems. In Wrecs, systems are the repositories for state. A genericISystem<TMarkerInterface, TStateSnapshot>manages the mapping of entities to specific state structures.IStateSnapshot: An immutable snapshot of an entity's state for a given system. This ensures agents can read the world without risk of accidentally altering it outside of the rigid phase pipeline.
Actors and Logic
IAgent: A specializedIEntitythat actively does things. Agents define logic that returns anAgentIntentwhen evaluated.IAgentContext: Passed to agents during their evaluation phase. Systems implementingISystemAgentContextProviderenrich this context with whatever the agent needs to know (e.g., a spatial system provides surrounding positions; an inventory system provides current resources).AgentIntent/IAgentIntentAction: A declarative pattern describing what an agent wants to do, decoupling the desire from the execution.ISystemAgentIntentTranslator: Systems interceptIAgentIntentActions they know how to handle and translate them into a series of concrete state updates.
Mutation and Transactions
State mutations happen via explicitly declared bundles instead of direct assignment operations.
IEntityUpdate: A delayed application of a new state (IStateSnapshot) for a specific entity.UpdateSet: A grouping ofIEntityUpdaterecords that conceptually represent an atomic transaction. If multiple systems coordinate on something (e.g., Deduct Money from System A, Give Item in System B), they are bundled up here.- Application Lifecycle Interfaces for Systems:
ISystemInternalUpdatePreparer/IProposeUpdates: Hook for proposing updates during phase 1.ISystemInternalUpdateApplier: Hook for committing strict internal state during phase 4.ISystemUpdateAcceptor: Hook for receiving the big bucket ofIEntityUpdateinstances across the whole simulation and committing them to internal state.
Communication and DI
ISystemEventRaiser/ISystemEventHandler: A decoupled pub/sub pipeline ensuring systems can react to one-off scenarios globally without tightly coupling logic.IRequire<TSystem>: Indicates that a System or an Agent explicitly depends on another System being injected. The simulation layer automatically hooks these up. All dependency wiring is finalized on the initial un-paused tick viaSim.EnsureDependenciesInjected().
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.AI.Abstractions (>= 10.4.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.