forked from chuyangliu/snake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
39 lines (30 loc) · 1014 Bytes
/
run.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
32
33
34
35
36
37
38
39
import argparse
from snake.game import Game, GameConf, GameMode
def main():
dict_solver = {
"greedy": "GreedySolver",
"hamilton": "HamiltonSolver",
"dqn": "DQNSolver",
}
dict_mode = {
"normal": GameMode.NORMAL,
"bcmk": GameMode.BENCHMARK,
"train_dqn": GameMode.TRAIN_DQN,
"train_dqn_gui": GameMode.TRAIN_DQN_GUI,
}
parser = argparse.ArgumentParser(description="Run snake game agent.")
parser.add_argument(
"-s",
default="hamilton",
choices=dict_solver.keys(),
help="name of the solver to direct the snake (default: hamilton)",
)
parser.add_argument("-m", default="normal", choices=dict_mode.keys(), help="game mode (default: normal)")
args = parser.parse_args()
conf = GameConf()
conf.solver_name = dict_solver[args.s]
conf.mode = dict_mode[args.m]
print(f"Solver: {conf.solver_name} Mode: {conf.mode}")
Game(conf).run()
if __name__ == "__main__":
main()