NAME
Games::Mahjongg::Solver::deBondt::FFI - Perl/FFI bindings to Mahjongg Solitaire Solver (after peeking) by Michiel de Bondt
SYNOPSIS
my $ffi = Games::Mahjongg::Solver::deBondt::FFI->new();
$ffi->set_g(' 10 14 02 00 ... 08 10 00 35');
$ffi->set_r1(0);
$ffi->set_r2(0);
my ($remain) = $ffi->mjsolve();
DESCRIPTION
The following is from the README of the DLL:
The exported routine of the dll is:
extern "C" __declspec (dllexport)
double mjsolve (char* g, double r1, double r2)
g is the string containing the positions of the (remaining) tiles, as decimal
numbers separated by whitespace, as follows:
<row_1> <column_1> <level_1> <value_1>
<row_2> <column_2> <level_2> <value_2>
:
:
<row_n> <column_n> <level_n> <value_n>
row_i and column_i must be in the interval [00..39]. level_i must be in the
interval [00..09] and value_i must be in the interval [00..99], although you
would need only [01..36] for value_i. Each value must appear an even number of
times and may appear at most four times.
The program searches partial solutions that reduce the number of tiles to
max(r1,r2) at least, and stops searching when a solution is found that reduce
the number of tiles to min(r1,r2). If a solution is found, the best solution
found solution is written to g in the very same format as the input in g, but
the tiles are in the take-away order. The length of g must be 12n at least.
The return value is max(r1,r2) + 2 if no solutions are found, and the number of
tiles remaining for the returned solution otherwise.
BUGS
Exception handling is underdeveloped. Be careful what you can do with $g, it is an opaque string that must match what the library expects to get.
AUTHOR
Binding written by Andreas Koenig <andk@cpan.org>
LICENSE
See the file COPYRIGHT that comes with this package
SEE ALSO
- home page of the library: https://www.math.ru.nl/~debondt/mjsolver.html
- link to the zip file with the library: https://www.math.ru.nl/~debondt/mjsolver_dll.zip
- thanks to Pedro Gimeno Fortea for his article about the solver at http://www.formauri.es/personal/pgimeno/mj-preview/MjSolver.php
- Kmahjongg Homepage: https://apps.kde.org/kmahjongg/