Beispiel #1
0
    def on_configure(self, server, msg):
        attrutil.pprint(msg)

        if self.game_info is None:
            self.game_info = lookup.by_name(msg.game)
            self.sm = self.game_info.get_sm()

        else:
            if self.game_info.game != msg.game:
                log.critical("Game changed to %s" % msg.game)
                sys.exit(1)

        self.self_play_conf = msg.self_play_conf
        self.latest_generation_name = msg.generation_name

        # refresh the neural network.  May have to run some commands to get it.
        self.nn = None
        while self.nn is None:
            try:
                self.nn = get_manager().load_network(self.game_info.game,
                                                     self.latest_generation_name)

            except Exception as exc:
                log.error("error in on_configure(): %s" % exc)
                for l in traceback.format_exc().splitlines():
                    log.error(l)
                time.sleep(1.0)

        self.configure_self_play()
        return msgs.Ok("configured")
Beispiel #2
0
    def on_configure(self, server, msg):
        attrutil.pprint(msg)

        if self.game_info is None:
            self.game_info = lookup.by_name(msg.game)
            self.sm = self.game_info.get_sm()

        else:
            self.game_info.game == msg.game

        self.self_play_conf = msg.self_play_conf
        self.latest_generation_name = msg.generation_name

        # refresh the neural network.  May have to run some commands to get it.
        self.nn = None
        try:
            self.nn = get_manager().load_network(self.game_info.game,
                                                 self.latest_generation_name)
            self.configure_self_play()

        except Exception as exc:
            log.error("error in on_configure(): %s" % exc)
            for l in traceback.format_exc().splitlines():
                log.error(l)

            self.cmds_running = runprocs.RunCmds(
                self.conf.run_post_training_cmds,
                cb_on_completion=self.finished_cmds_running,
                max_time=180.0)
            self.cmds_running.spawn()

        return msgs.Ok("configured")
Beispiel #3
0
 def on_train_request(self, server, msg):
     log.warning("request to train %s")
     print attrutil.pprint(msg)
     self.train(msg.game, msg.train_conf, msg.network_model, msg.generation_description)
     return msgs.Ok("network_trained")