Esempio n. 1
0
def build_demo(choreography, filename):
	wad = Wad(ENDIAN)
	encoded = get_demo_sequence(wad, choreography)
	print("Choreography length: %d bytes" %(len(encoded),))
	wad.add_bin(encoded, is_choreography=True)

	dirname = os.path.dirname(filename)
	if dirname and not os.path.exists(dirname):
		os.makedirs(dirname)

	central_directory_size = wad.write(filename)
	print("wrote %s (central directory size: %d)" % (filename, central_directory_size))
Esempio n. 2
0
    def __init__(self,
                 config,
                 wad,
                 skiprate,
                 visible=False,
                 mode=Mode.PLAYER,
                 actions=None,
                 id=None,
                 wad_file=None,
                 map_id=0,
                 max_steps=150,
                 eval_mode=False):
        args = (
            ""
            #" +viz_nocheat 1"
            #" +viz_debug 0"
        )

        if wad_file is None:
            dir = os.path.dirname(config)
            wad_file = glob.glob(os.path.join(dir, '*.wad'))[0]
        #dir = os.path.dirname(config)
        #wad_file = '{}/oblige_{:04d}.wad'.format(dir, id)
        #wad_file = '{}/mock.wad'.format(dir)
        #map_id = 0

        super().__init__(config,
                         wad,
                         skiprate,
                         visible,
                         mode,
                         actions,
                         id,
                         args,
                         config_wad=wad_file,
                         map_id=map_id)
        self.distance = 1000
        self.level_map = None

        if not eval_mode:
            wad = Wad(wad_file)
            if wad.levels:
                self.level_map = wad.levels[map_id].get_map()
                self.distance = self.get_distance()
                self.reward_ratio = 10 / self.distance

        self.step_num = 0
        self.finished = False
        self.max_steps = max_steps
        self.eval_mode = eval_mode
        self.var_diff = np.zeros(6)
        self.shot = False
        self.shot_counter = 0
        self.enemy_in_view = False
        self.killcount = 0
        '''
 def get_game_levels(config):
     levels = []
     # assume config in a separate dir with wad files
     dir = os.path.dirname(config)
     file_list = glob.glob(os.path.join(dir, '*.wad'))
     file_list.sort()
     for wad_file in file_list:
         wad = Wad(wad_file)
         map_num = len(wad.levels)
         levels.extend([[wad_file, i] for i in range(map_num) if wad.levels[i].get_map().get_exits()])
     return levels
    def __init__(self,
                 config,
                 wad,
                 skiprate,
                 visible=False,
                 mode=Mode.PLAYER,
                 actions=None,
                 id=None,
                 wad_file=None,
                 map_id=0,
                 max_steps=150,
                 eval_mode=False):
        args = (
            ""
            #" +viz_nocheat 1"
            #" +viz_debug 0"
        )

        self.map = None

        if wad_file is None:
            dir = os.path.dirname(config)
            wad_file = glob.glob(os.path.join(dir, '*.wad'))[0]

        super().__init__(config,
                         wad,
                         skiprate,
                         visible,
                         mode,
                         actions,
                         id,
                         args,
                         config_wad=wad_file,
                         map_id=map_id)
        self.distance = 1000
        self.level_map = None

        if not eval_mode:
            wad = Wad(wad_file)
            if wad.levels:
                self.level_map = wad.levels[map_id].get_map()
                self.distance = self.get_distance()
                self.reward_ratio = self.distance / 100

        self.step_num = 0
        self.finished = False
        self.max_steps = max_steps
        self.eval_mode = eval_mode
        self.map = self.level_map.map.copy()
        self.discoveries = 0
    def __init__(self, config, wad, skiprate, visible=False, mode=Mode.PLAYER, actions=None, id=None, args=None, config_wad=None, map_id=None):
        super().__init__(config, wad, skiprate, visible, mode, actions, id, args, config_wad, map_id)
        self.angles = None
        self.map_mode = self.game.is_depth_buffer_enabled() and self.game.is_labels_buffer_enabled()
        if self.map_mode:
            width = self.game.get_screen_width()
            half_width = width / 2
            self.tan = np.ndarray(shape=(width,), dtype=float)
            fov = np.pi/2.0
            ratio = math.tan(0.5 * fov) / half_width
            for i in range(width):
                self.tan[i] = (i - half_width) * ratio

        wad = Wad(config_wad)
        if wad.levels:
            self.level_map = wad.levels[map_id].get_map()

        self.finished = False