public class Pentomino extends Object
限定符和类型 | 类和说明 |
---|---|
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 |
限定符和类型 | 字段和说明 |
---|---|
protected static int[] |
fourRotations
Are all 4 rotations unique?
|
protected int |
height |
protected static int[] |
oneRotation
Is the piece fixed under rotation?
|
protected List<Pentomino.Piece> |
pieces |
protected static int[] |
twoRotations
Is the piece identical if rotated 180 degrees?
|
protected int |
width |
构造器和说明 |
---|
Pentomino()
Create the object without initialization.
|
Pentomino(int width,
int height)
Create the model for a given pentomino set of pieces and board size.
|
限定符和类型 | 方法和说明 |
---|---|
Pentomino.SolutionCategory |
getCategory(List<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.
|
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(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 String |
stringifySolution(int width,
int height,
List<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 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 String stringifySolution(int width, int height, List<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(List<List<Pentomino.ColumnName>> names)
names
- the solution to checkprotected void initializePieces()
public 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(String[] args)
Copyright © 2009 The Apache Software Foundation