NAME

Regexp::Sudoku::Constants - Constants related to Regexp::Sudoku

SYNOPSIS

use Regexp::Sudoku;
use Regexp::Sudoku::Constants qw [:Houses :Constraints :Diagonals];

my $sudoku = Regexp::Sudoku:: -> new -> init (
   clues      => "...",
   diagonals  => $MAIN |. $MINOR,
   houses     => $NRC,
   constaints => $ANTI_KING;

DESCRIPTION

This module exports constants to be used to configure Sudoku variants when using Regexp::Sudoku.

All constants are bitmasks based on vec. Constants are grouped based on Exporter tags; constants exported by the same tag can be mixed using the bitwise operators: |., &. and ~..

There are three tags :Houses, :Constraints and :Diagonals. There is also the tag :All, which can be used to import all the constants.

We'll discuss the constants below, grouped by the tag which imports them. (You can still import each constant individually if you wish to do so).

:Houses

These are used to signal the Sudoku variant uses additional houses. For a description of each additional house, see Regexp::Sudoku.

The constants are used for the houses parameter of the init function of Regexp::Sudoku.

$NRC

This is for NRC Sudokus; also called Windokus or Hyper Sudokus.

$ASTERISK

This is for Asterisk Sudokus.

$GIRANDOLA

This is for Girandola Sudokus.

$CENTER_DOT

This is for center dot Sudokus.

:Constraints

These constants are used for the constraints parameter, and indicate which additionally constraints apply to the Sudoku variant.

$ANTI_KNIGHT

In an Anti-Knight Sudoku, cells which are a Knights move away (as in Chess) must be different.

$ANTI_KING

In an Anti-King Sudoku, cells which touch each other (including cells which only touch by their corners) must be different. These cells corresponds with a Kings move in Chess. This type of Sudoku is also known as a No Touch Sudoku.

:Diagonals

Sudokus with constraints on diagonals (the constraint being that the cells on one or more diagonals should be different) are configured with the diagonals parameter, which takes one or more of the following constants as argument.

Note that there are many possible diagonals. For an N x N Sudoku, there are 4 * N - 2 possible diagonals; for a standard 9 x 9 Sudoku, this means 34 possible diagonals.

$MAIN

This is used if the cells on the main diagonal, running from the top left to the bottom right, are all different. Aliases for $MAIN and $SUB0 and $SUPER0.

$MINOR

This is used if the cells on the minor diagonal, running from the bottom left to the top right, are all different. Aliases for $MINOR and $MINOR_SUB0 and $MINOR_SUPER0.

$SUPER

The super diagonal is the diagonal which runs one cell above (or to the right) of the main diagonal. This is an alias for $SUPER1.

$SUB

The sub diagonal is the diagonal which runs one cell below (or to the left) of the main diagonal. This is an alias for $SUB1.

$MINOR_SUPER

The minor super diagonal is the diagonal which runs one cell above (or to the left) of the minor diagonal. This is an alias for $MINOR_SUPER1.

$MINOR_SUB

The minor sub diagonal is the diagonal which runs one cell below (or to the right) of the main diagonal. This is an alias for $MINOR_SUB1.

$SUPER1 .. $SUPER34

$SUPERM is the diagonal which runs parallel to the main diagonal, M cells above it (or to its right).

Note: If we have an N x N Sudoku, then if M >= N, this diagonal lies completely outside the Sudoku, and won't make any sense. If M == N - 1 the diagonal only contains a single cell (the one in the top right corner), and will not contain any other cells to differ from. For a standard 9 x 9 Sudoku, the diagonals $SUPER7 and $SUPER6 lie completely in the top right box, and hence, don't impose any additional constraints.

$SUB1 .. $SUB34

$SUBM is the diagonal which runs parallel to the main diagonal, M cells below it (or to its left).

The Note above applies here as well.

$MINOR_SUPER1 .. $MINOR_SUPER34

$MINOR_SUPERM is the diagonal which runs parallel to the minor diagonal, M cells above it (or to its left).

The Note above applies here as well.

$MINOR_SUB1 .. $MINOR_SUB34

$MINOR_SUBM is the diagonal which runs parallel to the minor diagonal, M cells below it (or to its right).

The Note above applies here as well.

$CROSS

This is a mask oring $MAIN and $MINOR together ($CROSS = $MAIN |. $MINOR). This is used to indicate cells on both the main and minor diagonals should differ. This is a common Sudoku variant, the X-Sudoku.

$CROSS1 .. $CROSS34

Each of those masks ors together the super, sub, minor super and minor sub diagonals M steps (for $CROSSM) above/below the main and minor diagonals. So, each $CROSSM mask implies uniqueness constraints on four diagonals.

$DOUBLE

This is an alias for $CROSS1, and is used for a Sudoku variant where all the cells on the diagonals just next to the main and minor diagonals should be unique.

$TRIPLE

This mask combines $CROSS and $CROSS1 ($TRIPLE = $CROSS |. $CROSS1). This is used for the variant where the cells on the six largest diagonals (the main and minor diagonals, and the four right next to them) should be unique.

$ARGYLE

This mask combines $CROSS1 and $CROSS4 and is used for the Argyle Sudoku variant. The eight diagonals of this mask form a pattern known as an argyle pattern.

BUGS

There are no known bugs.

SEE ALSO

Regexp::Sudoku.

DEVELOPMENT

The current sources of this module are found on github, git://github.com/Abigail/Regexp-Sudoku.git.

AUTHOR

Abigail, mailto:cpan@abigail.freedom.nl.

COPYRIGHT and LICENSE

Copyright (C) 2021-2022 by Abigail.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

INSTALLATION

To install this module, run, after unpacking the tar-ball, the following commands:

perl Makefile.PL
make
make test
make install