Skip to content

Commit

Permalink
Variant Descriptions and Various Fixes (#137)
Browse files Browse the repository at this point in the history
* add variant descriptions

* fix imports

* bump up versions of packages with known security vulnerabilities

* add build instructions for Cython-based Lights Out closed-form solver
  • Loading branch information
robertyishi authored Sep 26, 2023
1 parent 195fdde commit cf498e6
Show file tree
Hide file tree
Showing 38 changed files with 138 additions and 120 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ pip install -r requirements.txt
pip install -e .
```

To get optional closed-form solver for Lights Out, run the following commands from the project's root directory:
```
cd puzzlesolver/extern
python setup.py build_ext --inplace
```

Run from the base directory of the repositiory
```
cd puzzlesolver/players
Expand Down
4 changes: 2 additions & 2 deletions puzzlesolver/extern/m4ri/brilliantrussian.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#include <stdlib.h>
#include <string.h>

#include <m4ri/mzd.h>
#include <m4ri/mzp.h>
#include <mzd.h>
#include <mzp.h>

/**
* \brief Constructs all possible \f$2^k\f$ row combinations using the gray
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/debug_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef M4RI_DEBUG_DUMP
#define M4RI_DEBUG_DUMP

#include <m4ri/misc.h>
#include <misc.h>

static inline word calculate_hash(word const *rowptr, wi_t wide) {
word hash = 0;
Expand Down
10 changes: 5 additions & 5 deletions puzzlesolver/extern/m4ri/djb.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "config.h"
#endif

#include <m4ri/djb.h>
#include <m4ri/io.h>
#include <m4ri/misc.h>
#include <m4ri/mzd.h>
#include <m4ri/xor.h>
#include <djb.h>
#include <io.h>
#include <misc.h>
#include <mzd.h>
#include <xor.h>

#ifndef _MSC_VER
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/djb.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef M4RI_DJB_H
#define M4RI_DJB_H

#include <m4ri/mzd.h>
#include <mzd.h>

/**
* \brief Specify source type of addition
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/echelonform.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
********************************************************************/

#include <m4ri/mzd.h>
#include <mzd.h>

/**
* Density at which we switch to PLE decomposition.
Expand Down
4 changes: 2 additions & 2 deletions puzzlesolver/extern/m4ri/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*
********************************************************************/

#include <m4ri/m4ri_config.h>
#include <m4ri/mzd.h>
#include <m4ri_config.h>
#include <mzd.h>

/**
* \brief Print row i of M to an output stream.
Expand Down
30 changes: 15 additions & 15 deletions puzzlesolver/extern/m4ri/m4ri.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@
extern "C" {
#endif

#include <m4ri/brilliantrussian.h>
#include <m4ri/djb.h>
#include <m4ri/echelonform.h>
#include <m4ri/graycode.h>
#include <m4ri/io.h>
#include <m4ri/mp.h>
#include <m4ri/mzd.h>
#include <m4ri/mzp.h>
#include <m4ri/parity.h>
#include <m4ri/ple.h>
#include <m4ri/ple_russian.h>
#include <m4ri/solve.h>
#include <m4ri/strassen.h>
#include <m4ri/triangular.h>
#include <m4ri/triangular_russian.h>
#include <brilliantrussian.h>
#include <djb.h>
#include <echelonform.h>
#include <graycode.h>
#include <io.h>
#include <mp.h>
#include <mzd.h>
#include <mzp.h>
#include <parity.h>
#include <ple.h>
#include <ple_russian.h>
#include <solve.h>
#include <strassen.h>
#include <triangular.h>
#include <triangular_russian.h>

#if defined(__cplusplus) && !defined(_MSC_VER)
}
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
********************************************************************/

#include <m4ri/m4ri_config.h>
#include <m4ri_config.h>

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/mmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
********************************************************************/

#include <m4ri/misc.h>
#include <misc.h>

void *m4ri_mmc_malloc(size_t size);
void m4ri_mmc_free(void *condemned, size_t size);
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/mp.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
********************************************************************/

#include <m4ri/mzd.h>
#include <mzd.h>

/**
* \brief Matrix multiplication via the cubic multiplication algorithm on
Expand Down
4 changes: 2 additions & 2 deletions puzzlesolver/extern/m4ri/mzd.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "config.h"
#endif

#include <m4ri/m4ri_config.h>
#include <m4ri_config.h>

#include <assert.h>
#include <math.h>
Expand All @@ -46,7 +46,7 @@
#include <emmintrin.h>
#endif

#include <m4ri/debug_dump.h>
#include <debug_dump.h>

/**
* \brief Matrix multiplication block-ing dimension.
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/mzp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef M4RI_MZP
#define M4RI_MZP

#include <m4ri/mzd.h>
#include <mzd.h>

/**
* \brief Permutations.
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/parity.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* \author David Harvey
*/

#include <m4ri/misc.h>
#include <misc.h>

/**
* \brief Step for mixing two 64-bit words to compute their parity.
Expand Down
4 changes: 2 additions & 2 deletions puzzlesolver/extern/m4ri/ple.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*
********************************************************************/

#include <m4ri/mzd.h>
#include <m4ri/mzp.h>
#include <mzd.h>
#include <mzp.h>

/**
* Crossover point for PLUQ factorization.
Expand Down
4 changes: 2 additions & 2 deletions puzzlesolver/extern/m4ri/ple_russian.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*
********************************************************************/

#include <m4ri/mzd.h>
#include <m4ri/mzp.h>
#include <mzd.h>
#include <mzp.h>

/**
* \brief PLE Elimination Tables
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/ple_russian_template.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <m4ri/misc.h>
#include <misc.h>

void __M4RI_TEMPLATE_NAME(_mzd_process_rows_ple)(mzd_t *M, rci_t startrow, rci_t stoprow,
rci_t startcol, int const k[N],
Expand Down
4 changes: 2 additions & 2 deletions puzzlesolver/extern/m4ri/solve.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
*
********************************************************************/

#include <m4ri/mzd.h>
#include <m4ri/mzp.h>
#include <mzd.h>
#include <mzp.h>

/**
* \brief Solves A X = B with A and B matrices.
Expand Down
4 changes: 2 additions & 2 deletions puzzlesolver/extern/m4ri/strassen.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
*
********************************************************************/

#include <m4ri/brilliantrussian.h>
#include <m4ri/mzd.h>
#include <brilliantrussian.h>
#include <mzd.h>
#include <math.h>

/**
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/triangular.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
********************************************************************/

#include <m4ri/mzd.h>
#include <mzd.h>

/**
* \brief Solves X U = B with X and B matrices and U upper triangular.
Expand Down
2 changes: 1 addition & 1 deletion puzzlesolver/extern/m4ri/triangular_russian.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
********************************************************************/

#include <m4ri/mzd.h>
#include <mzd.h>

/**
* \brief Solves L X = B with X and B matrices and L lower triangular using Gray code tables.
Expand Down
4 changes: 2 additions & 2 deletions puzzlesolver/extern/m4ri/xor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
*
********************************************************************/

#include <m4ri/m4ri_config.h>
#include <m4ri_config.h>

#if __M4RI_HAVE_SSE2
#include <emmintrin.h>
#endif

#include <m4ri/misc.h>
#include <misc.h>

/**
* Compute c[i] += t1[i] for 0 <= i < wide
Expand Down
4 changes: 2 additions & 2 deletions puzzlesolver/extern/m4ri/xor_template.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <m4ri/m4ri_config.h>
#include <m4ri/misc.h>
#include <m4ri_config.h>
#include <misc.h>

/**
* Compute c[i] += sum(t[j][i], 0 <= j < N) for 0 <= i < wide
Expand Down
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
Loading

0 comments on commit cf498e6

Please sign in to comment.