Skip to content

Commit

Permalink
add variant descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Shi committed Sep 26, 2023
1 parent d78618f commit 5dad06f
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 22 deletions.
3 changes: 2 additions & 1 deletion puzzlesolver/puzzles/bishop.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class Bishop(ServerPuzzle):
desc = """Swap the locations of two sets of bishops on opposite ends of a chessboard, without moving them into threatened positions."""
date = "October 30, 2020"
# Chessboard has y rows, 2x columns
variants = {str(i[0]) + "x" + str(i[1]): IndexSolver for i in ((2,5), (2,7), (3,7))}
variants = [str(i[0]) + "x" + str(i[1]) for i in ((2,5), (2,7), (3,7))]
variants_desc = variants
test_variants = {str(i[0]) + "x" + str(i[1]): IndexSolver for i in ((2,5), (2,7))}
startRandomized = False

Expand Down
3 changes: 2 additions & 1 deletion puzzlesolver/puzzles/chairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class Chairs(ServerPuzzle):
desc = """Move all pieces from one side of the board to the other by hopping over adjacent pieces. The end result should be a flipped version of the starting state."""
date = "April 25, 2020"

variants = {"10" : SqliteSolver}
variants = ["10"]
variants_desc = variants
test_variants = variants
startRandomized = False

Expand Down
2 changes: 2 additions & 0 deletions puzzlesolver/puzzles/hanoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class Hanoi(ServerPuzzle):
variants += ["4_1", "4_2", "4_3", "4_4", "4_5", "4_6"]
variants += ["5_1", "5_2", "5_3", "5_4"]

variants_desc = variants

test_variants = ["3_1", "3_2", "3_3"]

startRandomized = False
Expand Down
8 changes: 2 additions & 6 deletions puzzlesolver/puzzles/hopNdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ class HopNDrop(ServerPuzzle):
desc = """Clear all platforms before reaching the goal tile. Don't get stuck or fall!"""
date = "Oct 10, 2020"

variants = {
"map1" : SqliteSolver,
"map2" : SqliteSolver,
"map3" : SqliteSolver,
# "map4" : SqliteSolver
}
variants = ["map1", "map2", "map3"]
variants_desc = variants

test_variants = variants

Expand Down
2 changes: 2 additions & 0 deletions puzzlesolver/puzzles/lightsout.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ class LightsOut(ServerPuzzle):
from ..extern import m4ri_utils
except:
variants = [str(i) for i in range(2, 6)]
variants_desc = ["{}x{}".format(i, i) for i in range(2, 6)]
closed_form_variants = []
else:
variants = [str(i) for i in range(2, 9)]
variants_desc = ["{}x{}".format(i, i) for i in range(2, 9)]
closed_form_variants = ['2', '3', '6', '7', '8']
test_variants = [str(i) for i in range(2, 5)]
startRandomized = True
Expand Down
5 changes: 3 additions & 2 deletions puzzlesolver/puzzles/npuzzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class Npuzzle(ServerPuzzle):
desc = "Shift pieces to get puzzle in ascending order."
date = "April 10, 2020"

variants = {str(i) : IndexSolver for i in range(2, 4)}
test_variants = {"2" : IndexSolver}
variants = [str(i) for i in range(2, 4)]
variants_desc = ["{}-puzzle".format(i * i - 1) for i in range(2, 4)]
test_variants = ["2"]
startRandomized = True

def __init__(self, size=3):
Expand Down
1 change: 1 addition & 0 deletions puzzlesolver/puzzles/nqueens.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class NQueens(ServerPuzzle):
date = 'March 17, 2021'

variants = ['4', '5']
variants_desc = ["4x4", "5x5"]
test_variants = ['4']
startRandomized = True

Expand Down
3 changes: 2 additions & 1 deletion puzzlesolver/puzzles/pegSolitaire.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Peg(ServerPuzzle):
desc = """Jump over a peg with an adjacent peg, removing it from the board. Have one peg remaining by end of the game."""
date = "April 15, 2020"

variants = {"Triangle": SqliteSolver}
variants = ["Triangle"]
variants_desc = variants;
test_variants = variants
startRandomized = False

Expand Down
3 changes: 2 additions & 1 deletion puzzlesolver/puzzles/rubiks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Rubiks(ServerPuzzle):
desc = """Solve the Rubiks cube by getting one color/number on each face using rotations.."""
date = "September 14th, 2020"

variants = {"2x2" : SqliteSolver}
variants = ["2x2"]
variants_desc = variants
startRandomized = True

def __init__(self, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions puzzlesolver/puzzles/rushhour.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class RushHour(ServerPuzzle):
date = "April 25, 2023"

variants = ['basic', 'easy', 'medium', 'hard', 'expert']
variants_desc = variants
# "True" would mean that the game would start at a random solvable board,
# by looking at all solvable hashes -- hence False to ensure we fix a start position
startRandomized = False
Expand Down
3 changes: 2 additions & 1 deletion puzzlesolver/puzzles/topspin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class TopSpin(ServerPuzzle):
name = "Top Spin"
desc = "Move the beads along the track and spin the ones in the spinner until the beads are in order clock-wise, with 1 in the first spot in the spinner."
date = "Nov. 23, 2020"
variants = {'6_2' : SqliteSolver}
variants = ['6_2']
variants_desc = variants
test_variants = variants
startRandomized = True

Expand Down
5 changes: 2 additions & 3 deletions scripts/server/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def test_puzzle(puzzle):
PuzzleManager = PuzzleManagerClass(puzzleList)
app.run()

@app.before_first_request
def server_start():
with app.app_context():
# Check which Puzzles have been solved or not solved
for p_cls in PuzzleManager.getPuzzleClasses():
if p_cls.id not in puzzle_solved_variants:
Expand All @@ -30,4 +29,4 @@ def server_start():
puzzle = p_cls.generateStartPosition(variant)
solver = s_cls(puzzle, dir_path=app.config['DATABASE_DIR'])
if os.path.exists(solver.path) or solver.path == "closed_form":
puzzle_solved_variants[p_cls.id][variant] = solver
puzzle_solved_variants[p_cls.id][variant] = solver
12 changes: 6 additions & 6 deletions scripts/server/src/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ def puzzle(puzzle_id):
"description": puzzlecls.desc,
"date_created": puzzlecls.date,
"variants": [{
"description": variant_id,
"startPosition": getPuzzle(puzzle_id, variant_id, puzzlecls.startRandomized).toString(),
"status": check_available(puzzle_id, variant_id),
"variantId": variant_id,
'autogui_v2_data': get_autoguiV2Data(puzzle_id, variant_id)
} for variant_id in puzzlecls.variants]
"description": puzzlecls.variants_desc[i],
"startPosition": getPuzzle(puzzle_id, puzzlecls.variants[i], puzzlecls.startRandomized).toString(),
"status": check_available(puzzle_id, puzzlecls.variants[i]),
"variantId": puzzlecls.variants[i],
'autogui_v2_data': get_autoguiV2Data(puzzle_id, puzzlecls.variants[i])
} for i in range(len(puzzlecls.variants))]
}
return format_response(response)

Expand Down

0 comments on commit 5dad06f

Please sign in to comment.