-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
57 lines (31 loc) · 1.08 KB
/
main.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
41
42
43
44
45
46
47
48
from ChessUtils.ChessID import ChessID
from ChessUtils.ChessGameDriver import ChessGameDriver
from ChessUtils.DeepChess import DeepChess
import chess
from SerialUtils.ArduinoInterface import ArduinoInterface
# Initialize Chess ID module
chessid = ChessID()
# Calibrate the chess board position
chessid.calibrateBoardPosition()
deepchess = DeepChess()
# Initialize Chess Game Driver
chessDriver = ChessGameDriver()
# Start a new chess game
chessDriver.startNewGame()
# Create the Arduino Serial interface object
arduino = ArduinoInterface()
# Perform initialization handshake with Arduino
arduino.initHandshake()
print("INFO: Completed Initialization")
shutdown = False
while(not shutdown):
print(chessDriver.board)
arduino.waitForPlayerMove()
piecePredictions = chessid.getBoardState()
chessDriver.addPlayerMove(piecePredictions)
print(chessDriver.board)
startSquare, endSquare, capture = deepchess.generateMove(chessDriver.getBoard())
print(startSquare)
print(endSquare)
print(capture)
arduino.moveChessPiece(startSquare, endSquare, capture)