If BOARD.mine and BOARD.status = "F":Ī, b = input("Supply an x and y coordinate to dig: ").Aubrey Gilman tells about the minesweepers on Utah Beach: If changes all your while loops so they break on success that avoids the confusion. You were inconsistent in whether status had to include the trailing blank (I'm not using it). Here's a slightly reorganized version of your code that works. MINES = int(input("How many mines do you want? ")) SIZE = int(input("Give me a size, between 3 and 10 inclusive ")) Print("It's Minesweeper, how wide do you want the board?") # set game parameters, give all the squares their neighbours Print("You found " + str(MINES) + " mines and didn't die.") # update square state after each dig to reveal mine status Otherwise, reveal nearby squaresĪ, b = input("Supply an x and y coordinate to dig: ").split(",") Try again.")Ī, b = input("Supply an x and y coordinate to unflag: ").split(",")Ī, b = input("Supply an x and y coordinate to flag: ").split(",") Print("f = Plant a flag marking a square as containing a mine.") Move = input("What would you like to do? ").lower() # keeps promting to dig, flag, or end the game # Recursively place mines, ignoring starting square Print("""Where would you like to start?\n""")Ī, b = input("Enter an x and y coodinate, comma separated, to dig the first square: ").split(",") # establish mine locations, ignoring stating dig The rest of it is your good old basic minesweeper. This version is a little different to the others out there in that it's supposed to start by asking the user how big the grid, then how many mines to insert. It's a basic minesweeper game in terminal. I have the following python code but I'm really struggling to get it to work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |