/**
 * interface Definitions
 *
 * Contains constants used by multiple classes (like values of pieces)
 *
 * @author: Jonatan Pettersson
 * Created:	2006-12-14
 * Last update: 2006-12-18
 */

public interface Definitions
{
	// Constants for type of move
	public static final int ORDINARY_MOVE = 0;
	public static final int SHORT_CASTLE = 1;
	public static final int LONG_CASTLE = 2;
	public static final int EN_PASSANT = 3;
	public static final int PROMOTION_QUEEN = 4;
	public static final int PROMOTION_ROOK = 5;
	public static final int PROMOTION_BISHOP = 6;
	public static final int PROMOTION_KNIGHT = 7;
	// END special moves constans

	// Side to move
	public static final int WHITE_TO_MOVE = 1;
	public static final int BLACK_TO_MOVE = -1;
	// END side to move

	// Constants for pieces
	public static final int W_KING = 1;
	public static final int W_QUEEN = 2;
	public static final int W_ROOK = 3;
	public static final int W_BISHOP = 4;
	public static final int W_KNIGHT = 5;
	public static final int W_PAWN = 6;

	public static final int B_KING = -1;
	public static final int B_QUEEN = -2;
	public static final int B_ROOK = -3;
	public static final int B_BISHOP = -4;
	public static final int B_KNIGHT = -5;
	public static final int B_PAWN = -6;

	public static final int EMPTY_SQUARE = 0;
	// END piece constants

	// Evaluation constants
	public static final int QUEEN_VALUE = 900;
	public static final int ROOK_VALUE = 500;
	public static final int BISHOP_VALUE = 300;
	public static final int KNIGHT_VALUE = 300;
	public static final int PAWN_VALUE = 100;
	public static final int MATE_VALUE = 100000;
	public static final int DRAW_VALUE = 0;

	// This array is used for fast evaluation of pieces.
	//
	// Take the integer representing the piece + 7 to get the value
	//
	// E.g. Found black queen
	// -2 + 7 = 5 (looking up in the array will give -QUEEN_VALUE = black queen)
	public static final int[] PIECE_VALUE_ARRAY =
	{ 0,			// Not used
	  -PAWN_VALUE,		// Black pawn
	  -KNIGHT_VALUE,	// Black knight
	  -BISHOP_VALUE,	// Black bishop
	  -ROOK_VALUE,		// Black rook
	  -QUEEN_VALUE,		// Black queen
	  0,			// Black king
	  0,			// Empty square
	  0,			// White king
          QUEEN_VALUE,		// White queen
	  ROOK_VALUE,		// White rook
          BISHOP_VALUE,		// White bishop
          KNIGHT_VALUE,		// White knight
          PAWN_VALUE };	  	// White pawn


	// END evaluation constants

	// Constants for castling availability
	public static final int CASTLE_NONE = 0;
	public static final int CASTLE_SHORT = 1;
	public static final int CASTLE_LONG = 2;
	public static final int CASTLE_BOTH = 3;
	// END Castling availability constans

	// Piece deltas
	public static int[] bishop_delta = {-15, -17, 15, 17, 0, 0, 0, 0};
	public static int[] rook_delta = {-1, -16, 1, 16, 0, 0, 0, 0};
	public static int[] queen_delta = {-15, -17, 15, 17, -1, -16, 1, 16};
	public static int[] king_delta = {-15, -17, 15, 17, -1, -16, 1, 16};
	public static int[] knight_delta = {18, 33, 31, 14, -31, -33, -18, -14};
	public static int[] pawn_delta = {16, 32, 17, 15, 0, 0, 0, 0};
	// END piece deltas

	// Attack- and delta-array and constants
	public static int ATTACK_NONE = 0; // Deltas that no piece can move
	public static int ATTACK_KQR = 1; // One square up down left and right
	public static int ATTACK_QR = 2; // More than one square up down left and right
	public static int ATTACK_KQBwP = 3; // One square diagonally up
	public static int ATTACK_KQBbP = 4; // One square diagonally down
	public static int ATTACK_QB = 5; // More than one square diagonally
	public static int ATTACK_N = 6; // Knight moves

	// Formula: attacked_square - attacking_square + 128 = pieces able to attack

	public static final int[] ATTACK_ARRAY =
	{0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,2,0,0,0,     //0-19
  	 0,0,0,5,0,0,5,0,0,0,0,0,2,0,0,0,0,0,5,0,     //20-39
	 0,0,0,5,0,0,0,0,2,0,0,0,0,5,0,0,0,0,0,0,     //40-59
	 5,0,0,0,2,0,0,0,5,0,0,0,0,0,0,0,0,5,0,0,     //60-79
	 2,0,0,5,0,0,0,0,0,0,0,0,0,0,5,6,2,6,5,0,     //80-99
	 0,0,0,0,0,0,0,0,0,0,6,4,1,4,6,0,0,0,0,0,     //100-119
	 0,2,2,2,2,2,2,1,0,1,2,2,2,2,2,2,0,0,0,0,     //120-139
	 0,0,6,3,1,3,6,0,0,0,0,0,0,0,0,0,0,0,5,6,     //140-159
	 2,6,5,0,0,0,0,0,0,0,0,0,0,5,0,0,2,0,0,5,     //160-179
	 0,0,0,0,0,0,0,0,5,0,0,0,2,0,0,0,5,0,0,0,     //180-199
	 0,0,0,5,0,0,0,0,2,0,0,0,0,5,0,0,0,0,5,0,     //200-219
	 0,0,0,0,2,0,0,0,0,0,5,0,0,5,0,0,0,0,0,0,     //220-239
	 2,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0         }; //240-256


	// Same as attack array but gives the delta needed to get to the square

	public static final int[] DELTA_ARRAY =
	{  0,   0,   0,   0,   0,   0,   0,   0,   0, -17,   0,   0,   0,   0,   0,   0, -16,   0,   0,   0,
	   0,   0,   0, -15,   0,   0, -17,   0,   0,   0,   0,   0, -16,   0,   0,   0,   0,   0, -15,   0,
	   0,   0,   0, -17,   0,   0,   0,   0, -16,   0,   0,   0,   0, -15,   0,   0,   0,   0,   0,   0,
	 -17,   0,   0,   0, -16,   0,   0,   0, -15,   0,   0,   0,   0,   0,   0,   0,   0, -17,   0,   0,
	 -16,   0,   0, -15,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, -17, -33, -16, -31, -15,   0,
	   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, -18, -17, -16, -15, -14,   0,   0,   0,   0,   0,
	   0,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   1,   1,   1,   1,   1,   0,   0,   0,   0,
	   0,   0,  14,  15,  16,  17,  18,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  15,  31,
	  16,  33,  17,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  15,   0,   0,  16,   0,   0,  17,
	   0,   0,   0,   0,   0,   0,   0,   0,  15,   0,   0,   0,  16,   0,   0,   0,  17,   0,   0,   0,
	   0,   0,   0,  15,   0,   0,   0,   0,  16,   0,   0,   0,   0,  17,   0,   0,   0,   0,  15,   0,
	   0,   0,   0,   0,  16,   0,   0,   0,   0,   0,  17,   0,   0,  15,   0,   0,   0,   0,   0,   0,
	  16,   0,   0,   0,   0,   0,   0,  17,   0,   0,   0,   0,   0,   0,   0,   0,   0};
	// END Attack- and delta-array and constants


}
