-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (35 loc) · 1.1 KB
/
main.py
File metadata and controls
49 lines (35 loc) · 1.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from chessengine.board import Board
import sys
def main():
currboard = Board(True)
whiteToMove = True
while True:
legalMoves = currboard.generateLegalMoves(whiteToMove)
print(legalMoves)
print(currboard)
inCheck = currboard.currInCheck(whiteToMove)
if inCheck:
print('Check')
if not legalMoves and inCheck:
print('Checkmate')
sys.exit()
if not legalMoves:
print('Stalemate')
sys.exit()
validMove = True
while validMove:
if whiteToMove:
entered_move = input('White to move: ')
else:
entered_move = input('Black to move: ')
if entered_move in legalMoves:
validMove = False
currboard.move(entered_move, whiteToMove)
if currboard.isStale():
print(currboard)
print('Stalemate by repitition')
sys.exit()
currboard.createboard()
whiteToMove = not whiteToMove
if __name__ == '__main__':
main()