88import random as rnd
99import pickle
1010import numpy as np
11+ from tqdm import tqdm
1112import cv2
1213
1314substrate = NEAT .Substrate ([(- 1 , - 1 ), (- 1 , 0 ), (- 1 , 1 )],
1415 [(0 , - 1 ), (0 , 0 ), (0 , 1 )],
1516 [(1 , 0 )])
1617
17- substrate .m_allow_input_hidden_links = False ;
18- substrate .m_allow_input_output_links = False ;
19- substrate .m_allow_hidden_hidden_links = False ;
20- substrate .m_allow_hidden_output_links = False ;
21- substrate .m_allow_output_hidden_links = False ;
22- substrate .m_allow_output_output_links = False ;
23- substrate .m_allow_looped_hidden_links = False ;
24- substrate .m_allow_looped_output_links = False ;
18+ substrate .m_allow_input_hidden_links = False
19+ substrate .m_allow_input_output_links = False
20+ substrate .m_allow_hidden_hidden_links = False
21+ substrate .m_allow_hidden_output_links = False
22+ substrate .m_allow_output_hidden_links = False
23+ substrate .m_allow_output_output_links = False
24+ substrate .m_allow_looped_hidden_links = False
25+ substrate .m_allow_looped_output_links = False
2526
26- substrate .m_allow_input_hidden_links = True ;
27- substrate .m_allow_input_output_links = False ;
28- substrate .m_allow_hidden_output_links = True ;
29- substrate .m_allow_hidden_hidden_links = False ;
27+ substrate .m_allow_input_hidden_links = True
28+ substrate .m_allow_input_output_links = False
29+ substrate .m_allow_hidden_output_links = True
30+ substrate .m_allow_hidden_hidden_links = False
3031
31- substrate .m_hidden_nodes_activation = NEAT .ActivationFunction .SIGNED_SIGMOID ;
32- substrate .m_output_nodes_activation = NEAT .ActivationFunction .UNSIGNED_SIGMOID ;
32+ substrate .m_hidden_nodes_activation = NEAT .ActivationFunction .SIGNED_SIGMOID
33+ substrate .m_output_nodes_activation = NEAT .ActivationFunction .UNSIGNED_SIGMOID
3334
34- substrate .m_with_distance = True ;
35+ substrate .m_with_distance = True
3536
36- substrate .m_max_weight_and_bias = 8.0 ;
37+ substrate .m_max_weight_and_bias = 8.0
3738
3839try :
3940 x = pickle .dumps (substrate )
@@ -129,7 +130,7 @@ def main():
129130 generations = 10
130131
131132 g = NEAT .Genome (0 , 24 + 1 + 1 , 0 , 4 , False ,
132- NEAT .ActivationFunction .TANH , NEAT .ActivationFunction .TANH , 0 , params , 0 )
133+ NEAT .ActivationFunction .TANH , NEAT .ActivationFunction .TANH , 0 , params , 0 , 1 )
133134 pop = NEAT .Population (g , params , True , 1.0 , rnd .randint (0 , 1000 ))
134135 hof = []
135136 maxf_ever = 0
@@ -142,7 +143,7 @@ def main():
142143 #args = [x for x in NEAT.GetGenomeList(pop)]
143144 #dv.block=True
144145 #fitnesses = dv.map_sync(evaluate_genome, args)
145- for _ , genome in enumerate (NEAT .GetGenomeList (pop )):
146+ for _ , genome in tqdm ( enumerate (NEAT .GetGenomeList (pop ) )):
146147 fitness = evaluate_genome (env , genome , trials )
147148 fitnesses .append (fitness )
148149 for genome , fitness in zip (NEAT .GetGenomeList (pop ), fitnesses ):
@@ -184,10 +185,10 @@ def do_trial(env, net, render_during_training):
184185 net .Flush ()
185186
186187 f = 0
187- for t in range (300 ):
188+ for t in range (500 ):
188189
189190 if render_during_training :
190- time .sleep (0.001 )
191+ # time.sleep(0.001)
191192 env .render ()
192193
193194 # interact with NN
0 commit comments