forked from facebookresearch/habitat-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
31 lines (22 loc) · 907 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import gym
import habitat.gym # noqa: F401
def example():
# Note: Use with for the example testing, doesn't need to be like this on the README
with gym.make("HabitatRenderPick-v0") as env:
print("Environment creation successful")
observations = env.reset() # noqa: F841
print("Agent acting inside environment.")
count_steps = 0
terminal = False
while not terminal:
observations, reward, terminal, info = env.step(
env.action_space.sample()
) # noqa: F841
count_steps += 1
print("Episode finished after {} steps.".format(count_steps))
if __name__ == "__main__":
example()