|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectklaus.chess.MoveControl
public class MoveControl
This class is used to check if a move is legal, if a certain square is controlled by white or black, if a king is in check etc.
Constructor Summary | |
---|---|
MoveControl()
|
Method Summary | |
---|---|
static boolean |
accept(Move move,
Position position)
Check if a move is legal in a given position |
private static boolean |
canDoMove(Move move,
Position position)
Checks whether a move is technically possible (meaning regarding the pieces positions, if the way is free etc, ignoring if pieces are in check etc. |
static Point |
findKing(Position position,
boolean white)
Get the king's current position |
static boolean |
squareInCheck(Position pos,
int searchx,
int searchy,
boolean white)
Checks if a certain square is in check |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MoveControl()
Method Detail |
---|
public static boolean accept(Move move, Position position)
move
- the move to be checkedposition
- the position in which the move should be done
private static boolean canDoMove(Move move, Position position)
move
- position
-
public static Point findKing(Position position, boolean white)
position
- a position to searchwhite
- true if the white king is to be searched, false if we need the black king's position
public static boolean squareInCheck(Position pos, int searchx, int searchy, boolean white)
pos
- the positionsearchx
- the square that has to be checked (X coordinate)searchy
- the square that has to be checked (Y coordinate)white
- who shall be in check?
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |