from gym import logger from gym.envs.external_games.supertuxkart import SuperTuxKart FRAMEBUFFER_SIZE = 10 env = SuperTuxKart(spf=0.000887, framebuffer_size=FRAMEBUFFER_SIZE, width=800, height=600, level='scotland', mode='time') env.reset() logger.set_level(logger.DEBUG) last_gt = 0 last_st = 0 for _ in range(10): for i in range(10): ob, reward, done, scores = env.step('throttle') gt = scores['game_time'] st = scores['system_time'] delta_gt = gt - last_gt delta_st = st - last_st print(f"Game: {delta_gt}") print(f"System: {delta_st}") last_gt = gt last_st = st
framebuffer_size=4, width=800, height=600, level='scotland', mode='time', speedup=1, observe_performance=False) # You provide the directory to write to (can be an existing # directory, including one with existing data -- all monitor files # will be namespaced). You can also dump to a tempdir if you'd # like: tempfile.mkdtemp(). outdir = '/tmp/random-agent-results' agent = SuperTuxKartAgent(env.action_space) episode_count = 5 reward = 0 scores = None for i in range(episode_count): done = False ob = None j = 0 while not done: action = agent.act(ob, reward, done, scores) ob, reward, done, scores = env.step(action) ob[1][0].save(f"screenshots/EP-{i}:STEP-{j}.ppm", overwrite=True) j += 1 ob = env.reset() env.close()