public class IslandMoveListState extends java.lang.Object implements java.util.Iterator<Move>
The Class IslandMoveListState. This class takes in a collection of islands and stores all the moves off each island. If the current island is a 2-island but not at <2,2>-island then calling next() returns a IslandMove which has the moves necessary to move 1 pebble off of the current island to the current target vertex. If the current island is a <2,2>-island next returns TwoTwoIslandMove which which is a move in which the target of the moves are every combination of two adjacent vertices to the current island. More documentation on how these iterators cycle may be found in the documentation of IslandMove and TwoTwoIslandMove.
For the purposes of understanding the reason for this classes existence comes from its use and for clarification it is helpful to think of this use when trying to decipher exactly how this class operates. The use of this class is to maintain the current state (where state means the current and future islands and the current and future moves targets from each of these islands) of the graph. One may think of the state in this algorithm as a options tree, the first layer (choice made) of the tree consists of the islands, then based on the islands we have a set of target moves, some islands have MultiMoves (<2,2>-islands) others have CompositeMoves (2-islands that are not <2,2>-islands), this is what this class stores (actually it stores islands, and the set of moves for the current island as the moves for untested islands are computed only when the fragment reaches them). The entire D2 algorithm recurses making each leaf of the tree this class stores a rootnode of another tree represented by this class structure with a new/altered set of islands. IsSolvableDiam2Iterable runs a depth-first search through this tree until enough moves are made that the graph is solved or there are no more moves to make proving the graph is unsolvable; the way IsSolvableDiam2Iterable stores this information is by storing only the tree fragments (IslandMoveListState) currently in use, each call to next in IsSolvableDiam2Iterable goes deeper into the tree until no more tree fragments (IslandMoveListState) can be made, then the algorithm backtracks until it finds a fragment whose choices have not been used up and progresses down that move tree on successive calls of next.
Constructor and Description |
---|
IslandMoveListState(java.util.Collection<Island> islands)
Instantiates a new island moves based on priority set up by the given priorities.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext() |
Move |
next() |
void |
remove() |
java.lang.String |
toString() |
public IslandMoveListState(java.util.Collection<Island> islands)
islands
- the islandsislandPriority
- the island prioritytwoIslandVertPriority
- the two island vert prioritytwoTwoIslandVertPriority
- the two two island vert priority