Skip to content
Snippets Groups Projects
Commit 9513f6e1 authored by Dahmane Lynda's avatar Dahmane Lynda
Browse files

init

parent e7acefcc
No related branches found
No related tags found
No related merge requests found
......@@ -61,17 +61,13 @@ def neighborhood(x: int, y: int, width: int, height: int) -> list[tuple[int, int
$$$ neighborhood(3, 9, 10, 10)
[(2, 8), (2, 9), (3, 8), (4, 8), (4, 9)]
"""
res=[]
if x>0:
res+=[(x-1,y)]
if x< width-1:
res+=[(x+1,y)]
if y>0:
res+=[(x,y-1)]
if y<height-1:
res+=[(x,y+1)]
return res
neighbors=[]
for i in range(x-1,x+2):
for j in range(y-1,y+2):
if 0<=i<width and 0<=j<height and (i,j)!=(x,y):
neighbors.append((i,j))
return neighbors
class Minesweeper():
"""
......@@ -120,7 +116,8 @@ class Minesweeper():
"""
self.width= width
self.height= height
self.nbombs= nbombs
self.state= GameState.unfinished
self.nbombs=nbombs
self.grid=[(cell() for x in range(width) for y in range(height))]
......@@ -139,8 +136,7 @@ class Minesweeper():
"""
return self.grid[x][y]
def _put_a_bomb_at(self, x: int, y: int):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment