Skip to content
Snippets Groups Projects
Commit 639422b8 authored by Garance Guey's avatar Garance Guey
Browse files

tests

parents eeedb726 15883ac1
Branches
No related tags found
No related merge requests found
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
<option value="E501" /> <option value="E501" />
<option value="W29" /> <option value="W29" />
<option value="E501" /> <option value="E501" />
<option value="W29" />
<option value="E501" />
</list> </list>
</option> </option>
</inspection_tool> </inspection_tool>
......
File added
File added
...@@ -204,6 +204,7 @@ def list_move_possible (grid): ...@@ -204,6 +204,7 @@ def list_move_possible (grid):
return(list_final) return(list_final)
<<<<<<< HEAD
def random_play(): def random_play():
#on suppose que le jeu par defaut comprend une grille de 4x4 #on suppose que le jeu par defaut comprend une grille de 4x4
...@@ -229,3 +230,5 @@ def random_play(): ...@@ -229,3 +230,5 @@ def random_play():
return() return()
#TEST random_play() #TEST random_play()
=======
>>>>>>> 15883ac11a1d5e067e173c9ddba3c0e80ca1d0df
from grid_2048 import *
from textual_2048 import *
def random_play():
#on suppose que le jeu par defaut comprend une grille de 4x4
#phase d'initialisation du jeu
grid_game=init_game(4)
print(grid_to_string_with_size_and_theme(grid_game,THEMES["0"],4))
#phase de jeu
while not is_game_over(grid_game):
#pour chaque tour
d=rd.choice(list_move_possible(grid_game)) #on choisi un mouvement
grid_game=move_grid(grid_game,d) #on le fait
grid_game=grid_add_new_tile(grid_game) #une tuile se crée
print(grid_to_string_with_size_and_theme(grid_game,THEMES["0"],4)) #on affuche le résulat
print("\n***********************************\n") #permet aux différentes grilles d'être plus lisible
#vérification si le jeu est gagnant ou perdant
if did_you_win(grid_game):
print("CONGRATS ! YOU WON !!!")
else :
print ("YOU FAIL, TRY AGAIN")
return
def game_play():
# Saisie des paramètres
size = read_size_grid()
theme = read_theme_grid()
# Initialisation
grid = init_game(size)
print(grid_to_string_with_size_and_theme(grid,theme,size))
# Phase de jeu
while not is_game_over(grid):
direction = read_player_command() # Choix de la direction
possibles = list_move_possible(grid)
if direction in possibles:
grid = move_grid(grid,direction)
grid = grid_add_new_tile(grid)
print(grid_to_string_with_size_and_theme(grid,theme,size))
print("\n***********************************\n")
# Test de victoire
if did_you_win(grid_game):
print("CONGRATS ! YOU WON !!!")
else :
print ("YOU FAIL, TRY AGAIN")
return
THEMES = {"0": {"name": "Default", 0: "", 2: "2", 4: "4", 8: "8", 16: "16", 32:"32", 64: "64", 128: "128", 256: "256", 512: "512", 1024: "1024", 2048: "2048",4096: "4096", 8192: "8192"}, "1": {"name": "Chemistry", 0: "", 2: "H", 4: "He", 8:"Li", 16: "Be", 32: "B", 64: "C", 128: "N", 256: "O", 512: "F", 1024: "Ne", 2048:"Na", 4096: "Mg", 8192: "Al"}, "2": {"name": "Alphabet", 0: "", 2: "A", 4: "B", 8:"C", 16: "D", 32: "E", 64: "F", 128: "G", 256: "H", 512: "I", 1024: "J", 2048: "K",4096: "L", 8192: "M"}}
# FONCTIONNALITE 3 # FONCTIONNALITE 3
def read_player_command(): def read_player_command():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment