|
import gym |
|
from evogym import sample_robot |
|
from gym.wrappers import Monitor |
|
|
|
|
|
import evogym.envs |
|
from dizoo.evogym.envs.viewer import DingEvoViewer |
|
from evogym.sim import EvoSim |
|
|
|
if __name__ == '__main__': |
|
gym.logger.set_level(gym.logger.DEBUG) |
|
|
|
body, connections = sample_robot((5, 5)) |
|
|
|
|
|
|
|
|
|
|
|
env = gym.make('Walker-v0', body=body) |
|
env.default_viewer = DingEvoViewer(EvoSim(env.world)) |
|
env = Monitor(env, './video', force=True) |
|
env.__class__.render = env.default_viewer.render |
|
env.metadata['render.modes'] = 'rgb_array' |
|
|
|
env.reset() |
|
|
|
for i in range(100): |
|
action = env.action_space.sample() |
|
ob, reward, done, info = env.step(action) |
|
x = env.render() |
|
if done: |
|
env.reset() |
|
env.close() |
|
|