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 boolean
attack(int i, int j)
Checks if a cell is attacked by the queens on the boardjava.lang.String
boardVisualizationAsString()
boolean
equals(java.lang.Object obj)
int
getDimension()
int
getNumberOfAttackedCells()
Returns the number of attacked cells of the current boardconfigurationint
getNumberOfAttackedCellsInNextRow()
Returns the number of attacked cells in the next free row from top down.int
getNumberOfNotAttackedCells()
int
getNumberOfQueens()
java.util.List<java.lang.Integer>
getPositions()
int
hashCode()
java.lang.String
toString()
java.lang.String
toStringAttack()
-
-
-
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:
toString
in 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:
true
if the cell is attacked,false
otherwise.
-
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.InterruptedException
Returns 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getNumberOfNotAttackedCells
public int getNumberOfNotAttackedCells()
-
-