Implemented loader for CustomConfigEnv for humanPlayer
This commit is contained in:
parent
74ebb6e250
commit
0412afb69c
@ -1,16 +1,17 @@
|
|||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pygame
|
import pygame
|
||||||
|
import yaml
|
||||||
|
|
||||||
from columbus import env
|
from columbus import env
|
||||||
from columbus.observables import Observable, CnnObservable
|
from columbus.observables import Observable, CnnObservable
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
Env = chooseEnv()
|
env = chooseEnv()
|
||||||
env = Env(fps=30)
|
while True:
|
||||||
env.start_pos = [0.6, 0.3]
|
|
||||||
playEnv(env)
|
playEnv(env)
|
||||||
|
input('<again?>')
|
||||||
env.close()
|
env.close()
|
||||||
|
|
||||||
|
|
||||||
@ -22,6 +23,33 @@ def getAvaibleEnvs():
|
|||||||
yield getattr(env, s)
|
yield getattr(env, s)
|
||||||
|
|
||||||
|
|
||||||
|
def loadConfigDefinedEnv(EnvClass):
|
||||||
|
p = input('[Path to config> ')
|
||||||
|
with open(p, 'r') as f:
|
||||||
|
docs = list([d for d in yaml.safe_load_all(
|
||||||
|
f) if 'name' in d and d['name'] not in ['SLURM']])
|
||||||
|
for i, doc in enumerate(docs):
|
||||||
|
name = doc['name']
|
||||||
|
print('['+str(i)+'] '+name)
|
||||||
|
ds = int(input('[0]> ') or '0')
|
||||||
|
doc = docs[ds]
|
||||||
|
cur = doc
|
||||||
|
path = 'params.task.env_args'
|
||||||
|
p = path.split('.')
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
if len(p) == 0:
|
||||||
|
break
|
||||||
|
key = p.pop(0)
|
||||||
|
print(key)
|
||||||
|
cur = cur[key]
|
||||||
|
except Exception as e:
|
||||||
|
print('Unable to find key "'+key+'"')
|
||||||
|
path = input('[Path> ')
|
||||||
|
print(cur)
|
||||||
|
return EnvClass(fps=30, **cur)
|
||||||
|
|
||||||
|
|
||||||
def chooseEnv():
|
def chooseEnv():
|
||||||
envs = list(getAvaibleEnvs())
|
envs = list(getAvaibleEnvs())
|
||||||
for i, Env in enumerate(envs):
|
for i, Env in enumerate(envs):
|
||||||
@ -35,7 +63,10 @@ def chooseEnv():
|
|||||||
if i < 0 or i >= len(envs):
|
if i < 0 or i >= len(envs):
|
||||||
print(
|
print(
|
||||||
'[!] That is a number, but not one that makes sense in this context...')
|
'[!] That is a number, but not one that makes sense in this context...')
|
||||||
return envs[i]
|
if envs[i] in [env.ColumbusConfigDefined]:
|
||||||
|
return loadConfigDefinedEnv(envs[i])
|
||||||
|
Env = envs[i]
|
||||||
|
return Env(fps=30)
|
||||||
|
|
||||||
|
|
||||||
def playEnv(env):
|
def playEnv(env):
|
||||||
|
Loading…
Reference in New Issue
Block a user