Esempio n. 1
0
def saveGameStateToFile():
    try:
        # Gets the board from the backend, initializes a new save file to write to (overwrites any existing one),
        #  and loops through the board matrix and writes it to the file
        gameBoard = backend.getBoard()
        saveGameFile = open("Reversi Save Game", "w")
        for rowCounter in range(8):
            for columnCounter in range(8):
                saveGameFile.write(str(gameBoard[rowCounter][columnCounter]))
        saveGameFile.write(str(backend.getDifficulty()))
        saveGameFile.close()
    except Exception:
        pass