Skip to content

Commit

Permalink
rushhour autoguiv3 (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameroncheung00 authored Sep 18, 2023
1 parent ca0396c commit 693a2e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions puzzlesolver/puzzles/AutoGUI_Status.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'4': 'v2'
},
'hanoi': {
None: 'v2',
None: 'v3',
'5_1': 'v1',
'5_2': 'v1',
'5_3': 'v1',
Expand All @@ -20,7 +20,7 @@
'3_8': 'v1'
},
'rushhour': {
None: 'v2'
None: 'v3'
},
'npuzzle': {
None: 'v3'
Expand Down
7 changes: 5 additions & 2 deletions puzzlesolver/puzzles/image_autogui_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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"
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions puzzlesolver/puzzles/rushhour.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 693a2e6

Please sign in to comment.