Skip to content
Snippets Groups Projects
Commit 10a4be0e authored by Thomas Bianco's avatar Thomas Bianco
Browse files

fonctionnalite 5

parent 964b8776
Branches
No related tags found
No related merge requests found
{ {
"test_grid_2048.py::test_grid_to_string": true, "test_grid_2048.py::test_grid_to_string": true
"test_grid_2048.py::test_move_possible": true
} }
\ No newline at end of file
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"test_grid_2048.py::test_long_value_with_theme", "test_grid_2048.py::test_long_value_with_theme",
"test_grid_2048.py::test_move_row_left", "test_grid_2048.py::test_move_row_left",
"test_grid_2048.py::test_move_row_right", "test_grid_2048.py::test_move_row_right",
"test_grid_2048.py::test_move_grid",
"test_grid_2048.py::test_is_grid_full", "test_grid_2048.py::test_is_grid_full",
"test_grid_2048.py::test_move_possible" "test_grid_2048.py::test_move_possible"
] ]
\ No newline at end of file
...@@ -162,8 +162,11 @@ def is_grid_full(grid): ...@@ -162,8 +162,11 @@ def is_grid_full(grid):
def move_possible(grid): def move_possible(grid):
possibles = [] possibles = []
for d in ["left","right","up","down"]: for d in ["left","right","up","down"]:
possibles.append(move_gride(grid,d) != grid) possibles.append(move_grid(grid,d) != grid)
return possibles return possibles
def is_game_over(grid): def is_game_over(grid):
return is_grid_full(grid) and True not in move_possible(grid)
def get_grid_tile_max(grid):
return max(get_all_tiles(grid))
...@@ -84,6 +84,12 @@ def test_move_row_right(): ...@@ -84,6 +84,12 @@ def test_move_row_right():
assert move_row_right([2, 4, 4, 0]) == [0, 0, 2, 8] assert move_row_right([2, 4, 4, 0]) == [0, 0, 2, 8]
assert move_row_right([4, 8, 16, 32]) == [4, 8, 16, 32] assert move_row_right([4, 8, 16, 32]) == [4, 8, 16, 32]
def test_move_grid():
assert move_grid([[2,0,0,2], [4, 4, 0, 0], [8, 0, 8, 0], [0, 2, 2, 0]],"left") == [[4,0,0,0], [8, 0, 0, 0], [16, 0, 0, 0], [4, 0, 0, 0]]
assert move_grid([[2,0,0,2], [4, 4, 0, 0], [8, 0, 8, 0], [0, 2, 2, 0]],"right") == [[0,0,0,4], [0, 0, 0, 8], [0, 0, 0, 16], [0, 0, 0, 4]]
assert move_grid([[2,0,0,2], [2, 4, 0, 0], [8, 4, 2, 0], [8, 2, 2, 0]],"up") == [[4,8,4,2], [16, 2, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
assert move_grid([[2,0,0,2], [2, 4, 0, 0], [8, 4, 2, 0], [8, 2, 2, 0]],"down") == [[0, 0, 0, 0], [0, 0, 0, 0],[4,8,0,0],[16, 2, 4, 2]]
def test_is_grid_full(): def test_is_grid_full():
assert is_grid_full([[0, 16, 32, 0], [64, 0, 32, 2], [2, 2, 8, 4], [512, 8, 16, 0]]) == False assert is_grid_full([[0, 16, 32, 0], [64, 0, 32, 2], [2, 2, 8, 4], [512, 8, 16, 0]]) == False
assert is_grid_full([[4, 16, 32, 4], [64, 8, 32, 2], [2, 2, 8, 4], [512, 8, 16, 1024]]) == True assert is_grid_full([[4, 16, 32, 4], [64, 8, 32, 2], [2, 2, 8, 4], [512, 8, 16, 1024]]) == True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment