-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMyChromosome.cs
More file actions
31 lines (26 loc) · 821 Bytes
/
MyChromosome.cs
File metadata and controls
31 lines (26 loc) · 821 Bytes
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
using System;
using GeneticAlgorithm.Interfaces;
namespace Environment
{
class MyChromosome : IChromosome
{
public ChromosomeType Type { get; private set; }
public MyChromosome(ChromosomeType type)
{
Type = type;
}
public double Evaluate()
{
// We don't need to implement this. Evaluations will be handled by our custom ChromosomeEvaluator.
throw new NotImplementedException();
}
/// <summary>
/// A mutation will change the type of a chromosome
/// </summary>
public void Mutate()
{
Type = Type == ChromosomeType.OProducer ? ChromosomeType.Oc2Producer : ChromosomeType.OProducer;
}
public override string ToString() => Type.ToString();
}
}