En:Libpuzzle 2
Aus EnigmaWiki
Available languages: Deutsch, English, Русский
With this library, formations of Puzzle stones (st-puzzle and st-puzzle2) and from Bigbricks (st-bigbrick and st-bigbluesand) can be made very easily. Anything is possible with this library, as demonstrated in the level "Puzzle-Demo" in the "Experimental" level pack.
Warning: This Library will be present for the first time in Enigma 1.01 and the current version of the Libpuzzle will be replaced. You can view and download it yourself here: [1]. It also works perfectly with Enigma 1.00.
Inhaltsverzeichnis |
Example
A ring of st-puzzle2
puzzle({"###", "# #", "###"},{2,2},"redpuzzle","none")
|
A ring of puzzle stones. |
Two Puzzles
puzzle({"#","#","#"},{11,20},"bluepuzzle","random") puzzle({"#","#","#"},{8,14},"redpuzzle","permutation")
Pseudo stones in action
puzzle({"##+#", "# #", "#+##"},{26,20},"bluepuzzle","none")
|
This puzzle contains two "pseudo stones" |
Pseudo stones are stones that appear in the Lua code, but which will not be drawn in the level. Their only effect is that the neighboring stones are connected to them. This way, you can provide open puzzles.
Reference
The libpuzzle version 2 offers a function which can draw all the possible different puzzles. It reads as follows:
puzzle(map, corner, type, shuffle_method, num_shuffles)
-
map: An array of strings, which contains the layout of the puzzle. An example could look something like this:
{"###", "# #", "###"}
Each string describes a line of the puzzles. In these strings exactly 4 different characters may occur:
-
(Blank space): no puzzle stone is on this position.
-
#means: puzzle stone.
-
+means: pseudo puzzle stone.
-
*means: hollow puzzle stone. With Bigbricks it is the block without connections.
-
-
corner: An array with exactly 2 elements. These are the X and Y position of the upper left corner of the puzzle. It is not mandatory for a stone to be there.
-
shuffle_method: A string which indicates the method used to mix the parts. The following variants are available:
-
"none": The puzzle stones are not mixed. This results in a solved puzzle. Among others this makes sense with Bigbricks.
-
"random": The puzzle stones are mixed by always exchanging 2 arbitrarily selected stones. The puzzle does not have to be solvable!
-
"permutation": The puzzle is produced with the same rules that apply in the game, from its solved form. The puzzle is always solvable.
-
-
num_shuffles: A number (initial value >= 1) that indicates the number of mixing processes. If this argument is omitted, a random number is accepted. It is computed as follows:
- For
shuffle_method"random"the number will be in the range [number_puzzlestones; number_puzzlestones+math.random(1,number_puzzlestones)].
- For
shuffle_method"permutation"the number will be in the range [number_possible_permutations; number_possible_permutations+ math.random(1,number_puzzlestones)].
- For
One can produce puzzles when using "permutation" as shuffle_method, which are solvable in a maximum of num_shuffles steps.
For each of these values there is a reasonable default value, such that one could theoretically omit all values and a puzzle could be produced by:
puzzle()
For further information and examples take a look at the demo level and the library source code!




