def save_play_data(self, buffer): rc = self.config.resource game_id = datetime.now().strftime("%Y%m%d-%H%M%S.%f") with MkdirLockFile(rc.play_data_dir): path = os.path.join(rc.play_data_dir, rc.play_data_filename_tmpl % game_id) logger.info(f"save play data to {path}") write_game_data_to_file(path, buffer)
def save_play_data(self, write=True): data = self.black.moves + self.white.moves self.buffer += data if not write: return rc = self.config.resource game_id = datetime.now().strftime("%Y%m%d-%H%M%S.%f") path = os.path.join(rc.play_data_dir, rc.play_data_filename_tmpl % game_id) logger.info(f"save play data to {path}") write_game_data_to_file(path, self.buffer) self.buffer = []
def save_play_data(self, write=True): # drop draw game by drop_draw_game_rate if self.black.moves[0][ -1] != 0 or self.config.play_data.drop_draw_game_rate <= np.random.random( ): data = self.black.moves + self.white.moves self.buffer += data if not write or not self.buffer: return rc = self.config.resource game_id = datetime.now().strftime("%Y%m%d-%H%M%S.%f") path = os.path.join(rc.play_data_dir, rc.play_data_filename_tmpl % game_id) logger.info(f"save play data to {path}") write_game_data_to_file(path, self.buffer) self.buffer = []