浏览代码

count trainer steps in controller by team id

/develop/cubewars
Andrew Cohen 5 年前
当前提交
88b8a922
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 9
      ml-agents/mlagents/trainers/ghost/controller.py

9
ml-agents/mlagents/trainers/ghost/controller.py


"""
self._swap_interval = swap_interval
self._last_swap: int = 0
# Tracks last swap step for each learning team because trainer
# steps of all GhostTrainers do not increment together
self._last_swap: Dict[int, int] = {}
self._queue: Deque[int] = deque(maxlen=maxlen)
self._learning_team: int = -1
# Dict from team id to GhostTrainer

"""
if team_id not in self._ghost_trainers:
self._ghost_trainers[team_id] = trainer
self._last_swap[team_id] = 0
if self._learning_team < 0:
self._learning_team = team_id
else:

:param step: Current step of the trainer.
:return: The learning team id
"""
if step >= self._swap_interval + self._last_swap:
self._last_swap = step
if step >= self._swap_interval + self._last_swap[self._learning_team]:
self._last_swap[self._learning_team] = step
self._queue.append(self._learning_team)
self._learning_team = self._queue.popleft()
return self._learning_team

正在加载...
取消
保存