|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrules.Position
public final class Position
Myriad's representation of a particular position. This is a basic class that underlines the properties of a position, such as the availability of castling, 50 move rule count, etc. The piece-centric board representation is used, with coordinates used by the "0x88" algorithm. Note that this is an immutable object. Once an object is created via a constructor it cannot be changed!
Field Summary | |
---|---|
static byte[] |
BLACK_PAWN_ATTACK
The storage for the difference of all pawn capture moves for black. |
static int |
BLACK_WINS
The signal given by the gameResult() method that means black wins. |
static byte[] |
DIAGONALS
The storage for the differences of all diagonal moves. |
static byte |
DOWN_MOVE
The distance between 1 down move. |
static int |
DRAW
The signal given by the gameResult() method that means a draw (or stalemate). |
static byte[] |
HORIZONTALS
The storage for the differences of all horizontal/vertical moves. |
static byte[] |
KNIGHT_MOVES
The storage for the differences of all knight moves. |
static byte |
LEFT_DOWN_MOVE
The distance between 1 diagonal left and down move. |
static byte |
LEFT_MOVE
The distance between 1 left move. |
static byte |
LEFT_UP_MOVE
The distance between 1 diagonal left and up move. |
static int |
NO_RESULT
The signal given by the gameResult() method that means no result has been reached yet. |
static byte[] |
RADIALS
The storage for the differences of all radial moves. |
static byte |
RIGHT_DOWN_MOVE
The distance between 1 diagonal right and down move. |
static byte |
RIGHT_MOVE
The distance between 1 right move. |
static byte |
RIGHT_UP_MOVE
The distance between 1 diagonal right and up move. |
static byte |
UP_MOVE
The distance between 1 up move. |
static byte[] |
WHITE_PAWN_ATTACK
The storage for the difference of all pawn capture moves for white. |
static int |
WHITE_WINS
The signal given by the gameResult() method that means white wins. |
Constructor Summary | |
---|---|
Position()
Default Constructor: Constructs a Position object with the same settings as the initial start-up position. |
|
Position(byte fifty_move,
byte epsq,
boolean[] castling_rights,
boolean whiteturn,
Piece[] w_map,
Piece[] b_map)
Constructor: Constructs a board objects with the following parameters: |
Method Summary | |
---|---|
Move[] |
generateAllMoves()
Generates all the moves possible in this Position object. |
byte |
get50MoveCount()
Returns this position's current 50 move rule counter. |
Piece[] |
getBlackPieces()
Returns an array containing all the black pieces. |
boolean[] |
getCastlingRights()
Gets the castling rights of a board in the order specified in the Constructor. |
byte |
getEnPassantSquare()
Returns the "en passant-able" square using 0x88 cooridinates in this position. |
int |
getResult()
Returns the ending game decision for the positions. |
Piece |
getSquareOccupier(byte square)
Returns the occupier of a specific square, or the null piece if the square is empty. |
Piece |
getSquareOccupier(byte square,
boolean toSearch)
Returns the occupier of a specific square, or the null piece if the square is empty. |
Piece |
getSquareOccupier(byte square,
Piece[] map)
Returns the occupier of a specific square, or the null piece if the square is empty. |
Piece[] |
getWhitePieces()
Returns an array containing all the white pieces. |
boolean |
isInCheck()
Checks if in the current position, whether or not the king is in check. |
boolean |
isWhiteToMove()
Returns whether or not if it is white to play in this position. |
Position |
makeMove(Move m)
Makes a move on the position. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte UP_MOVE
public static final byte DOWN_MOVE
public static final byte LEFT_MOVE
public static final byte RIGHT_MOVE
public static final byte LEFT_UP_MOVE
public static final byte RIGHT_UP_MOVE
public static final byte LEFT_DOWN_MOVE
public static final byte RIGHT_DOWN_MOVE
public static final byte[] KNIGHT_MOVES
public static final byte[] DIAGONALS
public static final byte[] HORIZONTALS
public static final byte[] RADIALS
public static final byte[] WHITE_PAWN_ATTACK
public static final byte[] BLACK_PAWN_ATTACK
public static final int DRAW
public static final int WHITE_WINS
public static final int BLACK_WINS
public static final int NO_RESULT
Constructor Detail |
---|
public Position(byte fifty_move, byte epsq, boolean[] castling_rights, boolean whiteturn, Piece[] w_map, Piece[] b_map)
fifty_move
- The 50 move rule counter.three_fold
- The 3 fold repetition counter.epsq
- The en passant square.castling_rights
- An array storing the castling rights, with index 0 being white
to the kingside, 1 being black to the kingside, 2 being white to the queenside, 3 being
black to the queenside.whiteturn
- If it is currently white to move.w_map
- An array containing all the current white pieces.b_map
- An array containing all the current black pieces.public Position()
Method Detail |
---|
public boolean[] getCastlingRights()
public byte get50MoveCount()
public byte getEnPassantSquare()
public boolean isWhiteToMove()
public Piece[] getWhitePieces()
public Piece[] getBlackPieces()
public Move[] generateAllMoves()
public boolean isInCheck()
public Position makeMove(Move m)
p = p.makeMove(m)
.
m
- The move to make on the current Position.
public int getResult()
public Piece getSquareOccupier(byte square)
public Piece getSquareOccupier(byte square, Piece[] map)
public Piece getSquareOccupier(byte square, boolean toSearch)
square
- The square to search for.toSearch
- The map to search in, true if white, false if black.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |