forked from gosom/tic-tac-toe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_cmd.py
More file actions
31 lines (26 loc) · 1 KB
/
run_cmd.py
File metadata and controls
31 lines (26 loc) · 1 KB
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
# -*- coding: utf-8 -*-
"""
Let two players play tic tac toe in the command line
Use option -h for help
"""
import logging
import argparse
from tictac.lib.game import TicTacGame
from tictac.lib.player import RandomPlayer, SmartPlayer
def parse_args():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-s', '--smart', action='store_true',
help='Use to allow player1 to play smart',
default=False)
parser.add_argument('-v', '--verbose', action='store_true',
default=False, help='Use to see more output')
return parser.parse_args()
if __name__ == '__main__':
args = parse_args()
loglevel = logging.DEBUG if args.verbose else logging.INFO
#logging.basicConfig(level=loglevel)
p1 = SmartPlayer(1) if args.smart else RandomPlayer(1)
thegame = TicTacGame(player1=p1, player2=RandomPlayer(-1))
logging.debug('Initial state:\n%s', repr(thegame))
thegame.start()
print thegame.stats