def interactiveGame(currentGame, depth): while currentGame.pieceCount != 42: if currentGame.currentTurn == 1: nextMove = input( "Enter the column between [1-7] where you want to insert your next coin : " ) if not currentGame.playPiece(nextMove - 1): print "This column is full!" continue if nextMove < 1 or nextMove > 7: print "Enter a column between [1-7]!" currentGame.gameFile = open("Human.txt", 'w') gameState(currentGame, nextMove - 1) elif currentGame.pieceCount != 42: minimaxTree = Minimax(currentGame, depth) move = minimaxTree.Decision() result = currentGame.playPiece(move) currentGame.gameFile = open("Computer.txt", 'w') gameState(currentGame, move) currentGame.gameFile.close() if currentGame.player1Score > currentGame.player2Score: print "User won" elif currentGame.player2Score > currentGame.player1Score: print "Computer won" else: print "Game Drawn"
def oneMoveGame(currentGame, depth): if currentGame.pieceCount == 42: # Is the board full already? print 'BOARD FULL\n\nGame Over!\n' sys.exit(0) tree = Minimax(currentGame, depth) move = tree.Decision() result = currentGame.playPiece(move) gameState(currentGame, move) currentGame.gameFile.close()