-
Notifications
You must be signed in to change notification settings - Fork 1
/
gene.py
49 lines (36 loc) · 1.27 KB
/
gene.py
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
# gene.py
dict_of_sm_so_far = { }# error! error! error!
curr_gen_no = 1
class Node:
def __init__(self, node_num, nature):
self.node_num = node_num
self.nature = nature # 'I','H1','H2','O'
def pp(self):
print("\n\tNode")
print("node_num: %d, nature: %r " % (self.node_num, self.nature))
print("--------")
class Conn:
def __init__(self, innov_num, couple, weight, status=True):
self.status = status # determines enabled or disabled
self.source = couple[0] # a node object
self.destination = couple[1] # same as above
self.weight = weight
self.innov_num = innov_num
def get_couple(self):
return (self.source, self.destination)
def set_weight(self, weight):
self.weight = weight
def pp(self):
print("\n\nConn")
print("innov_num:", self.innov_num)
print("couples are")
self.get_couple()[0].pp()
self.get_couple()[1].pp()
print("weight",self.weight,"status",self.status)
print("-----------------")
class BiasConn(Conn):
def __init__(self, out_node, weight):
numb = -1
nature = -1
status = True
Conn.__init__(self, -1, (Node(numb, nature), out_node), weight, status=status)