Skip to content

Repository files navigation

BIOME 2

BIOME 2 is a small .NET 8 cellular simulation and visualization project. It models layered cell worlds with configurable species and rule-driven behavior. The project includes a rules file loader, a simulation engine, and OpenGL-based rendering with an ImGui UI.

Key features

  • Rule-driven cellular simulation loaded from plain text rule files (Users of BIOME will be familiar with the language).
  • Multiple species can be defined with any number of rules governing their state.
  • Layered world model (discrete layers) with cross-layer interactions.
  • Support for different grid topologies (rectangular, disk)
  • OpenGL renderer and ImGui tools for inspection and placement

Requirements

  • .NET 8 SDK
  • A system with OpenGL support (for graphics)
  • Recommended IDE: Visual Studio or VS Code with C# extension

Build and run

From the repository root:

  • Restore and build: dotnet build
  • Run: dotnet run --project "BIOME 2.csproj"

Or open the solution in Visual Studio and run the BIOME 2 project.

Rules file format (summary)

Rules files are plain text with four sections separated by %%:

  1. Settings (key = value). Recognized keys include:

    • WIDTH = 150: sets world horizontal width
    • HEIGHT = 150: sets world vertical height
    • SHAPE = SPIRAL: sets world shape to "Spiral" mode, shaped like a disk. Exclude this or use RECT to use normal rectangular grid.
    • PAUSE: pauses the simulation upon load, useful if the user needs to provide some sort of input
    • EDGES: sets edge behavior; options include BORDER, WRAP, WRAPX, WRAPY, and INFINITE (default is BORDER)
  2. Species (one-per-line:

    • Format: name = {r,g,b} where r, g, & b are 0-255 color values
    • Example: GRASS = {0,150,0}
  3. Layers (one-per-line)

    • Format: DISCRETE layerName. Layers are discrete grids that can hold species.
    • Example: DISCRETE GROUND
  4. Rules (one-per-line)

    • Basic form: (coordLimits) layer:originSpecies +/- reactants -> newSpecies * probability
      • layer is optional; if omitted, the rule applies to the first layer.
      • originSpecies is the species being transformed.
      • reactants are conditions that must be met for the rule to apply. A given reactant has two modes: Neighbor Count and Layer.
        • When in Neighbor Count mode, the reactant specifies how many neighboring cells of a certain species must be present.
          • Example: 2TREE+ means there must be at least 2 or more neighboring TREE cells.
          • Example: 3WATER- means there must be at most 3 neighboring WATER cells.
          • Example: 0FIRE means there must be no neighboring FIRE cells.
        • When in Layer mode, the reactant specifies a certain species presence/absence in the same cell on another layer.
          • Example: AIR:WIND means the AIR layer must have WIND species present in the same cell.
          • The preceding sign + or - indicates presence or absence should be checked for, respectively.
          • Example: - AIR:STILL means the AIR layer must NOT have STILL species present in the same cell.
      • newSpecies is the species that the originSpecies will become if the rule's reactants are all true.
      • probability is an optional decimal value (double) between 0 and 1 indicating the chance of the transformation occurring when the rule conditions are met. Is assumed to be 1 when omitted.
      • coordLimits may be parenthesized in a prefix like (x1:x2,y1:y2) or 0:60 (which only applies to x-axis, for backwards compatibility)
        • Example: (10:50,20:80) GRASS + 1PIXIEDUST -> PIXIEDUST*0.1 means the rule only applies to cells with x-coordinates 10-50 and y-coordinates 20-80.
    • Example: GROUND:GRASS + 1TREE + AIR:OXYGEN -> TREE*0.05 means that in the GROUND layer, a GRASS cell with at least 1 neighboring TREE cell has a 5% chance to become a TREE.
    • See FileLoading/RulesLoader.cs for the authoritative parsing behavior

Example rules file:

WIDTH = 200
HEIGHT = 200
SHAPE = SPIRAL

%%

GRASS = {0,150,0}
TREE = {0,80,0}
FIRE = {255,0,0}

%%

DISCRETE GROUND

%%

GROUND:GRASS + 1TREE -> TREE*0.05
GROUND:GRASS + 1FIRE+ -> FIRE*0.1
GROUND:TREE + 1FIRE+ -> FIRE*0.1
GROUND:FIRE -> GRASS

Project layout (high-level)

  • FileLoading — rules parsing and models
  • Simulation — rule application and simulation controller
  • World — grid implementations, layers and state
  • Graphics — OpenGL renderer, shaders, UI windows
  • Input / App — input handling and application bootstrap

Contributing

  • Feel free to fork the repository, create a branch, and open a PR
  • run dotnet build before submitting

Troubleshooting

  • If rendering fails, update your OpenGL drivers
  • For rules parsing errors, check the console logs; the loader reports line numbers and positions
  • Check the Issues tab for known problems

License

See LICENSE in the repository root (if present).

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages