def main(args):
logger.debug("CONFIGURATION : {}".format(args))
#Global shared counter alloated in the shared memory. i = signed int
args.global_step = Value('i', 0)
#Barrier used to synchronize the threads
args.barrier = Barrier(args.num_actor_learners)
#Thread safe queue used to communicate between the threads
args.queue = Queue()
#Number of actions available at each steps of the game
args.nb_actions = atari_environment.get_num_actions(args.game)
if args.visualize == 0:
args.visualize = False
else:
args.visualize = True
actor_learners = []
#n-1 pipes are needed.
pipes = [Pipe() for _ in range(args.num_actor_learners - 1)]
#Loop launching all the learned on different process
for i in range(args.num_actor_learners):
if i == 0:
#A pipe to each other processe
args.pipes = [pipe[0] for pipe in pipes]
else:
#A pipe to the process 0
args.pipes = [pipes[i-1][1]]
#Process id
args.actor_id = i
#Random see for each process
rng = np.random.RandomState(int(time.time()))
args.random_seed = rng.randint(1000)
actor_learners.append(A3C_Learner(args))
actor_learners[-1].start()
#Waiting for the processes to finish
for t in actor_learners:
t.join()
logger.debug("All processes are over")
评论列表
文章目录