Skip to content

armas77/ChaosSim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChaosSim

ChaosSim is a small grid-based ecosystem simulator written in .NET 8. It demonstrates a SOLID-friendly separation of concerns, allowing you to explore chaotic population dynamics by combining composable update rules.

Solution Layout

ChaosSim.sln
├─ ChaosSim.Domain          // Entities, value objects, and rule abstractions
├─ ChaosSim.Application     // World state implementation, rules, and simulation engine
├─ ChaosSim.Infrastructure  // Infrastructure services (e.g. randomness)
└─ ChaosSim.Console         // Console host with a reference scenario

Key abstractions live in the domain project (GridCell, Individual, SpeciesDefinition, IWorldUpdateRule, etc.), while the application layer builds on them with a mutable world state, mutation context, and reusable simulation pipeline.

Running the Sample

dotnet run --project ChaosSim.Console

The console host seeds two species across a 10x10 world, then executes 25 ticks using the default rule set (resource regeneration → foraging → movement → reproduction → metabolism). Each tick prints summary statistics and a subset of recorded events so you can observe emergent behaviour.

Simulation Flow

  1. WorldBuilder prepares environment cells, species, and seed individuals.
  2. SimulationPipelineFactory wires rules into a SimulationRunner.
  3. Each rule implements IWorldUpdateRule to mutate the world through IWorldMutationContext:
    • ResourceRegenerationRule replenishes cell resources.
    • ForagingRule lets individuals consume resources.
    • MovementRule guides individuals towards richer cells.
    • ReproductionRule spawns offspring when energy thresholds are exceeded.
    • MetabolismRule applies energy costs and ageing.
  4. SimulationRunner produces SimulationTickResult snapshots that aggregate state and events.

Extending the Model

  • Additional species traits: introduce predation, territoriality, or environmental resistances.
  • New rules: add weather events, disasters, or disease spread by creating more IWorldUpdateRule implementations.
  • Visualisation: project the snapshots into interactive dashboards (e.g. Blazor, MAUI) or export data for plotting.
  • Persistence: capture snapshots to disk for replay or analysis.
  • AI experiments: plug in optimisation loops that adjust traits and measure fitness over many runs.

Testing Guidance

  • Use a deterministic RandomSource seed (already supported) for repeatable scenarios.
  • Validate individual rules in isolation by constructing small WorldState instances and invoking the rules directly.
  • Consider approval or snapshot tests to monitor emergent behaviour when tweaking parameters.

Happy experimenting!

About

ChaosSim is a small grid-based ecosystem simulator written in .NET 8.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages