浏览代码

modified the python side to read the logfile path from the academy parameters

/tag-0.2.0
vincentpierre 7 年前
当前提交
539c081f
共有 2 个文件被更改,包括 27 次插入7 次删除
  1. 2
      .gitignore
  2. 32
      python/unityagents/environment.py

2
.gitignore


/python/summaries
# Environemnt logfile
/python/unity-environment.log
*unity-environment.log
# Visual Studio 2015 cache directory
/unity-environment/.vs/

32
python/unityagents/environment.py


try:
self._socket.listen(1)
self._conn, _ = self._socket.accept()
self._conn.setblocking(1)
# self._conn.setblocking(1)
self._conn.settimeout(5)
p = self._conn.recv(self._buffer_size).decode('utf-8')
p = json.loads(p)
except socket.timeout as e:

self._data = {}
self._global_done = None
self._academy_name = p["AcademyName"]
self._log_path = p["logPath"]
self._brains = {}
self._brain_names = p["brainNames"]
self._external_brain_names = p["externalBrainNames"]

'\n'.join([str(self._brains[b]) for b in self._brains])
def _recv_bytes(self):
s = self._conn.recv(self._buffer_size)
message_length = struct.unpack("I", bytearray(s[:4]))[0]
s = s[4:]
while len(s) != message_length:
s += self._conn.recv(self._buffer_size)
try:
s = self._conn.recv(self._buffer_size)
message_length = struct.unpack("I", bytearray(s[:4]))[0]
s = s[4:]
while len(s) != message_length:
s += self._conn.recv(self._buffer_size)
except socket.timeout as e:
if not os.path.isfile(self._log_path):
raise UnityEnvironmentException("The environment took too long to respond. "
"No unity-environment.log file could be found.")
else:
with open(self._log_path, "r") as f:
printing= False
for l in f:
l=l.strip()
if (l == 'Exception') or (l=='Error'):
printing = True
print('----------------------')
if (l == ''):
printing = False
if printing:
print(l)
raise UnityEnvironmentException("The environment took too long to respond.")
return s
def _get_state_image(self, bw):

正在加载...
取消
保存