-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnakeAI.py
20 lines (16 loc) · 876 Bytes
/
snakeAI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import argparse
from snake_engine.pygame_screen import run_display
from AI.q_learning import run_q_learn
def run(args):
should_learn = True if args.learn is not None else False
if args.nodisplay:
run_q_learn(args.learn, should_learn)
else:
run_display(args.learn, should_learn)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Python Q-Learning Agent that learns to play the game Snake")
parser.add_argument('--learn', dest="learn", type=int, help="The number of episodes (games) for the Snake to learn from (default 100000). If not specified will use prelearnt Q-table instead.", default=None)
parser.add_argument('--no-display', dest="nodisplay", action="store_true", help="Do not use Pygame to display the final Snake gameplay.", default=False)
args = parser.parse_args()
print(args)
run(args)