IQSolver.jl Documentation
Introduction
This is a simple package for solving the IQ Puzzler Pro game. It works for all three variantes of the game, including the 3D pyramid!.
It uses a backtracking algorithm to solve the game, recursing on disconnected empty regions on the board. Although it is really cool to see it solving the puzzle, the plotting is too slow, so only the initial and final states are shown.
To see it in action, first install it.
using Pkg
Pkg.add("https://github.com/JoseKling/IQSolver.jl.git")
using IQSolverAnd then simply run this command to solve a specific stage.
solve(80)Basic functions
IQSolver.solve — FunctionCan be called in three different ways:
Board+Pieces -> Use the collection ofPieces to solve theBoard. Any
Pieces in the collection that are already on the Board will be disconsidered.
Board-> Solves theBoardwith the original gamePieces. Again,Pieces
already on the Board are discarded.
- Number -> Solves the corresponding game's stage.
IQSolver.image — FunctionIf a Board is passed, shows the board with empty Cells in black and Cells with pieces with the corresponding color.
If an Int n is passed, shows the configuration of the board in stage n of the original game.
Can also be used to see a specific symmetry of a piece. Simply provide a Piece and an Int n to show the n-th symmetry of the Piece.
Original game
IQSolver.rectangular_board — FunctionCreates an empty rectangular board
Creates a rectangular board filled with the provided Pieces and Regions.
filled is a Dict of Piece => Region.
IQSolver.diagonal_board — FunctionCreates an empty diagonal board (the one on the back of the game)
Builds the game's diagonal 2D board filled with the provided Pieces.
IQSolver.pyramid_board — FunctionCreates a pyramid board
Builds the game's 3D pyramid board board filled with the provided Pieces.
IQSolver.build_stage — FunctionReturns the board with the configuration of each stage in the game
IQSolver.game_pieces2D — ConstantList of all the pieces in the original game. This list is for the 2D variants.
Their names refer to the color. It always start with 'l', 'm', or 'd', for light, middle, and dark. To maintain the standard and to not have any conflicts with any color names, a 'm' is appended even for colors that appear only once, like 'm_orange'.
The individual pieces are also exported.
IQSolver.game_pieces3D — ConstantList of all the pieces of the game, but for the 3D pyramid variant.
The difference between the 3D and 2D Pieces is the number of symmetries.
Data types
IQSolver.Piece — TypeA Piece is the collection of all its symmetries with a correspoding color. A symmetry of a piece is just a Region (a collection of Cells), which will be always in a normal form. This means that a symmetry always contains the Cell $(0, 0)$ (or $(0,0,0)$) and the first index of all the Cells in it is always non-negative.
The implemented methods for this data type are:
n_symmetries-> number of symmetriessize-> how many cells it occupiesiterate-> iterate over its symmetries
IQSolver.Board — TypeA Board is a matrix containing either a Color or nothing. Alias for Matrix{Union{Nothing, Color}}.
Implemented methods for this dasta type:
empty_region-> Returns the collection of emptyCellsimage-> Plots the current state of the board
IQSolver.Region — TypeA region is a collection of Cells.