def interactiveGame(currentGame, depth): # Fill me in #sys.exit('Interactive mode is currently not implemented') while currentGame.pieceCount != 42: if currentGame.currentTurn == 1: move = input('enter some number in the range of 1-7::') if move > 7 or move < 1: print 'Invalid move' continue if not currentGame.playPiece(move - 1): print 'No space left in this column..' continue try: currentGame.gameFile = open('human.txt', 'w') except: sys.exit('file not found') postmoveupdate(currentGame, move - 1) elif currentGame.pieceCount != 42: search = Minimax(currentGame, depth) move = search.decision() result = currentGame.playPiece(move) try: currentGame.gameFile = open("computer.txt", 'w') except: sys.exit('file not found') postmoveupdate(currentGame, move) currentGame.gameFile.close() if currentGame.player1Score == currentGame.player2Score: print 'It is a draw' elif currentGame.player2Score < currentGame.player1Score: print 'Human wins' else: print 'AI rampage'
def oneMoveGame(currentGame, depth): if currentGame.pieceCount == 42: # Is the board full already? print 'BOARD FULL\n\nGame Over!\n' sys.exit(0) search = Minimax(currentGame, depth) move = search.decision() result = currentGame.playPiece(move) postmoveupdate(currentGame, move) currentGame.gameFile.close()