Daniel Plop 8a0629ded6
Fix mypy issues in tests and examples (#1077)
Closes #952 

- `SamplingConfig` supports `batch_size=None`. #1077
- tests and examples are covered by `mypy`. #1077
- `NetBase` is more used, stricter typing by making it generic. #1077
- `utils.net.common.Recurrent` now receives and returns a
`RecurrentStateBatch` instead of a dict. #1077

---------

Co-authored-by: Michael Panchenko <m.panchenko@appliedai.de>
2024-04-03 18:07:51 +02:00

41 lines
1.1 KiB
Python
Executable File

# import cv2
import os
import sys
import time
import tqdm
import vizdoom as vzd
def main(
cfg_path: str = os.path.join("maps", "D3_battle.cfg"),
lmp_path: str = os.path.join("test.lmp"),
) -> None:
game = vzd.DoomGame()
game.load_config(cfg_path)
game.set_screen_format(vzd.ScreenFormat.CRCGCB)
game.set_screen_resolution(vzd.ScreenResolution.RES_1024X576)
game.set_window_visible(True)
game.set_render_hud(True)
game.init()
game.replay_episode(lmp_path)
killcount = 0
with tqdm.trange(10500) as tq:
while not game.is_episode_finished():
game.advance_action()
state = game.get_state()
if state is None:
break
killcount = game.get_game_variable(vzd.GameVariable.KILLCOUNT)
time.sleep(1 / 35)
# cv2.imwrite(f"imgs/{tq.n}.png",
# state.screen_buffer.transpose(1, 2, 0)[..., ::-1])
tq.update(1)
game.close()
print("killcount:", killcount)
if __name__ == "__main__":
main(*sys.argv[-2:])