-
Notifications
You must be signed in to change notification settings - Fork 4
/
link.cpp
65 lines (56 loc) · 1.23 KB
/
link.cpp
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
#include "link.h"
using namespace NEAT;
Link::Link(double w,NNode *inode,NNode *onode,bool recur) {
weight=w;
in_node=inode;
out_node=onode;
is_recurrent=recur;
added_weight=0;
linktrait=0;
time_delay=false;
trait_id=1;
}
Link::Link(Trait *lt,double w,NNode *inode,NNode *onode,bool recur) {
weight=w;
in_node=inode;
out_node=onode;
is_recurrent=recur;
added_weight=0;
linktrait=lt;
time_delay=false;
if (lt!=0)
trait_id=lt->trait_id;
else trait_id=1;
}
Link::Link(double w) {
weight=w;
in_node=out_node=0;
is_recurrent=false;
linktrait=0;
time_delay=false;
trait_id=1;
}
Link::Link(const Link& link)
{
weight = link.weight;
in_node = link.in_node;
out_node = link.out_node;
is_recurrent = link.is_recurrent;
added_weight = link.added_weight;
linktrait = link.linktrait;
time_delay = link.time_delay;
trait_id = link.trait_id;
}
void Link::derive_trait(Trait *curtrait) {
if (curtrait!=0) {
for (int count=0;count<NEAT::num_trait_params;count++)
params[count]=(curtrait->params)[count];
}
else {
for (int count=0;count<NEAT::num_trait_params;count++)
params[count]=0;
}
if (curtrait!=0)
trait_id=curtrait->trait_id;
else trait_id=1;
}