-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
31 lines (25 loc) · 732 Bytes
/
script.py
File metadata and controls
31 lines (25 loc) · 732 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
import argparse
from game import Game
import agent
# parse arguments
parser = argparse.ArgumentParser(description='2048 Game')
parser.add_argument('agent', metavar='a', type=str, default='human',
help='the agent that plays the game')
parser.add_argument('-v', '--verbose', action='store_true',
help='verbose flag')
args = parser.parse_args()
if args.agent == 'human':
player = agent.Human()
verbose = True
elif args.agent == 'random':
player = agent.RandomAgent()
elif args.agent == 'bestscore':
player = agent.BestScoreAgent()
if args.verbose:
verbose = True
else:
verbose = False
# run game
game = Game(4, player, verbose=verbose)
game.play()
print 'Took {} sec'.format(game.get_play_time())