MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / get_num_neighboring_bombs

Method get_num_neighboring_bombs

Minesweeper_game/minesweeper.py:39–48  ·  view source on GitHub ↗
(self, row, col)

Source from the content-addressed store, hash-verified

37 self.board[r][c] = self.get_num_neighboring_bombs(r, c)
38
39 def get_num_neighboring_bombs(self, row, col):
40 num_neighboring_bombs = 0
41 for r in range(max(0, row-1), min(self.dim_size-1, row+1)+1):
42 for c in range(max(0, col-1), min(self.dim_size-1, col+1)+1):
43 if r == row and c == col:
44 continue
45 if self.board[r][c] == '*':
46 num_neighboring_bombs += 1
47
48 return num_neighboring_bombs
49
50 def dig(self, row, col):
51 self.dug.add((row, col))

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected