GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Games::LMSolve::Base(3) User Contributed Perl Documentation Games::LMSolve::Base(3)

Games::LMSolve::Base - base class for puzzle solvers.

version 0.14.2

    package MyPuzzle::Solver;
    use Games::LMSolve::Base;
    @ISA = qw(Games::LMSolve::Base);
    # Override these methods:
    sub input_board { ... }
    sub pack_state { ... }
    sub unpack_state { ... }
    sub display_state { ... }
    sub check_if_final_state { ... }
    sub enumerate_moves { ... }
    sub perform_move { ... }
    # Optionally:
    sub render_move { ... }
    sub check_if_unsolvable { ... }
    package main;
    my $self = MyPuzzle::Solver->new();
    $self->solve_board($filename);

This class implements a generic solver for single player games. In order to use it, one must inherit from it and implement some abstract methods. Afterwards, its interface functions can be invoked to actually solve the game.

new()

The constructor.

Should be inherited to implement the construction.

Actually solve the board based on the arguments in the command line.

This method is responsible to read the "board" (the permanent parameters) of the puzzle and its initial state. It should place the board in the object's keys, and return the initial state. (in unpacked format).

Note that $file_spec can be either a filename (if it's a string) or a reference to a filehandle, or a reference to the text of the board. input_board() should handle all cases.

You can look at the Games::LMSolve::Input module for methods that facilitate inputting a board.

This function accepts a state in unpacked form and should return it in packed format. A state in unpacked form can be any perl scalar (as complex as you like). A state in packed form must be a string.

This function accepts a state in a packed form and should return it in its expanded form.

Accepts a packed state and should return the user-readable string representation of the state.

This function should return 1 if the expanded state $state_vector is a final state, and the game is over.

This function accepts an expanded state and should return an array of moves that can be performed on this state.

This method accepts an expanded state and a move. It should try to peform the move on the state. If it is successful, it should return the new state. Else, it should return undef, to indicate that the move cannot be performed.

This method returns the verdict if $state_vector cannot be solved. This method defaults to returning 0, and it is usually safe to keep it that way.

This function returns the user-readable stringified represtantion of a move.

$self->solve_board($file_spec, %args)

Solves the board specification specified in $file_spec. %args specifies optional arguments. Currently there is one: 'max_iters' that specifies the maximal iterations to run.

Returns whatever run_scan returns.

Continues the current scan. %args may contain the 'max_iters' parameter to specify a maximal iterations limit.

Returns two values. The first is a progress indicator. "solved" means the puzzle was solved. "unsolved" means that all the states were covered and the puzzle was proven to be unsolvable. "interrupted" means that the scan was interrupted in the middle, and could be proved to be either solvable or unsolvable.

The second argument is the final state and is valid only if the progress value is "solved".

Retrieves the current number of iterations.

$self->display_solution($progress_code, $final_state)

If you input this message with the return value of run_scan() you'll get a nice output of the moves to stdout.

Sets the run time states display callback to \&states_display_callback.

This display callback accepts a reference to the solver and also the following arguments in key => value pairs:

"state" - the expanded state. "depth" - the depth of the state. "move" - the move leading to this state from its parent.

Games::LMSolve::Input

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

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.

  • MetaCPAN

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

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

  • RT: CPAN's Bug Tracker

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

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

  • CPANTS

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

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

  • CPAN Testers

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

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

  • 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.

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

  • CPAN Testers Dependencies

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

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

Please report any bugs or feature requests by email to "bug-games-lmsolve at rt.cpan.org", or through the web interface at <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.

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 :)

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

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

Shlomi Fish <shlomif@cpan.org>

Please report any bugs or feature requests on the bugtracker website <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.

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

This is free software, licensed under:

  The MIT (X11) License
2020-10-16 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.