Created
March 7, 2019 15:50
-
-
Save Kyeongan/ff5f275f67e99a13f7dd91c462ebec43 to your computer and use it in GitHub Desktop.
minesweeper board generation and bomb generation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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