-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnection.pde
More file actions
66 lines (60 loc) · 1.65 KB
/
Connection.pde
File metadata and controls
66 lines (60 loc) · 1.65 KB
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
62
63
64
65
66
static class Connection {
Neuron neuronIn, neuronOut;
Network network;
float weight;
int innovationNumber;
boolean enabled;
static int globalInnovationNumber =
0; // the next innovation number, globally
Connection(
Network network,
Neuron neuronIn,
Neuron neuronOut,
float weight
) {
this(network, neuronIn, neuronOut, weight, globalInnovationNumber);
network.connections.add(this);
globalInnovationNumber++; // so that all innovation numbers are unique
}
Connection(
Network network,
Neuron neuronIn,
Neuron neuronOut,
float weight,
int innovationNumber
) {
this(network, neuronIn, neuronOut, weight, innovationNumber, true);
}
Connection(
Network network,
Neuron neuronIn,
Neuron neuronOut,
float weight,
int innovationNumber,
boolean enabled
) {
this.network = network;
this.neuronIn = neuronIn;
this.neuronOut = neuronOut;
this.weight = weight;
this.innovationNumber = innovationNumber;
this.enabled = enabled;
}
void newInnovationNumber() {
this.innovationNumber = globalInnovationNumber;
globalInnovationNumber++; // so that all innovation numbers are unique
}
Connection copy(Network network) {
return new Connection(
network,
neuronIn,
neuronOut,
weight,
innovationNumber,
enabled
);
}
float getInnovationNumber() { // for sorting and max and min
return innovationNumber;
}
}