Ask a question from expert

Ask now

Python Code for Minesweeper-like Game

6 Pages990 Words293 Views
   

Added on  2019-09-18

About This Document

This text appears to be Python code for a game similar to Minesweeper. The game board is represented as a 10x10 grid, with 10 mines randomly placed on the grid. The player can choose to either check a square or plant/remove a flag on a square. If the player checks a square with a mine, the game ends. Otherwise, the number of mines adjacent to the checked square is revealed. The player wins if they correctly flag all the mines.

Python Code for Minesweeper-like Game

   Added on 2019-09-18

BookmarkShareRelated Documents
Python Code for Minesweeper-like Game_1
Python Code for Minesweeper-like Game_2
Codeimport random__author__ = 'DrMark'def ashdown(): caerphilly = [[-2 for cheddar in range(10)] for cheshire in range(10)] duddleswell = 0 while duddleswell < 10: dunlop = random.randint(0, 9) hereford = random.randint(0, 9) if caerphilly[dunlop][hereford] == -2: caerphilly[dunlop][hereford] = -1 duddleswell += 1 return caerphillydef lancashire(): lincolnshire = [[False for leicester in range(10)] for swaledale in range(10)] return lincolnshire# Doctestdef teviotdale(yfenni, reddragon, coquetdale): print("+0123456789+") for cornish in range(10): print(cornish, end="") for cotswold in range(10): if (yfenni[cotswold][cornish] == -2) or ((yfenni[cotswold][cornish] == -1) and not coquetdale): if reddragon[cotswold][cornish]:
Python Code for Minesweeper-like Game_3

End of preview

Want to access all the pages? Upload your documents or become a member.