forked from facebookresearch/habitat-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.py
More file actions
38 lines (26 loc) · 917 Bytes
/
agent.py
File metadata and controls
38 lines (26 loc) · 917 Bytes
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
32
33
34
35
36
37
import argparse
import habitat
import random
import numpy
import os
class RandomAgent(habitat.Agent):
def __init__(self, task_config: habitat.Config):
self._POSSIBLE_ACTIONS = task_config.TASK.POSSIBLE_ACTIONS
def reset(self):
pass
def act(self, observations):
return {"action": numpy.random.choice(self._POSSIBLE_ACTIONS)}
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--evaluation", type=str, required=True, choices=["local", "remote"])
args = parser.parse_args()
config_paths = os.environ["CHALLENGE_CONFIG_FILE"]
config = habitat.get_config(config_paths)
agent = RandomAgent(task_config=config)
if args.evaluation == "local":
challenge = habitat.Challenge(eval_remote=False)
else:
challenge = habitat.Challenge(eval_remote=True)
challenge.submit(agent)
if __name__ == "__main__":
main()