Ejemplo n.º 1
0
 def test_eat_and_move_east(self):
     blobble_env = BlobbleEnv()
     blobble_env.reset()
     observation = blobble_env.reset_test([3, 3, 5], TEST_FOOD)
     print(observation)
     self.assertEqual(1, observation[3], 'Should be food of value 1')
     observation, reward, done, _ = blobble_env.step(7)  # Eat food, Go East
     print(observation)
     observation, reward, done, _ = blobble_env.step(4)  # Go West back to original (no food) spot
     print(observation)
     self.assertEqual(0, observation[3], 'Should be no food')
     observation, reward, done, _ = blobble_env.step(4)
     blobble_env.render(mode='human')
Ejemplo n.º 2
0
def create_blobble_video(video_filename, num_episodes=1, fps=30):
    filename = video_filename + ".mp4"

    blobble_env = BlobbleEnv()

    print('Observation space: '+str(blobble_env.observation_space))
    print('Action space:      '+str(blobble_env.action_space))

    with imageio.get_writer(filename, fps=fps) as video:
        for i in range(num_episodes-1):
            print(i)
            blobble_env.reset()
            done = False
            while not done:
                action = np.random.randint(8)
                print('Next Action: ', action)
                observation, reward, done, _ = blobble_env.step(action)
                blobble_env.render_print()
                video.append_data(blobble_env.render(mode='rgb_array'))

    blobble_env.close()
Ejemplo n.º 3
0
 def test_render_human(self):
     blobble_env = BlobbleEnv()
     blobble_env.reset()
     blobble_env.reset_test([-2, 5, 5], TEST_FOOD)
     blobble_env.render(mode='human')