diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 579ee6c3d835f204e49f244f0ca87be3de4419d2..1cc4cadcb94f1cb025667abbb79508d573b7c473 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -8,6 +8,8 @@ <option value="E501" /> <option value="W29" /> <option value="E501" /> + <option value="W29" /> + <option value="E501" /> </list> </option> </inspection_tool> diff --git a/game2048/__pycache__/grid_2048.cpython-36.pyc b/game2048/__pycache__/grid_2048.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b4ec16f7a48441ea6719758968776a24b0e1f56d Binary files /dev/null and b/game2048/__pycache__/grid_2048.cpython-36.pyc differ diff --git a/game2048/__pycache__/textual_2048.cpython-36.pyc b/game2048/__pycache__/textual_2048.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4fcab3570c43c02c800419b57b77edf6e961e609 Binary files /dev/null and b/game2048/__pycache__/textual_2048.cpython-36.pyc differ diff --git a/game2048/grid_2048.py b/game2048/grid_2048.py index 05f38a52187b98b37fc565f6220e4c72311e8b25..fc2b8a35c2f5af9f6596bd652b78c12e03671f29 100644 --- a/game2048/grid_2048.py +++ b/game2048/grid_2048.py @@ -204,6 +204,7 @@ def list_move_possible (grid): return(list_final) +<<<<<<< HEAD def random_play(): #on suppose que le jeu par defaut comprend une grille de 4x4 @@ -229,3 +230,5 @@ def random_play(): return() #TEST random_play() +======= +>>>>>>> 15883ac11a1d5e067e173c9ddba3c0e80ca1d0df diff --git a/game2048/run_2048.py b/game2048/run_2048.py new file mode 100644 index 0000000000000000000000000000000000000000..53d5f1417e33c57380af29024bd1130609292095 --- /dev/null +++ b/game2048/run_2048.py @@ -0,0 +1,55 @@ +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 + diff --git a/game2048/textual_2048.py b/game2048/textual_2048.py index a24c190acc254bad5c52182b0c4d481cc3aadd07..0fa73a0ae33b65ca6efb05a43eeb51cf68d8c124 100644 --- a/game2048/textual_2048.py +++ b/game2048/textual_2048.py @@ -1,3 +1,5 @@ +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 def read_player_command():