En:Libpuzzle
Aus EnigmaWiki
Available languages: Deutsch, English, Русский
With this library, formations from Puzzle-Stones (st-puzzle and st-puzzle2) can be very easily created. Anything is possible with this library, as demonstrated in the level "Puzzle-Demo" in the pack "Development".
Inhaltsverzeichnis |
Examples
A ring from st-puzzle2
matrix={ {1,1,1}, {1,0,1}, {1,1,1}} puzzle(matrix,2,2,"red","no")
|
A ring from Puzzle stones. |
Two Puzzles
matrix={ {1}, {1}, {1}} shuffle_method="random" puzzle(matrix,2,2,"blue") shuffle_method="permutation" puzzle(matrix,4,2,"red")
Pseudo stones in action
matrix={ {1,1,2,1}, {1,0,0,1}, {1,2,1,1}} puzzle(matrix,2,2,"blue","no")
|
This puzzle contains two "pseudo stones". |
Pseudo stones are stones that appear in the Lua code, however will not be drawn in the level. Their only effect consists of the fact that the neighbouring stones have connections to them. In this way you can provide open puzzles.
Reference
Functions
puzzle(original_matrix, xtopleftcorner, ytopleftcorner, puzzle_kind, shuffle)
-
original_matrixis a matrix, which specifies the form of the puzzle. It consists of the values 0, 1, and 2. 0 means: no stone, 1 means stone, 2 means "Pseudo stone": no stone is drawn, but the connection points are set in such a way as if a stone was present.
- With
xtopleftcornerandytopleftcornerthe coordinates of the left upper corner are set.
-
puzzle_kindspecifies which puzzle stones are used to create the puzzle. Allowed values are"blue"for st-puzzle and"red"for st-puzzle2.
-
shuffleindicates whether that puzzle is to be mixed. The possible values are"yes"and"no".
Global variables
shuffle_method
- Possible values: "permutation", "random"
- Default: "permutation"
- Indicates how the puzzle is mixed. "permutation" mixes the puzzle in such a way that it is always solvable. "random" arranges the stones randomly, the puzzle can thereby become unsolvable.
num_perm
- Possible values: natural number
- Default: 10
- Specifies «mit wievielen Zügen das Level gemischt wird», if this happens with permutations. The value indicated here only serves as the basis for the computation of the actual value. The actual number of permutations is a number between
num_perm + 1and2 * num_perm, in our example thus between 11 and 20. For larger puzzles larger values should be selected.
For further information, see comments in the source code.




