Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
minesweeper board generation and bomb generation.
import numpy as np;
ROW_COUNT = 5
COL_COUNT = 5
BOMES_COUNT = (ROW_COUNT * COL_COUNT) / 4
def create_board():
"""
create a board
"""
board = np.zeros((ROW_COUNT, COL_COUNT))
# generate random number of Bome on board
board = [[ 0, -1, 0, 0, 0,],
[ 0, 0, 0, -1, 0,],
[ 0, -1, 0, 0, 0,],
[ -1, 0, 0, 0, 0,],
[ 0, -1, 0, -1, 0,]]
return board
def create_bombs():
"""
generate bombs on the board
"""
return board
def check_number_of_bombs(board):
"""
looping board to count boums (-1) and return the total bombs
check the value top-left corner to left corner - [x-1][y-1] to [x+1][y+1] to [x][y-1]
"""
number = 0
# let looping to count
return number
board = create_board()
print(board)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.