public class Pentomino
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static interface |
Pentomino.ColumnName
This interface just is a marker for what types I expect to get back
as column names.
|
protected static class |
Pentomino.Piece
Maintain information about a puzzle piece.
|
static class |
Pentomino.SolutionCategory |
Modifier and Type | Field and Description |
---|---|
protected static int[] |
fourRotations
Are all 4 rotations unique?
|
protected int |
height |
protected static int[] |
oneRotation
Is the piece fixed under rotation?
|
protected java.util.List<Pentomino.Piece> |
pieces |
protected static int[] |
twoRotations
Is the piece identical if rotated 180 degrees?
|
protected int |
width |
Constructor and Description |
---|
Pentomino()
Create the object without initialization.
|
Pentomino(int width,
int height)
Create the model for a given pentomino set of pieces and board size.
|
Modifier and Type | Method and Description |
---|---|
Pentomino.SolutionCategory |
getCategory(java.util.List<java.util.List<Pentomino.ColumnName>> names)
Find whether the solution has the x in the upper left quadrant, the
x-midline, the y-midline or in the center.
|
java.util.List<int[]> |
getSplits(int depth)
Generate a list of prefixes to a given depth
|
protected void |
initializePieces()
Fill in the pieces list.
|
static void |
main(java.lang.String[] args)
Solve the 6x10 pentomino puzzle.
|
void |
setPrinter(DancingLinks.SolutionAcceptor<Pentomino.ColumnName> printer)
Set the printer for the puzzle.
|
int |
solve()
Find all of the solutions to the puzzle.
|
int |
solve(int[] split)
Find all of the solutions that start with the given prefix.
|
static java.lang.String |
stringifySolution(int width,
int height,
java.util.List<java.util.List<Pentomino.ColumnName>> solution)
Convert a solution to the puzzle returned by the model into a string
that represents the placement of the pieces onto the board.
|
protected int width
protected int height
protected java.util.List<Pentomino.Piece> pieces
protected static final int[] oneRotation
protected static final int[] twoRotations
protected static final int[] fourRotations
public Pentomino(int width, int height)
width
- the width of the board in squaresheight
- the height of the board in squarespublic Pentomino()
public static java.lang.String stringifySolution(int width, int height, java.util.List<java.util.List<Pentomino.ColumnName>> solution)
width
- the width of the puzzle boardheight
- the height of the puzzle boardsolution
- the list of column names that were selected in the modelpublic Pentomino.SolutionCategory getCategory(java.util.List<java.util.List<Pentomino.ColumnName>> names)
names
- the solution to checkprotected void initializePieces()
public java.util.List<int[]> getSplits(int depth)
depth
- the length of each prefixpublic int solve(int[] split)
split
- a list of row indexes that should be choosen for each row
in orderpublic int solve()
public void setPrinter(DancingLinks.SolutionAcceptor<Pentomino.ColumnName> printer)
printer
- A call-back object that is given each solution as it is
found.public static void main(java.lang.String[] args)
Copyright © 2009 The Apache Software Foundation