|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectklaus.chess.Position
public class Position
This class stores a position.
Field Summary | |
---|---|
private int |
enPassantPossibility
This variable stores the posiibilities to take en passant (e. p.). |
private boolean |
longCastlingBlack
|
private boolean |
longCastlingWhite
|
private int |
noOfDrawMoves
Number of half-moves since the last time a pawn moved or a piece was taken. |
private int |
noOfMove
Number of moves (not half-moves, notice the dirfference to noOfDrawMoves!!!) |
private char[][] |
pieces
This matrix is used to store the position. |
private boolean |
shortCastlingBlack
|
private boolean |
shortCastlingWhite
|
private boolean |
whitesTurn
Is it white's turn (is this a max position) ??? |
Constructor Summary | |
---|---|
Position()
Creates a default position |
|
Position(String fen)
This creates a new position from a FEN string. |
Method Summary | |
---|---|
Object |
clone()
|
void |
dump(PrintStream ps)
|
boolean |
equals(Object obj)
|
int |
getEnPassantPossibility()
|
int |
getNoOfDrawMoves()
|
int |
getNoOfMove()
|
char |
getPieceAt(int line,
int row)
|
Point[] |
getPositionsOf(char piece)
|
int |
hashCode()
|
boolean |
hasLegalMoves()
check if the player moving next has any possible moves |
boolean |
isCheck()
|
boolean |
isCheckmate()
|
boolean |
isLongCastlingBlack()
|
boolean |
isLongCastlingWhite()
|
boolean |
isShortCastlingBlack()
|
boolean |
isShortCastlingWhite()
|
boolean |
isStalemate()
|
boolean |
isWhitesTurn()
|
void |
setEnPassantPossibility(int enPassantPossibility)
|
void |
setLongCastlingBlack(boolean longCastlingBlack)
|
void |
setLongCastlingWhite(boolean longCastlingWhite)
|
void |
setNoOfDrawMoves(int noOfDrawMoves)
|
void |
setNoOfMove(int noOfMove)
|
void |
setPieceAt(int line,
int row,
char piece)
|
void |
setShortCastlingBlack(boolean shortCastlingBlack)
|
void |
setShortCastlingWhite(boolean shortCastlingWhite)
|
void |
setWhitesTurn(boolean whitesTurn)
|
String |
toFEN()
Generate a FEN (Forsyth-Edwards notation) string from this position. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean whitesTurn
private int noOfDrawMoves
private int noOfMove
private int enPassantPossibility
private boolean longCastlingWhite
private boolean longCastlingBlack
private boolean shortCastlingWhite
private boolean shortCastlingBlack
private char[][] pieces
This matrix is used to store the position. Capital letters are white pieces, other characters are black. The blanks are empty fields.
Each new position is initialized with the default position. I don't know if this is that good, but it makes things more easy.
Constructor Detail |
---|
public Position(String fen)
This creates a new position from a FEN string.
.The most simple way to create a Position is giving a FEN String.
This might look like this:
rbnqknbr/pppppppp/8/8/8/8/PPPPPPPP/RBNQKNBR w - - 0 1
where the rbn... sequence is the board, w means it's white's move (b would
mean black), - is the possibility to castle (in this example nobody can castle,
Kq would mean white can do a short castling and black can do a long castling),
the second - means nobody can take e. p. (else e. g. 4 for e. p. on the E line).
0 is the number of half-moves for the 50 moves rule and 1 is the number of this move (NOT
half-move but move, really!)
fen
- the FEN string used (Forsyth-Edwards notation, see Wikipedia for details)public Position()
Method Detail |
---|
public void setPieceAt(int line, int row, char piece)
public char getPieceAt(int line, int row)
public int getEnPassantPossibility()
public int getNoOfDrawMoves()
public boolean isWhitesTurn()
public void setEnPassantPossibility(int enPassantPossibility)
public void setNoOfDrawMoves(int noOfDrawMoves)
public void setWhitesTurn(boolean whitesTurn)
public Object clone()
clone
in class Object
public boolean isLongCastlingBlack()
public boolean isLongCastlingWhite()
public boolean isShortCastlingBlack()
public boolean isShortCastlingWhite()
public void setLongCastlingBlack(boolean longCastlingBlack)
public void setLongCastlingWhite(boolean longCastlingWhite)
public void setShortCastlingBlack(boolean shortCastlingBlack)
public void setShortCastlingWhite(boolean shortCastlingWhite)
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public boolean hasLegalMoves()
public boolean isCheck()
public boolean isCheckmate()
public boolean isStalemate()
public void dump(PrintStream ps)
public Point[] getPositionsOf(char piece)
public String toFEN()
public int getNoOfMove()
public void setNoOfMove(int noOfMove)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |