Skip to content

Latest commit

 

History

History
62 lines (42 loc) · 1.82 KB

README.md

File metadata and controls

62 lines (42 loc) · 1.82 KB

Hexagonal Grid Puzzle

The problem requires the player to place all the available pieces inside the grid, without leaving any empty cells. The pieces cannot overlap nor be turned upside-down. Only 2-dimensional rotations are allowed.

A problem usually have at least one of the cells blocked from the start, in order to constrain the solution. In this case, all the 12 available pieces should be used.

Installation

The solver requires numpy, PyYaml and matplotlib. You can install them manually via pip/conda or use the requirements file:

pip install -r requirements.txt

# --- OR ---

conda install --file requirements.txt

Usage

Solving a problem

To solve a problem, use the solve.py script:

python solve.py <problem_config.yaml>

This requires a YAML configuration file describing the porblem. The configuration file should contain the list of blocked cells (as (x, y) coordinate pairs) in the blocked_grid_cells section. Optionally, it can also contain an excluded_pieces section containing a list of piece indexes to exclude from the available pieces for the solution. See examples in the problems folder.

If a solution is found, this is also saved in the configuration file, in the solution section (unless one already exists).

The script also accepts some optional arguments. See the relative help message for details.

Generating a solution image

To generate an image of the solution to a problem, use the make_figure.py script:

python make_figure.py <problem_config.yaml> <image_file_name>

This requires a YAML configuration file with the same format as for the solve.py script. In addition, this also requires the solution section to be present, as generated by the solving script.

The folder solution_imgs already contains the solutions for the 10 standard problems.