-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndividual.cs
61 lines (48 loc) · 1.15 KB
/
Individual.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
public abstract class Individual
{
public float[] horizontalMoves;
public float[] verticalMoves;
public bool[] shots;
protected int totalSize;
protected float fitness;
protected bool evaluated;
protected int mutationType = 3;
protected int crossoverType = 1;
public int n_cuts;
public int MutationType {
get { return mutationType; }
set { mutationType = value; }
}
public int CrossoverType {
get { return crossoverType; }
set { crossoverType = value; }
}
public int Size {
get { return totalSize; }
}
public float Fitness {
get { return fitness; }
set {
fitness = value;
evaluated = true;
}
}
public bool Evaluated {
get { return evaluated; }
}
public Individual (int size)
{
totalSize = size;
fitness = 0f;
evaluated = false;
horizontalMoves = new float[size];
verticalMoves = new float[size];
shots = new bool[size];
}
//override on each specific individual class
public abstract void Initialize ();
public abstract void Mutate (float probability);
public abstract void Crossover (Individual partner, float probability);
public abstract void Translate ();
public abstract Individual Clone ();
}