|
/Users/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Games-Sudoku-Component/blib/lib/Games/Sudoku/Component/Controller.pm |
Games::Sudoku::Component::Controller
use Games::Sudoku::Component::Controller;
# Let's create a default 9x9 puzzle.
my $c = Games::Sudoku::Component::Controller->new;
# Solve the (currently blank) puzzle
$c->solve;
# Then, make blanks
$c->make_blank(50);
# Voila! Let's see.
$c->table->as_HTML;
# If all you want is the result, just solve.
$c->solve;
# If you want to do something, then try this loop.
until ($c->status->is_solved) {
# Solve only one step forward (or backward)
$c->next;
# do something, such as updating a session file, printing
# a result, etc.
}
This is a main controller.
Returns the Games::Sudoku::Component::Table manpage, the Games::Sudoku::::Component::Controller::History manpage, the Games::Sudoku::::Component::Controller::Status manpage object respectively.
Creates an object. Options are:
block_width x block_height = size)
Loads and parses puzzle data from file or string. If there is only one argument, it is assumed to be raw puzzle data.
$sudoku->load(<<'EOT'); 4 . . . . 1 2 1 . . 5 . 3 5 1 2 6 . 1 . . . 3 . 6 . . 5 1 2 5 . . . 4 6 EOT
If the argument seems to be a hash, data will be loaded from $hash{filename} (or $hash{file}, for short).
Does what should be done next, i.e. finds a cell that has least value possibilities, decides which value should be set (or should be tried), rewinds a step while rewinding.
Finds a cell that has least value possibilities and decides which value should be set (or should be tried).
Tries to set a value of cell(row, column) to value. Though the value is not allowed in fact, the cell stores the value temporarily.
Finds all the cells that have least value possibilities.
Solves the puzzle that you generated or loaded. You can solve a 'blank' puzzle.
Makes specified number of blanks for the (solved) puzzle randomly. This is useful but the puzzles made through this method may have several solutions.
Rewinds a stacked step. Mainly used when the solver is stuck.
However, this is only useful when possible solutions are few.
When there are too much solutions, rewind_all may be a better
choice.
Rewinds all the steps stacked in the history stack, i.e. restores
the generated or loaded puzzle afresh. Mainly used when the solver
is stuck several times. As next (or find_and_set) sets
values a bit randomly, it tends to be faster to retry from the
start than to rewind again and again.
Clears all (the generated or loaded puzzle, and history stack).
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2006 by Kenichi Ishigaki
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
/Users/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Games-Sudoku-Component/blib/lib/Games/Sudoku/Component/Controller.pm |