Rev 96 | Rev 169 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 96 | Rev 154 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | GNU General Public License for more details. |
15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | */ |
19 | */ |
- | 20 | ||
- | 21 | #include <algorithm> |
|
20 | 22 | ||
21 | #include "types.h" |
23 | #include "types.h" |
- | 24 | ||
- | 25 | Value PieceValue[PHASE_NB][PIECE_NB] = { |
|
- | 26 | { VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg }, |
|
- | 27 | { VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg } |
|
- | 28 | }; |
|
22 | 29 | ||
23 | namespace PSQT { |
30 | namespace PSQT { |
24 | 31 | ||
25 | #define S(mg, eg) make_score(mg, eg) |
32 | #define S(mg, eg) make_score(mg, eg) |
26 | 33 | ||
Line 30... | Line 37... | ||
30 | // second half of the files. |
37 | // second half of the files. |
31 | const Score Bonus[][RANK_NB][int(FILE_NB) / 2] = { |
38 | const Score Bonus[][RANK_NB][int(FILE_NB) / 2] = { |
32 | { }, |
39 | { }, |
33 | { // Pawn |
40 | { // Pawn |
34 | { S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0) }, |
41 | { S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0) }, |
35 | { S(- |
42 | { S(-16, 7), S( 1,-4), S( 7, 8), S( 3,-2) }, |
36 | { S(- |
43 | { S(-23,-4), S( -7,-5), S( 19, 5), S(24, 4) }, |
37 | { S(- |
44 | { S(-22, 3), S(-14, 3), S( 20,-8), S(35,-3) }, |
38 | { S(- |
45 | { S(-11, 8), S( 0, 9), S( 3, 7), S(21,-6) }, |
39 | { S(- |
46 | { S(-11, 8), S(-13,-5), S( -6, 2), S(-2, 4) }, |
40 | { S(- |
47 | { S( -9, 3), S( 15,-9), S( -8, 1), S(-4,18) } |
41 | { S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0) } |
- | |
42 | }, |
48 | }, |
43 | { // Knight |
49 | { // Knight |
44 | { S(-143, -97), S(-96,-82), S(-80,-46), S(-73,-14) }, |
50 | { S(-143, -97), S(-96,-82), S(-80,-46), S(-73,-14) }, |
45 | { S( -83, -69), S(-43,-55), S(-21,-17), S(-10, 9) }, |
51 | { S( -83, -69), S(-43,-55), S(-21,-17), S(-10, 9) }, |
46 | { S( -71, -50), S(-22,-39), S( 0, -8), S( 9, 28) }, |
52 | { S( -71, -50), S(-22,-39), S( 0, -8), S( 9, 28) }, |
Line 92... | Line 98... | ||
92 | } |
98 | } |
93 | }; |
99 | }; |
94 | 100 | ||
95 | #undef S |
101 | #undef S |
96 | 102 | ||
97 | Score psq[ |
103 | Score psq[PIECE_NB][SQUARE_NB]; |
98 | 104 | ||
99 | // init() initializes piece |
105 | // init() initializes piece-square tables: the white halves of the tables are |
100 | // copied from Bonus[] adding the piece value, then the black halves of the |
106 | // copied from Bonus[] adding the piece value, then the black halves of the |
101 | // tables are initialized by flipping and changing the sign of the white scores. |
107 | // tables are initialized by flipping and changing the sign of the white scores. |
102 | void init() { |
108 | void init() { |
103 | 109 | ||
104 | for ( |
110 | for (Piece pc = W_PAWN; pc <= W_KING; ++pc) |
105 | { |
111 | { |
106 | PieceValue[MG][ |
112 | PieceValue[MG][~pc] = PieceValue[MG][pc]; |
107 | PieceValue[EG][ |
113 | PieceValue[EG][~pc] = PieceValue[EG][pc]; |
108 | 114 | ||
109 | Score v = make_score(PieceValue[MG][ |
115 | Score v = make_score(PieceValue[MG][pc], PieceValue[EG][pc]); |
110 | 116 | ||
111 | for (Square s = SQ_A1; s <= SQ_H8; ++s) |
117 | for (Square s = SQ_A1; s <= SQ_H8; ++s) |
112 | { |
118 | { |
113 |
|
119 | File f = std::min(file_of(s), FILE_H - file_of(s)); |
114 | psq[ |
120 | psq[ pc][ s] = v + Bonus[pc][rank_of(s)][f]; |
- | 121 | psq[~pc][~s] = -psq[pc][s]; |
|
115 | } |
122 | } |
116 | } |
123 | } |
117 | } |
124 | } |
118 | 125 | ||
119 | } // namespace PSQT |
126 | } // namespace PSQT |