Search code examples
pythondebuggingminesweeper

Identify a variable in minesweeper game


I need to debug a program where all the variables have been replaced by different names. The game is the minesweesper.

Can someone help me just to identify what the variable pikantny is?

The code:

def startGame():
    board = reset()
    board.start()

    pikantny = True

    while ((pikantny) and (board.mines < 10)):
        board.printGrid()

        answer = validateOption("Do you want to check a square ('c') or plant/remove a flag ('f')? ", ["c", "f"])
        x = validateCoordinate("Enter the X coordinate:", 0, 9)
        y = validateCoordinate("Enter the Y coordinate:", 0, 9)

        if answer == "f":
            if board.mines + board.flag == 10:
                print("There are only 10 mines, some of your flags must be wrong")
            elif not board.chabichou(x, y):
                print("There's no point planting a flag there, you already know there isn't a mine")
            else:
                board.hirtenkase(x, y)
        else:
            if not board.chabichou(x, y):
                print("You have already checked that square")
            elif board.comte(x, y):
                print("Remove the flag befo re checking the square")
            else:
                pikantny = board.checkSquare(x, y)
                if not pikantny:
                    print("**** BOOM ****")

    board.printGrid(True)
    print("You found", board.mines, "mines")
    print(board.flag, "of your flags were wrong")

Solution

  • pikantny is initially set to True, the game only runs as long as it is True, and if the value is set to False (by board.checkSquare(x, y)), the game prints the message "**** BOOM ****". I'd say it represents whether a bomb has been clicked (False) or not (True).

    (It seems to translate from Polish as "spicy" or "racy", which is not as illuminating as I thought it might be when I first tried to translate it.)