1 /* Copyright (C) 2007-2011 Vincent Ollivier
3 * Purple Haze is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * Purple Haze is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 // Specific bonus and malus
23 static const int CASTLE_BONUS
= 100;
24 static const int BISHOP_PAIR_BONUS
= 40;
25 static const int OPEN_FILE_BONUS
= 30;
26 static const int HALF_OPEN_FILE_BONUS
= 15;
27 static const int REDUNDANCY_MALUS
= -10;
28 static const int BREAKING_CASTLE_MALUS
= -40;
29 static const int NO_PAWNS_MALUS
= -50;
31 static const int PIECE_VALUE
[] = {
37 965, // Queen (Rook + Minor + Pawn + Bishop Pair)
41 // Pieces values adjustments based on the number of pawns
42 static const int PAWNS_ADJUSTEMENT
[][9] = {
43 { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Empty
44 { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Pawns
45 { -30, -24, -18, -12, -6, 0, 6, 12, 18 }, // Knights
46 { -15, -12, -9, -6, -3, 0, 3, 6, 9 }, // Bishops
47 { 60, 48, 36, 24, 12, 0, -12, -24, -36 }, // Rooks
48 { 30, 24, 18, 12, 6, 0, 0, 0, 0 }, // Queens
49 { 0, 0, 0, 0, 0, 0, 0, 0, 0 } // King
52 static const int MULTI_PAWNS_MALUS
[] = { // Pawns on the same file
53 0, -5, -50, -75, -100, -100, -100
56 // Game phase used in tapered evaluation
57 enum Phase
: unsigned char { OPENING
, ENDING
};
59 // Coefficient of each type of piece to determine the game phase
60 static const int PHASE_COEF
[] = { 0, 1, 2, 2, 4, 8, 0 };
63 static const int PHASE_MAX
= 16 * PHASE_COEF
[PAWN
] +
64 4 * PHASE_COEF
[KNIGHT
] +
65 4 * PHASE_COEF
[BISHOP
] +
66 4 * PHASE_COEF
[ROOK
] +
67 2 * PHASE_COEF
[QUEEN
]; // == 64
70 static const int BORDER_MALUS
= -5;
71 static const int CENTER_BONUS
[] = {
72 0, 0, 1, 2, 2, 1, 0, 0
74 static const int PAWN_FILES_VALUES
[] = {
75 -15, -5, 1, 5, 5, 1, -5, -15
77 static const int OPENING_RANKS_BONUS
[][8] = {
78 { 0, 0, 0, 0, 0, 0, 0, 0 }, // Dummy for PieceType EMPTY
79 { 0, -10, -5, 5, 4, 3, 0, 0 }, // Pawns
80 { 0, 1, 2, 4, 4, 2, 0, 0 }, // Knights
81 { 0, 1, 2, 3, 3, 2, 0, 0 }, // Bishops
82 { 30, 0, 0, 0, 0, 0, 0, 0 }, // Rooks
83 { -5, 1, 2, 3, 3, 2, 1, 0 }, // Queens
84 { 0, -15, -40, -40, -40, -40, -40, -40,} // King