#NEWLINE# def startGame( board , playerSide , ai ) : #NEWLINE# #INDENT# parser = InputParser ( board , playerSide ) #NEWLINE# while True : #NEWLINE# #INDENT# print ( board ) #NEWLINE# print ( ) #NEWLINE# if board . isCheckmate ( ) : #NEWLINE# #INDENT# if ( board . currentSide == playerSide ) : #NEWLINE# #INDENT# print ( 'Checkmate, you lost' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( 'Checkmate! You won!' ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if board . isStalemate ( ) : #NEWLINE# #INDENT# if ( board . currentSide == playerSide ) : #NEWLINE# #INDENT# print ( 'Stalemate' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( 'Stalemate' ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if ( board . currentSide == playerSide ) : #NEWLINE# #INDENT# printPointAdvantage ( board ) #NEWLINE# move = None #NEWLINE# command = input ( "It's your move. Type '?' for options. ? " ) . lower ( ) #NEWLINE# if ( command == 'u' ) : #NEWLINE# #INDENT# undoLastTwoMoves ( board ) #NEWLINE# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( command == '?' ) : #NEWLINE# #INDENT# printCommandOptions ( ) #NEWLINE# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( command == 'l' ) : #NEWLINE# #INDENT# printAllLegalMoves ( board , parser ) #NEWLINE# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( command == 'r' ) : #NEWLINE# #INDENT# move = getRandomMove ( board , parser ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( command == 'quit' ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# move = parser . moveForShortNotation ( command ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if move : #NEWLINE# #INDENT# makeMove ( move , board ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( "Couldn't parse input, enter a valid command or move." ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# print ( 'AI thinking...' ) #NEWLINE# move = ai . getBestMove ( ) #NEWLINE# move . notation = parser . notationForMove ( move ) #NEWLINE# makeMove ( command , board )