mit.ai.techniques
Class LinePossibilities
java.lang.Object
|
+--mit.ai.techniques.LinePossibilities
- public class LinePossibilities
- extends java.lang.Object
This class computes all the possible assignments that can satisfy
the constraints for one row or column of the puzzle. It stores all
the possibilities in an internal Vector, each is an array of booleans.
|
Constructor Summary |
LinePossibilities(java.util.Vector blockLengths,
int lineSize)
Given the lengths of the blocks in a puzzle line, generate all
possible locations of the blocks. |
|
Method Summary |
boolean[] |
elementAt(int index)
Retrieve a possibility. |
private boolean[] |
lineVariables(int numBlocks,
int lineSize,
java.util.Vector blockLengths,
int[] blockLocations)
Given a placement of blocks in a line and the sizes of the lines,
generate a boolean array indicating which squares are occupied. |
private void |
locateBlocks(int currentBlock,
int firstAvailableLocation,
int numBlocks,
int lineSize,
java.util.Vector blockLengths,
int[] blockLocations)
Recursively assign blocks to locations. |
int |
size()
How many possibilities exist? |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
possibilities
private java.util.Vector possibilities
LinePossibilities
public LinePossibilities(java.util.Vector blockLengths,
int lineSize)
- Given the lengths of the blocks in a puzzle line, generate all
possible locations of the blocks. We'll create a vector of
possibilities. Each possibility is an array of lineSize
booleans, specifying which locations are occupied.
locateBlocks
private void locateBlocks(int currentBlock,
int firstAvailableLocation,
int numBlocks,
int lineSize,
java.util.Vector blockLengths,
int[] blockLocations)
- Recursively assign blocks to locations. This procedure should be
nested inside the constructor, but we can't do that in Java.
Adds things on to possibilities.
lineVariables
private boolean[] lineVariables(int numBlocks,
int lineSize,
java.util.Vector blockLengths,
int[] blockLocations)
- Given a placement of blocks in a line and the sizes of the lines,
generate a boolean array indicating which squares are occupied.
size
public int size()
- How many possibilities exist?
elementAt
public boolean[] elementAt(int index)
- Retrieve a possibility. Black pixels are true, and white pixels
are false.