-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtestneat.py
More file actions
34 lines (25 loc) · 779 Bytes
/
testneat.py
File metadata and controls
34 lines (25 loc) · 779 Bytes
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
import os
import pickle
import neat
import gym
import numpy as np
# load the winner
with open('winner', 'rb') as f:
c = pickle.load(f)
print('Loaded genome:')
print(c)
# Load the config file, which is assumed to live in
# the same directory as this script.
local_dir = os.path.dirname(__file__)
config_path = os.path.join(local_dir, 'config')
config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction,
neat.DefaultSpeciesSet, neat.DefaultStagnation,
config_path)
net = neat.nn.FeedForwardNetwork.create(c, config)
env = gym.make("BipedalWalker-v3")
observation = env.reset()
done = False
while not done:
action = net.activate(observation)
observation, reward, done, info = env.step(action)
env.render()