-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrganism.pde
More file actions
54 lines (43 loc) · 874 Bytes
/
Organism.pde
File metadata and controls
54 lines (43 loc) · 874 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class organism {
float[] genotype;
float fitness = 0;
float mutation;
int num_shapes;
int num_caracteristics;
organism(int shapes, int chars)
{
num_shapes = shapes;
num_caracteristics = chars;
genotype = new float[shapes*chars];
for (int i=0; i<genotype.length; i++)
genotype[i]=random(0, 1);
}
float get_mutation()
{
return mutation;
}
void set_mutation(float t)
{
mutation = t;
}
float get_fitness()
{
return fitness;
}
void set_fitness(float score)
{
fitness = score;
}
float get_caracteristic(int shape, int index)
{
return genotype[shape*num_caracteristics+index];
}
float get_weight(int index)
{
return genotype[index];
}
void set_weight(int index, float value)
{
genotype[index] = value;
}
}