浏览代码

Clean up interface for AP

/develop/sac-apex
Ervin Teng 5 年前
当前提交
f6fcf512
共有 1 个文件被更改,包括 26 次插入8 次删除
  1. 34
      ml-agents/mlagents/trainers/agent_processor.py

34
ml-agents/mlagents/trainers/agent_processor.py


pass
def __init__(self, behavior_id: str, maxlen: int = 20):
def __init__(self, behavior_id: str, maxlen: int = 1):
self.maxlen: int = maxlen
self.queue: queue.Queue = queue.Queue(maxsize=maxlen)
self.behavior_id = behavior_id
self._maxlen: int = maxlen
self._queue: queue.Queue = queue.Queue(maxsize=maxlen)
self._behavior_id = behavior_id
def maxlen(self):
"""
Returns the maximum length of the queue.
:return: Maximum length of the queue.
"""
return self._maxlen
def behavior_id(self):
"""
Returns the Behavior ID of this queue.
:return: Behavior ID associated with the queue.
"""
return self._behavior_id
return self.queue.empty()
return self._queue.empty()
Blocking get
Gets the next item from the queue.
:param block: Block if the queue is empty. If False, exit immediately and
throw an AgentManagerQueue.Empty exception. (default = True)
:param timeout: Timeout for blocking get. If a positive float, wait timeout seconds
before throwing an AgentManagerQueue.Empty exception. (default = None)
return self.queue.get(block=block, timeout=timeout)
return self._queue.get(block=block, timeout=timeout)
self.queue.put(item)
self._queue.put(item)
class AgentManager(AgentProcessor):

正在加载...
取消
保存