Add nearly all gym environments using pybullet together with the latest tf model from the roboschool model zoo.

This commit is contained in:
Benjamin Ellenberger
2017-07-14 23:38:15 +02:00
parent 40dae99435
commit a6aade2e21
35 changed files with 82536 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import re
from gym import error
import glob
# checkpoints/KerasDDPG-InvertedPendulum-v0-20170701190920_actor.h5
weight_save_re = re.compile(r'^(?:\w+\/)+?(\w+-v\d+)-(\w+-v\d+)-(\d+)(?:_\w+)?\.(\w+)$')
def get_fields(weight_save_name):
match = weight_save_re.search(weight_save_name)
if not match:
raise error.Error('Attempted to read a malformed weight save: {}. (Currently all weight saves must be of the form {}.)'.format(id,weight_save_re.pattern))
return match.group(1), match.group(2), int(match.group(3))
def get_latest_save(file_folder, agent_name, env_name, version_number):
"""
Returns the properties of the latest weight save. The information can be used to generate the loading path
:return:
"""
path = "%s%s"% (file_folder, "*.h5")
file_list = glob.glob(path)
latest_file_properties = []
file_properties = []
for f in file_list:
file_properties = get_fields(f)
if file_properties[0] == agent_name and file_properties[1] == env_name and (latest_file_properties == [] or file_properties[2] > latest_file_properties[2]):
latest_file_properties = file_properties
return latest_file_properties