In the popular Minesweeper game you have a board with some mines and those cells that don’t contain a mine have a number in it that indicates the total number of mines in the neighboring cells. Starting off with some arrangement of mines we want to create a Minesweeper game setup.
# 만약 현재 값이 true인 경우, 현재 인덱스의 값은 1 # 만약 현재 값이 false인 경우, 현재 인덱스의 값은 현재 위치 값의 주위에 true 개수
row = len(matrix) col = len(matrix[0])
MineCounterMat = np.zeros((row, col))
print(row) print(col)
for idx_row in range(row):
for idx_col in range(col):
MineCounter = 0
CurrVal = matrix[idx_row][idx_col]
if idx_row == 0: idx_row_set = [idx_row, idx_row + 1] if idx_row == row: idx_row_set = [idx_row - 1, idx_row]
if idx_col == 0: idx_col_set = [idx_col, idx_col + 1] if idx_col == col: idx_col_set = [idx_col - 1, idx_col]
print(idx_row_set) print(idx_col_set) for mine_row in idx_row_set: for mine_col in idx_col_set: if matrix[mine_row][mine_col]: print(mine_row) print(mine_col) MineCounter = MineCounter + 1