The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Games::Sudoku::PatternSolver::Patterns - for internal use in Games::Sudoku::PatternSolver only

DESCRIPTION

This sub module encompasses procedures that require a certain knowledge of the specific grid size and layout (currently only the standard 9x9).

The solve method does not know of the grid. For its backtracking algorithm it doesn't apply constraint rules to any individual field, but only uses bit vectors of length 81 and tries to combine them in order to arrive at a solution.

This sub module Games::Sudoku::PatternSolver::Patterns

* reads the 46656 different patterns from a binary file, converts them into Bit::Vector objects, which it returns in 2 different data structures: As an array, as well as a hash which holds them ordered in sets by a common field they share. (If the binary file is missing, it will offer to create it from scratch; this lasts around 1 minute.)

* provides an array with 81 hashes representing the fields, initialized with some properties that help to maintain status (value, candidate lists, area covered, ...)

* provides the field indices in sets of groups (rows, columns and boxes). These are needed by the cheat mode, essentially in methods hidden_singles() and naked_singles(), which have to know which fields they must apply the rules to.

SEE ALSO

https://www.sudokuwiki.org/Pattern_Overlay, https://sites.math.washington.edu/~morrow/mcm/team2280.pdf

AUTHOR

Steffen Heinrich

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.