https://github.com/openchanter/ecosystems
A simple 3D ecosystem simulation made in C#
https://github.com/openchanter/ecosystems
3d ecosystems game simulation
Last synced: 4 months ago
JSON representation
A simple 3D ecosystem simulation made in C#
- Host: GitHub
- URL: https://github.com/openchanter/ecosystems
- Owner: OpEnchanter
- Created: 2025-08-26T01:44:52.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-18T16:11:41.000Z (9 months ago)
- Last Synced: 2025-09-18T17:00:07.031Z (9 months ago)
- Topics: 3d, ecosystems, game, simulation
- Language: C#
- Homepage:
- Size: 4.47 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ecosystem Simulation đ
This is a basic ecosystem simulation game made with a Raylib port (Vinculum) in C#. It features different organisms that interact with eachother (ex. fox, rabbit, bush) as well as a random island generator for the play area and various features for understanding the simulation and logging results.
## Repository Stats đ
[](https://github.com/OpEnchanter/ecosystems/actions/workflows/build.yml)
[](https://wakatime.com/badge/user/98f6777a-987b-4ee6-8815-04a0d8ae8626/project/2e3ef99d-2602-4d64-9470-7c536294cd83)
## Controls đšī¸
### **Movement**
- **Forward** : `W`
- **Backward** : `S`
- **Left** : `A`
- **Right** : `D`
- **Down** : `Left Control`
- **Up** : `Space`
- **Sprint** : `Shift`
- **Interact**: `Left Click`
### **Menus**
- **Open menu** : `Tab`
- **Use the menu**: The menu has options for logging data, quitting the game, turning on debug mode and turning on cheats.
- **Open god menu**: `Left click on organism`
- **Use god meny**: The god menu allows you to interact with organisms such as killing them feeding them and hydrating them.
## Logging Display đ
The python file in `plot/python` can be used to visualize the logs generated by the program.
**Prerequisites**
- `pandas`
- `matplotlib`
These prerequisites can be installed with
```pwsh
pip install pandas matplotlib
```
The graph can be loaded and run with
```pwsh
python ./plot/main.py
```
## Debug mode â
Debug mode gives an ingame look into the inner workings of the simulation.
**Features**
- Displays stats about organisms above them (ex. traits and stats)
- Displays organism's pathing target
## Examples đ
These are some examples of environments that have been generated within the simulation.


## Getting Started đ
1. Download the `.zip` from the releases on this page.
2. Unzip the file.
3. Run the `.exe` (if prompted asking if you want to run the file click more options, then run anyway).
> **Note**: Currently, if you want to use this on Linux or MacOS you will have to compile from source yourself.
## Compile from source đž
### Prerequisites
- **.NET**: Ensure that you have the .NET SDK installed on your computer.
### Run the simulation
1. Clone the repository
```pwsh
git clone https://github.com/OpEnchanter/ecosystems.git
```
2. Navigate to the project's directory
```pwsh
cd ecosystems
```
3. Build and run
```pwsh
dotnet run
```
## Code examples
If you want to modify the simulation to add your own personal organisms you can create the organism and make it spawn by modifying `Program.cs`.
> **Note**: You should have a decent understanding of `C#` before attempting to modify the code.
### Load the model
Load the organism's model and texture and use them.
```cs
Image image = Raylib.LoadImage("texture.png"); // Load the texture as an Image
Texture texture = Raylib.LoadTextureFromImage(image); // Load Texture from image
Model model = Raylib.LoadModelFromMesh("model.obj"); // Load model
model.materials[0].maps[(int)MaterialMapIndex.MATERIAL_MAP_ALBEDO].texture = texture; // Apply texture to model
model.materials[0].shader = lit; // Apply lit shader to model
```
### Create the organism
Create a new organism and give it a model and position, then modify it's traits (note that it will evolve and the traits will change).
```cs
Organism organism = new Organism() {
model = model;
organismPosition = new Vector3(0,0,0);
} // Create and organism with a model and position
// Modify organism traits
organism.traits.eyesight = 10.0f;
organism.traits.speed = 1.0f;
organism.traits.oType = organismType.CustomOrganism; // A new organism type must be added to the organismType enum
organism.traits.foodSources = new organismType[] { organismType.Bush }; // What the organism can eat
organism.traits.hydrationSources = new fluidType[] { fluidType.Water }; // How the organism can get hydration
```
### Make the organism spawn
Modify the function call beginning on line 601 to include a number and reference to your organism.
```cs
placeFeatures(new Dictionary
{
{ bush, 150 },
{ fox, 120 },
{ rabbit, 120 },
{ organism, 400} // This will spawn 400 of organism on the island
}, *groundHeightmap, terrainThreshold);
```
## Code line count đ§Ž
If you want to check how many lines of code there are in the project (either if you are curious or you made an addition) you can run the command
```pwsh
cloc ./ --include-lang=C#,Python
```
This is assuming you have `cloc.exe` somewhere on your computer and it is added to your `PATH`