Class LightsOutNode
java.lang.Object
|
+--SearchNode
|
+--LightsOutNode
- All Implemented Interfaces:
- java.lang.Cloneable
- public class LightsOutNode
- extends SearchNode
class LightsOutNode
- a puzzle where one seeks to get
all lights out in a grid of lights. Each move turns a light
on/off. However, this also toggles horizontally/vertically
adjacent lights on/off. The puzzle starts in its solved state.
Take a number of random moves to scramble it and see if you can
return it to the solved state!
Method Summary |
java.lang.Object |
clone()
clone - see Main (pp. |
boolean |
equals(java.lang.Object o)
equals - test for equality. |
java.util.Vector |
expand()
expand - return a (possibly empty) Vector of this
node's children. |
boolean |
isGoal()
isGoal - test whether or not the current node is a
goal node. |
static void |
main(java.lang.String[] args)
|
void |
makeMove(int row,
int col)
|
void |
makeRandomMove()
|
void |
makeRandomMoves(int moves)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
LightsOutNode
public LightsOutNode(int size)
isGoal
public boolean isGoal()
- Description copied from class:
SearchNode
isGoal
- test whether or not the current node is a
goal node.
- Overrides:
isGoal
in class SearchNode
- Following copied from class:
SearchNode
- Returns:
- a
boolean
value
expand
public java.util.Vector expand()
- Description copied from class:
SearchNode
expand
- return a (possibly empty) Vector of this
node's children.
- Overrides:
expand
in class SearchNode
- Following copied from class:
SearchNode
- Returns:
- a
Vector
of SearchNodes
makeMove
public void makeMove(int row,
int col)
makeRandomMove
public void makeRandomMove()
makeRandomMoves
public void makeRandomMoves(int moves)
equals
public boolean equals(java.lang.Object o)
- Description copied from class:
SearchNode
equals
- test for equality. This can be
especially useful for repeated state checking in search.
- Overrides:
equals
in class SearchNode
- Following copied from class:
SearchNode
- Parameters:
o
- an Object
value- Returns:
- a
boolean
value
clone
public java.lang.Object clone()
- Description copied from class:
SearchNode
clone
- see Main (pp. 76-80)
- Overrides:
clone
in class SearchNode
- Following copied from class:
SearchNode
- Returns:
- an
Object
value
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
main
public static void main(java.lang.String[] args)