-
Notifications
You must be signed in to change notification settings - Fork 1
/
boilerplate.py
40 lines (35 loc) · 1.34 KB
/
boilerplate.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
40
import sys
def desc_move(move_str):
out_str = ''
move = move_str.split()
check = 'check' in move
mate = 'checkmate' in move
promote = 'promote' in move
capture = 'capture' in move
piece = move[2]
if promote:
if mate:
out_str = 'The ' + str(move[3][0])+ '-pawn promotes to a ' +
move[move.index('promote')+1] + ' and delivers checkmate'
elif check:
out_str = 'The ' + str(move[3][0]) + '-pawn promotes to a ' + piece + ' and checks the king'
else:
out_str = 'The ' + str(move[3][0]) + '-pawn promotes to a ' + piece
elif capture:
if mate:
out_str = 'The ' + piece + ' captures on ' + move[4] + ' and delivers checkmate'
if check:
out_str = 'The ' + piece + ' captures on ' + move[4] + ' and checks the king'
else:
out_str = 'The ' + piece + ' captures on ' + move[4]
else:
if mate:
out_str = 'The ' + piece + ' moves to ' + move[4] + ' and delivers checkmate'
elif check:
out_str = 'The ' + piece + ' moves to ' + move[4] + ' and checks the king'
else:
out_str = 'The ' + piece + ' moves to ' + move[4]
return out_str
if __name__ == "__main__":
for line in open(sys.argv[1]).readlines():
print(desc_move(line.strip()))