Class QueenNode
- java.lang.Object
-
- ai.libs.jaicore.search.exampleproblems.nqueens.QueenNode
-
- All Implemented Interfaces:
java.io.Serializable
public class QueenNode extends java.lang.Object implements java.io.Serializable- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description QueenNode(int dimension)Creates a QueenNode with a empty boardQueenNode(int x, int y, int dimension)Creates a QueenNode with one Queen on itQueenNode(QueenNode n, int y)Creates a new QueenNode out of another QueenNode to add a new queen.QueenNode(java.util.List<java.lang.Integer> pos, int y, int dimension)Creates a QueenNode with exiting positions of other queensQueenNode(java.util.List<java.lang.Integer> pos, int x, int y, int dimension)Creates a QueenNode with exiting positions of other queens
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanattack(int i, int j)Checks if a cell is attacked by the queens on the boardjava.lang.StringboardVisualizationAsString()booleanequals(java.lang.Object obj)intgetDimension()intgetNumberOfAttackedCells()Returns the number of attacked cells of the current boardconfigurationintgetNumberOfAttackedCellsInNextRow()Returns the number of attacked cells in the next free row from top down.intgetNumberOfNotAttackedCells()intgetNumberOfQueens()java.util.List<java.lang.Integer>getPositions()inthashCode()java.lang.StringtoString()java.lang.StringtoStringAttack()
-
-
-
Constructor Detail
-
QueenNode
public QueenNode(int dimension)
Creates a QueenNode with a empty board- Parameters:
dimension- The dimension of the board.
-
QueenNode
public QueenNode(int x, int y, int dimension)Creates a QueenNode with one Queen on it- Parameters:
x- The row position of the queen.y- The column position of the queen.dimension- The dimension of the board.
-
QueenNode
public QueenNode(java.util.List<java.lang.Integer> pos, int y, int dimension)Creates a QueenNode with exiting positions of other queens- Parameters:
pos- The positions of the other queens.y- The column position of the newly placed queen.dimension- The dimension of the board.
-
QueenNode
public QueenNode(java.util.List<java.lang.Integer> pos, int x, int y, int dimension)Creates a QueenNode with exiting positions of other queens- Parameters:
pos- The positions of the other queens.x- The row position of the newly placed queen.y- The column position of the newly placed queen.dimension- The dimension of the board.
-
QueenNode
public QueenNode(QueenNode n, int y)
Creates a new QueenNode out of another QueenNode to add a new queen.- Parameters:
n- The old QueenNode.y- The column position of the new queen.
-
-
Method Detail
-
getPositions
public java.util.List<java.lang.Integer> getPositions()
-
getDimension
public int getDimension()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
boardVisualizationAsString
public java.lang.String boardVisualizationAsString()
-
attack
public boolean attack(int i, int j)Checks if a cell is attacked by the queens on the board- Parameters:
i- The row of the cell to be checked.j- The collumn of the cell to be checked.- Returns:
trueif the cell is attacked,falseotherwise.
-
toStringAttack
public java.lang.String toStringAttack()
-
getNumberOfQueens
public int getNumberOfQueens()
-
getNumberOfAttackedCells
public int getNumberOfAttackedCells()
Returns the number of attacked cells of the current boardconfiguration- Returns:
- The number of attacked cells.
-
getNumberOfAttackedCellsInNextRow
public int getNumberOfAttackedCellsInNextRow() throws java.lang.InterruptedExceptionReturns the number of attacked cells in the next free row from top down.- Returns:
- The number of attacked cells in the next row.
- Throws:
java.lang.InterruptedException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getNumberOfNotAttackedCells
public int getNumberOfNotAttackedCells()
-
-