def add_agent(self, agent_dir, name, train=False): assert len(self.agents) < s.MAX_AGENTS # if self.args.single_process: backend = SequentialAgentBackend(train, name, agent_dir) # else: # backend = ProcessAgentBackend(train, name, agent_dir) backend.start() agent = Agent(self.colors.pop(), name, agent_dir, train, backend) self.agents.append(agent)
def __init__(self, make_video=False, replay=False, live_preview=False): self._actions = self.ACTIONS self.ROWS, self.COLS = s.ROWS, s.COLS self._live_preview = False args = namedtuple("args", [ "no_gui", "fps", "log_dir", "turn_based", "update_interval", "save_replay", "replay", "make_video", "continue_without_training" ]) args.continue_without_training = False args.save_replay = False args.log_dir = "agent_code/koetherminator" if make_video: # not working yet! args.no_gui = False args.make_video = True # obviously gotta change to True if ffmpeg issue is fixed args.fps = 15 args.update_interval = 0.1 args.turn_based = False elif live_preview: self._live_preview = True args.no_gui = False args.make_video = False args.fps = 15 args.update_interval = 1 args.turn_based = False else: args.no_gui = True args.make_video = False if replay: args.save_replay = True # agents = [("user_agent", True)] + [("rule_based_agent", False)] * (s.MAX_AGENTS-1) agents = [("user_agent", True) ] + [("peaceful_agent", False)] * (s.MAX_AGENTS - 1) if not args.no_gui: pygame.init() self._world = BombeRLeWorld(args, agents) self._agent = self._world.agents[0] rb_agent_cfg = {"color": "blue", "name": "rule_based_agent"} rb_agent_backend = SequentialAgentBackend(False, rb_agent_cfg['name'], rb_agent_cfg['name']) rb_agent_backend.start() self._rb_agent = Agent(rb_agent_cfg['color'], rb_agent_cfg['name'], rb_agent_cfg['name'], train=False, backend=rb_agent_backend)