-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMyEnvironment.cs
38 lines (32 loc) · 916 Bytes
/
MyEnvironment.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using GeneticAlgorithm.Interfaces;
namespace Environment
{
class MyEnvironment : IEnvironment
{
public void UpdateEnvierment(IChromosome[] chromosomes, int generation)
{
O = 0;
OC2 = 0;
foreach (var chromosome in chromosomes)
{
var myChromosome = (MyChromosome) chromosome;
if (myChromosome.Type == ChromosomeType.OProducer)
{
O += 2;
OC2 -= 1;
}
else
{
OC2 += 2;
O -= 1;
}
}
O = Math.Max(0, O);
OC2 = Math.Max(0, OC2);
}
public int O { get; private set; }
public int OC2 { get; private set; }
public override string ToString() => $"O: {O}; OC2 {OC2}";
}
}