forked from lyudmil-mitev/Simple-Python-Chess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chess.py
executable file
·34 lines (27 loc) · 820 Bytes
/
chess.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
#!/usr/bin/env python
import os
import sys
if sys.version_info[0] > 2:
print("This game runs on python 2 only")
from chesslib import board
# Load a save if it exists
if os.path.exists("state.fen"):
with open("state.fen") as save:
game = board.Board(save.read())
else:
game = board.Board()
# Choose display method
if len(sys.argv) > 1:
if sys.argv[1] in ('--console', '-c'):
from chesslib.gui_console import display
display(game)
exit(0)
elif sys.argv[1] in ('--help', '-h'):
print '''Usage: game.py [OPTION]\n\n\tPlay a game of chess\n\n\tOptions:\n\t -c, --console\tplay in console mode\n\n'''
exit(0)
try:
from chesslib.gui_tkinter import display
except ImportError:
from chesslib.gui_console import display
finally:
display(game)