From 693a2e6eab280ba68483094a82450b7d8d1481c3 Mon Sep 17 00:00:00 2001 From: Cameron Cheung <42563314+cameroncheung00@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:00:18 +0900 Subject: [PATCH] rushhour autoguiv3 (#135) --- puzzlesolver/puzzles/AutoGUI_Status.py | 4 ++-- puzzlesolver/puzzles/image_autogui_data.py | 7 +++++-- puzzlesolver/puzzles/rushhour.py | 14 +++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/puzzlesolver/puzzles/AutoGUI_Status.py b/puzzlesolver/puzzles/AutoGUI_Status.py index 5b56a90..cd0d0a5 100644 --- a/puzzlesolver/puzzles/AutoGUI_Status.py +++ b/puzzlesolver/puzzles/AutoGUI_Status.py @@ -7,7 +7,7 @@ '4': 'v2' }, 'hanoi': { - None: 'v2', + None: 'v3', '5_1': 'v1', '5_2': 'v1', '5_3': 'v1', @@ -20,7 +20,7 @@ '3_8': 'v1' }, 'rushhour': { - None: 'v2' + None: 'v3' }, 'npuzzle': { None: 'v3' diff --git a/puzzlesolver/puzzles/image_autogui_data.py b/puzzlesolver/puzzles/image_autogui_data.py index 2df59e8..4fa7b51 100644 --- a/puzzlesolver/puzzles/image_autogui_data.py +++ b/puzzlesolver/puzzles/image_autogui_data.py @@ -54,7 +54,8 @@ def get_hanoi(variant_id): "space": [3, 3] if num_poles <= 3 else [4, 4], "background": f"hanoi/{num_poles}_{num_disks}_variant_grid.svg", "entities": pieces, - "arrowWidth": 0.06 if num_poles <= 3 else 0.08 + "arrowWidth": 0.06 if num_poles <= 3 else 0.08, + "animationType": "simpleSlidePlaceRemove" } if variant_id == '3_4': @@ -140,7 +141,9 @@ def get_rushhour(variant_id): "entities": { p: {"image": f"rushhour/{pieces[p]}.svg", "scale": 1} for p in pieces }, - "arrowWidth": 0.1 + "arrowWidth": 0.1, + "sounds": {"x": "general/slide.mp3"}, + "animationType": "multipleSlides" } } } diff --git a/puzzlesolver/puzzles/rushhour.py b/puzzlesolver/puzzles/rushhour.py index 45151ff..3e72950 100644 --- a/puzzlesolver/puzzles/rushhour.py +++ b/puzzlesolver/puzzles/rushhour.py @@ -255,9 +255,9 @@ def generateMoves(self, movetype="all"): if i == 16: # If it's a leftward move from a winning position, # display it as though it is coming from outside the grid - moves.append(f"M_{36}_{i-j}") + moves.append(f"M_{36}_{i-j}_x") else: - moves.append(f"M_{i}_{i-j}") + moves.append(f"M_{i}_{i-j}_x") # Check for rightward moves elif piece in {'R', '2'}: j = 0 @@ -266,27 +266,27 @@ def generateMoves(self, movetype="all"): if i + j == 17: # If it's a rightward move to a winning position, # display it as though it is going outside the grid - moves.append(f"M_{i}_{36}") + moves.append(f"M_{i}_{36}_x") else: - moves.append(f"M_{i}_{i+j}") + moves.append(f"M_{i}_{i+j}_x") # Check for upward moves elif piece == 'T': j = 1 while i - 6 * j >= 0 and self.pos[i - 6*j] == '-': - moves.append(f"M_{i}_{i-6*j}") + moves.append(f"M_{i}_{i-6*j}_x") j += 1 # Check for downward moves elif piece == 'B': j = 1 while i + 6 * j < 36 and self.pos[i + 6*j] == '-': - moves.append(f"M_{i}_{i+6*j}") + moves.append(f"M_{i}_{i+6*j}_x") j += 1 return moves def doMove(self, move, **kwargs): if move not in self.generateMoves(): raise ValueError - _, start, end = move.split("_") + _, start, end, _ = move.split("_") start = int(start) end = int(end) # If the move is to/from a winning position, adjust to the true destination (see generateMoves)