#!/usr/bin/perl -w

use strict;

use Games::LMSolve::Registry;

my $r = Games::LMSolve::Registry->new('default_variant' => "minotaur");

$r->main();

__END__

=pod

=head1 NAME

lm-solve - A Computerized Solver for Logic Mazes

=head1 VERSION

version 0.14.0

=head1 SYNOPSIS

B<lm-solve> [options] I<Input File>

=head1 DESCRIPTION

This program is a front end for the LM-Solve Perl modules that
can be used to solve any of the number of Logic Mazes present on the
Logic Mazes site (http://www.logicmazes.com/) and similar sites.

To use this program you should create a text file describing the layout
of the game and your current position (most probably the initial one). Then
invoke B<lm-solve> with its path as input. Alternatively, by specifiying
I<-> as the filename, then B<lm-solve> will read the layout from the standard
input.

One can find an archive containing some written-down layouts for some of the
puzzles on the web on the LM-Solve homepage. The format of the
layouts for the various puzzle types is described below.

=head1 OPTIONS

=over 8

=item B<--help> B<-h> B<-?>

Display a help message on the screen.

=item B<--man>

Invoke the UNIX B<man> command to display the man-page of this program.

=item B<-g> I<variant> | B<--game> I<variant>

Specify the I<variant> to use for the game. Currently available variants are:

B<alice> - Alice Mazes

B<minotaur> - Theseus and the Minotaur Mazes

B<numbers> - Number Mazes

B<plank> - Planks in the Swamp Puzzles

B<tilt_single> - Tilt Mazes with one goal

B<tilt_multi> - Tilt Mazes with multiple goals

B<tilt_rb> - A Red-Blue Tilt Puzzle

=item B<--rle> B<--norle>

This options toggle run-length encoding of the moves displayed on and off.
What it means is that several identical consecutive moves will be displayed
as "B<move> * B<number>".

The default is B<--rle>.

=item B<--output-states> B<--nooutput-states>

B<--output-states> will precede each line with the state of the game up
to the move displayed on it. The default is B<--nooutput-states>

=item B<--method> I<scan>

Specifies the scan to use for solving the game:

B<brfs> - Breadth-First Search. Finds minimal solutions, but possibly
slower than other scans.

B<dfs> - Depth-First Search.

=item B<--rtd> B<--nortd>

B<--rtd> stands for "Run-Time Display". This option will print the states
of the scan that were arrived to, as the scan encounters them. The default is
B<--nortd>.

=back

=head1 Generic Board Format

The format of the board is that of a file containing keys and values on each
line, in the format "key=value". A value can be an integer (e.g: "x=6"),
an (x,y) integral pair (e.g: "dims=(3,6)"), an array of pairs (e.g:
"goals="[(5,6), (3,8), (0, 3)]"), an array of start and end pairs
(e.g: "Planks = [ ((0,2) -> (3,2)) , ((6,5) -> (7,5)) ]")
or a layout specification. The latter begins with "<<EOF" where EOF is a
terminator and extends from the next line down to the first line
containing the terminator.

Whitespace and newlines are generally ignored and the keys are
case-insensitive.

=head1 Alice Mazes Board Format

Dims is an (x,y) value that specifies the dimensions of the board. layout
is the layout of the board. The cells are specified row by row, from top to
bottom and from left to right. Newlines and whitespace between each cell
are ignored as well as lines beginning with a sharp-sign ("#").

Each cell is surrounded by square brackets and contains several flags
separated by commas. The flags are:

=over 8

=item N,S,E,W

Specifies North, South, East and West arrows respectively.

=item NE,NW,SE,SW

Likewise for North-East, North-West, South-East and South-West

=item ADD

Specifies that this cell increases the step by 1.

=item SUB

Specifies that this cell decreases the step by 1.

=item GOAL

The goal cell.

=item START

The start cell.

=item BLANK

A blank cell that may not be stepped on.

=back

Examples can be found in the layouts archive.

=head1 Theseus and the Minotaur Mazes Board Format

The keys and values required for this format are:

=over 8

=item Dims

An (x,y) pair that specifies the (x,y) dimensions of the board.

=item Exit

An (x,y) pair that specifies the (x,y) coordinates of the exit. (starting
at (0,0) for the top-left corner.)

=item Thes

(x,y) - The initial coordinates of Theseus.

=item Mino

(x,y) - The initial coordinates of the Minotaur.

=item layout

This is a layout in the following format: The first line contains width
characters that are either whitespace (" ") or a "-" or a "_" depending
if there is a horizontal wall at that position. The second line contains
width+1 characters that are either whitespace or a "|" sign depending
if there is a vertical wall at that position.

The horizontal-walls and vertical-wall lines intermingle this way until
the bottom line which specifies horizontal walls.

=back

Examples can be found in the layouts archive.

=head1 Number Mazes Board Format

Dims is an (x,y) key that specifies the dimensions of the board. Start
is an (x,y) key that specifies the starting position (starting from (0,0)
at the top-left corner). The key layout is a layout key that contains
the layout of the board.

The layout contains a line for every row, and every cell is represented as
a character. It contains a digit for its number or an asterisk ("*") if it
is the goal cell.

Examples can be found in the layouts archive.

=head1 Single Goal Tilt Mazes

Dims is an (x,y) key that speciifes the dimensions of the board. Start
is an (x,y) pair that specifies the coordinates of the start (starting from
0). Goal is an (x,y) pair that determines the location of the single goal.

layout contains a scheme of horizontal and vertical walls similar to the
Minotaur's mazes.

=head1 Multiple Goals Tilt Mazes

Dims is an (x,y) key that speciifes the dimensions of the board. Start
is an (x,y) pair that specifies the coordinates of the start (starting from
0). Goals is an (x,y) array that determines the locations of the goals.

layout contains a scheme of horizontal and vertical walls similar to the
Minotaur's mazes.

=head1 Red-Blue Tilt Puzzles

Dims is an (x,y) key that specifies the dimensions of the board. Blue_Start
and Red_Start are two (x,y) keys which specify the starting positiones of
the red and blue markers. Red_Goal and Blue_Goal are their respective goals.

layout contains a scheme of horizontal and vertical walls similar to the
Minotaur's mazes.

=head1 Planks in the Swamp Puzzles

Dims is an (x,y) key that specifies the dimensions of the board. Planks is
an array of start and end pairs specifying the start and end coordinates
of the planks. layout is a layout that matches the size specified by Dims
that has an X where a stump is present, G where the goal is
and any other character (preferably a whitespace) where nothing is
present.

The first plank in "Planks" is the active plank.

=head1 SEE ALSO

B<LM-Solve's Homepage>:

L<http://www.shlomifish.org/lm-solve/>

B<The Logic Mazes Homepage>:

L<http://www.logicmazes.com/>

B<Click Mazes>:

L<http://www.gjnem.demon.co.uk/>

=head1 AUTHOR

Shlomi Fish, L<http://www.shlomifish.org/> .

=head1 AUTHOR

Shlomi Fish <shlomif@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2007 by Shlomi Fish.

This is free software, licensed under:

  The MIT (X11) License

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website
L<https://github.com/shlomif/lm-solve-source/issues>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan

=head1 SUPPORT

=head2 Websites

The following websites have more information about this module, and may be of help to you. As always,
in addition to those websites please use your favorite search engine to discover more resources.

=over 4

=item *

MetaCPAN

A modern, open-source CPAN search engine, useful to view POD in HTML format.

L<https://metacpan.org/release/Games-LMSolve>

=item *

Search CPAN

The default CPAN search engine, useful to view POD in HTML format.

L<http://search.cpan.org/dist/Games-LMSolve>

=item *

RT: CPAN's Bug Tracker

The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.

L<https://rt.cpan.org/Public/Dist/Display.html?Name=Games-LMSolve>

=item *

AnnoCPAN

The AnnoCPAN is a website that allows community annotations of Perl module documentation.

L<http://annocpan.org/dist/Games-LMSolve>

=item *

CPAN Ratings

The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.

L<http://cpanratings.perl.org/d/Games-LMSolve>

=item *

CPANTS

The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.

L<http://cpants.cpanauthors.org/dist/Games-LMSolve>

=item *

CPAN Testers

The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.

L<http://www.cpantesters.org/distro/G/Games-LMSolve>

=item *

CPAN Testers Matrix

The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.

L<http://matrix.cpantesters.org/?dist=Games-LMSolve>

=item *

CPAN Testers Dependencies

The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.

L<http://deps.cpantesters.org/?module=Games::LMSolve>

=back

=head2 Bugs / Feature Requests

Please report any bugs or feature requests by email to C<bug-games-lmsolve at rt.cpan.org>, or through
the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=Games-LMSolve>. You will be automatically notified of any
progress on the request by the system.

=head2 Source Code

The code is open to the world, and available for you to hack on. Please feel free to browse it and play
with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
from your repository :)

L<https://github.com/shlomif/lm-solve-source>

  git clone git://github.com/shlomif/lm-solve-source.git

=cut
