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

Tp5

parent 33c98436
No related branches found
No related tags found
No related merge requests found
...@@ -218,25 +218,21 @@ class Minesweeper(): ...@@ -218,25 +218,21 @@ class Minesweeper():
GameState.losing GameState.losing
""" """
Cell=self.get_cell(x,y) cell=self.grid[x][y]
cell.reveal()
if Cell.is_bomb: if Cell.is_bomb:
self.state=GameState.losing self.state=GameState.losing
else: elif Cell.nbomb_in_neighborhood==0:
Cell.is_revealed=True for (xn,yn) in neighborhood(x,y, self.width, self.height):
if Cell.nbomb_in_neighborhood==0: if not self.grid[yn][xn].is_revealed:
self.reveal_all_cells_from(xn, yn)
neighbor =self.get_neighbors(x,y)
for neighbor in neighbors:
if not neighbor.is_revealed: if self.all_cells_are_revealed_or_bomb() :
self.state=GameState.winning
self.reveal_all_Cells_from(neighbor.x,neighbor.y)
if self.all_Cells_are_revealed_or_bomb():
self.state=GameState.winning
if (__name__ == '__main__'): if (__name__ == '__main__'):
import apl1test import apl1test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment