Skip to content

Commit 913e65f

Browse files
committed
Finished up on predator logic & rendering, slightly improved html file and entity rendering UI
0 parents  commit 913e65f

33 files changed

Lines changed: 2109 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v4
19+
with:
20+
dotnet-version: 4.7.2
21+
22+
- name: Restore dependencies
23+
run: dotnet restore
24+
25+
- name: Build
26+
run: dotnet build --no-restore --configuration Release
27+
28+
- name: Run tests
29+
run: dotnet test --no-build --configuration Release --verbosity normal --logger "trx;LogFileName=test-results.trx"
30+
31+
- name: Publish test results
32+
uses: dorny/test-reporter@v1
33+
if: always()
34+
with:
35+
name: Test Results
36+
path: '**/test-results.trx'
37+
reporter: dotnet-trx

.gitignore

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Build artifacts
2+
bin/
3+
obj/
4+
5+
# Visual Studio
6+
.vs/
7+
*.suo
8+
*.user
9+
*.userosscache
10+
*.sln.docstates
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Rr]elease/
16+
x64/
17+
x86/
18+
[Aa]rm/
19+
[Aa]rm64/
20+
bld/
21+
[Bb]in/
22+
[Oo]bj/
23+
[Ll]og/
24+
[Ll]ogs/
25+
26+
# Visual Studio cache/options
27+
.vscode/
28+
*.rsuser
29+
*.suo
30+
*.user
31+
*.userosscache
32+
*.sln.docstates
33+
34+
# NuGet
35+
packages/
36+
*.nupkg
37+
*.snupkg
38+
39+
# Test results
40+
[Tt]est[Rr]esult*/
41+
[Bb]uild[Ll]og.*
42+
43+
# Others
44+
*.cache
45+
*.log
46+
*.vsidx
47+
*.vspscc
48+
*.vssscc
49+
.builds
50+
*.pidb
51+
*.svclog
52+
*.scc

App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>

AssemblyInfo.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Ecoystem_Simulator")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Peter Symonds College")]
12+
[assembly: AssemblyProduct("Ecoystem_Simulator")]
13+
[assembly: AssemblyCopyright("Copyright © Peter Symonds College 2026")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("fff1a49e-1401-463f-919d-7035d3fed022")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]

Core/CritterGenome.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Ecosystem_Simulator.Core.Interfaces;
2+
using System;
3+
namespace Ecosystem_Simulator.Core
4+
{
5+
public class CritterGenome : IGenome
6+
{
7+
public float Speed { get; private set; }
8+
public float SightRadius { get; private set; }
9+
public float MetabolismEfficiency { get; private set; }
10+
public float ReproductionThreshold { get; private set; }
11+
public float GetGeneValue(string name)
12+
{
13+
return 0;
14+
}
15+
public void Mutate() { }
16+
public void Mutate(float ParentSpeed, float ParentSightRadius, float ParentMetabolismEfficiency, float ParentReproductionThreshold)
17+
{
18+
19+
20+
//Calculating change and adding it to parent genes
21+
float newSpeed = ParentSpeed + (float)((Settings.Rng.NextDouble() * 2 - 1) * (ParentSpeed * Settings.CritterMutationRate));
22+
float newSightRadius = ParentSightRadius + (float)((Settings.Rng.NextDouble() * 2 - 1) * (ParentSightRadius * Settings.CritterMutationRate));
23+
float newMetabolismEfficiency = ParentMetabolismEfficiency + (float)((Settings.Rng.NextDouble() * 2 - 1) * (ParentMetabolismEfficiency * Settings.CritterMutationRate));
24+
float newReproductionThreshold = ParentReproductionThreshold + (float)((Settings.Rng.NextDouble() * 2 - 1) * (ParentReproductionThreshold * Settings.CritterMutationRate));
25+
26+
//clamping to max values
27+
this.Speed = Math.Max(Settings.MinCritterSpeed,Math.Min(Settings.MaxCritterSpeed, newSpeed));
28+
this.SightRadius = Math.Max(Settings.MinCritterSightradius,Math.Min(Settings.MaxCritterSightradius, newSightRadius));
29+
this.MetabolismEfficiency = Math.Max(Settings.MinCritterMetabolismEfficiency,Math.Min(Settings.MaxCritterMetabolismEfficiency, newMetabolismEfficiency));
30+
this.ReproductionThreshold = Math.Max(Settings.MinCritterReproductionThreshold,Math.Min(Settings.MaxCritterReproductionThreshold, newReproductionThreshold));
31+
}
32+
33+
public CritterGenome(float Speed, float SightRadius, float MetabolismEfficiency, float ReproductionThreshold, bool newBorn = false)
34+
{
35+
if (newBorn)
36+
{
37+
Mutate(Speed,SightRadius,MetabolismEfficiency,ReproductionThreshold);
38+
}
39+
else
40+
{
41+
this.Speed = Speed;
42+
this.SightRadius = SightRadius;
43+
this.MetabolismEfficiency = MetabolismEfficiency;
44+
this.ReproductionThreshold = ReproductionThreshold;
45+
}
46+
47+
}
48+
49+
public CritterGenome()
50+
{
51+
Speed = Settings.StartingCritterSpeed;
52+
SightRadius = Settings.StartingCritterSightRadius;
53+
MetabolismEfficiency = Settings.StartingCritterMetabolismEfficiency;
54+
ReproductionThreshold = Settings.StartingCritterReproductionThreshold;
55+
}
56+
57+
}
58+
}

Core/Enums/SimulationState.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public enum SimulationState
2+
{
3+
Idle,
4+
Running,
5+
Paused,
6+
Extinct
7+
}

Core/Interfaces/IEatable.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Ecosystem_Simulator.Core.Interfaces
2+
{
3+
public interface IEatable : IUpdatable
4+
{
5+
float EnergyValue { get; }
6+
void Consume(); // What happens when it gets eaten?
7+
}
8+
}

Core/Interfaces/IEnergyPolicy.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Ecosystem_Simulator.Core.Interfaces
2+
{
3+
public interface IEnergyPolicy
4+
{
5+
float CalculateLoss(Vector2 velocity, float SightRadius, double deltaTime);
6+
}
7+
}

Core/Interfaces/IEntitity.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using Ecosystem_Simulator.Core;
2+
3+
public interface IEntity
4+
{
5+
Vector2 Position { get; }
6+
bool IsPendingRemoval { get; }
7+
}

Core/Interfaces/IGenome.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Ecosystem_Simulator.Core.Interfaces
2+
{
3+
public interface IGenome
4+
{
5+
float GetGeneValue(string name);
6+
void Mutate();
7+
}
8+
}

0 commit comments

Comments
 (0)