Skip to content

Instantly share code, notes, and snippets.

@Kyeongan
Created March 7, 2019 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kyeongan/ff5f275f67e99a13f7dd91c462ebec43 to your computer and use it in GitHub Desktop.
Save Kyeongan/ff5f275f67e99a13f7dd91c462ebec43 to your computer and use it in GitHub Desktop.
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