Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 112 | pmbaty | 1 | /* | 
| 2 |     Protector -- a UCI chess engine | ||
| 3 | |||
| 4 |     Copyright (C) 2009-2010 Raimund Heid (Raimund_Heid@yahoo.com) | ||
| 5 | |||
| 6 |     This program is free software: you can redistribute it and/or modify | ||
| 7 |     it under the terms of the GNU General Public License as published by | ||
| 8 |     the Free Software Foundation, either version 3 of the License, or | ||
| 9 |     (at your option) any later version. | ||
| 10 | |||
| 11 |     This program is distributed in the hope that it will be useful, | ||
| 12 |     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||
| 14 |     GNU General Public License for more details. | ||
| 15 | |||
| 16 |     You should have received a copy of the GNU General Public License | ||
| 17 |     along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef _evaluation_h_ | ||
| 22 | #define _evaluation_h_ | ||
| 23 | |||
| 24 | #include "position.h" | ||
| 25 | #include "bitboard.h" | ||
| 26 | #include "keytable.h" | ||
| 27 | #include "io.h" | ||
| 28 | |||
| 29 | #ifndef NDEBUG | ||
| 30 | extern bool debugEval; | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #define MATERIALINFO_TABLE_SIZE ( 648 * 648 ) | ||
| 34 | extern MaterialInfo materialInfo[MATERIALINFO_TABLE_SIZE]; | ||
| 35 | extern Bitboard companionFiles[_64_]; | ||
| 36 | extern Bitboard troitzkyArea[2]; | ||
| 37 | extern Bitboard pawnOpponents[2][_64_]; | ||
| 38 | extern Bitboard krprkDrawFiles; | ||
| 39 | extern Bitboard A1C1, F1H1, A1B1, G1H1; | ||
| 40 | |||
| 41 | #define VALUE_TEMPO_OPENING 20 | ||
| 42 | #define VALUE_TEMPO_ENDGAME 10 | ||
| 43 | #define MIN_PIECE_WEIGHT_FOR_KING_ATTACK 14 | ||
| 44 | |||
| 45 | void addEvalBonusForColor(EvaluationBase * base, const Color color, | ||
| 46 | const INT32 bonus); | ||
| 47 | void addEvalMalusForColor(EvaluationBase * base, const Color color, | ||
| 48 | const INT32 bonus); | ||
| 49 | Color getWinningColor(const Position * position, const int value); | ||
| 50 | Bitboard getPromotablePawns(const Position * position, const Color color); | ||
| 51 | bool oppositeColoredBishops(const Position * position); | ||
| 52 | int getKnnkpChances(const Position * position, const Color color); | ||
| 53 | bool passiveKingStopsPawn(const Square kingSquare, | ||
| 54 | const Square pawnSquare, const Color pawnColor); | ||
| 55 | int getKrppkrChances(const Position * position, const Color color); | ||
| 56 | int getKrpkrChances(const Position * position, const Color color); | ||
| 57 | int getKqppkqChances(const Position * position, const Color color); | ||
| 58 | int getKqpkqChances(const Position * position, const Color color); | ||
| 59 | int getKpkChances(const Position * position, const Color color); | ||
| 60 | int getKbpkChances(const Position * position, const Color color); | ||
| 61 | int specialPositionChances(const Position * position, | ||
| 62 | const EvaluationBase * base, | ||
| 63 | const SpecialEvalType type, const Color color); | ||
| 64 | int getChances(const Position * position, const EvaluationBase * base, | ||
| 65 | const Color winningColor); | ||
| 66 | bool hasBishopPair(const Position * position, const Color color); | ||
| 67 | int phaseValue(const INT32 value, const Position * position, | ||
| 68 | EvaluationBase * base); | ||
| 69 | INT32 materialBalance(const Position * position); | ||
| 70 | INT32 positionalBalance(const Position * position, EvaluationBase * base); | ||
| 71 | int basicPositionalBalance(Position * position); | ||
| 72 | int getValue(const Position * position, | ||
| 73 |              EvaluationBase * base, | ||
| 74 |              PawnHashInfo * pawnHashtable, | ||
| 75 | KingSafetyHashInfo * kingsafetyHashtable); | ||
| 76 | bool hasWinningPotential(Position * position, Color color); | ||
| 77 | Bitboard calculateKingPawnSafetyHashKey(const Position * position, | ||
| 78 | const Color color); | ||
| 79 | int getPawnWidth(const Position * position, const Color color); | ||
| 80 | int getPassedPawnWidth(const Position * position, | ||
| 81 | const EvaluationBase * base, const Color color); | ||
| 82 | int getMaterialUpPawnCountWeight(int numPawns); | ||
| 83 | |||
| 84 | /** | ||
| 85 |  * Calculate the value of the specified position. | ||
| 86 |  * | ||
| 87 |  * @return the value of the specified position | ||
| 88 |  */ | ||
| 89 | int getValue(const Position * position, | ||
| 90 |              EvaluationBase * base, | ||
| 91 |              PawnHashInfo * pawnHashtable, | ||
| 92 | KingSafetyHashInfo * kingsafetyHashtable); | ||
| 93 | |||
| 94 | /** | ||
| 95 |  * Check if the pawn at the specified square is a passed pawn. | ||
| 96 |  */ | ||
| 97 | bool pawnIsPassed(const Position * position, const Square pawnSquare, | ||
| 98 | const Color pawnColor); | ||
| 99 | |||
| 100 | /** | ||
| 101 |  * Check if a pawn capture creates at least one passer. | ||
| 102 |  */ | ||
| 103 | bool captureCreatesPasser(Position * position, const Square captureSquare, | ||
| 104 | const Piece capturingPiece); | ||
| 105 | |||
| 106 | /** | ||
| 107 |  * Reset the pawn hashtable. | ||
| 108 |  */ | ||
| 109 | void resetPawnHashtable(void); | ||
| 110 | |||
| 111 | /** | ||
| 112 |  * Flip the given position and check if it yields the same result. | ||
| 113 |  * | ||
| 114 |  * @return FALSE if the flipped position yields a diffent result | ||
| 115 |  */ | ||
| 116 | bool flipTest(Position * position, PawnHashInfo * pawnHashtable, | ||
| 117 | KingSafetyHashInfo * kingsafetyHashtable); | ||
| 118 | |||
| 119 | /** | ||
| 120 |  * Initialize this module. | ||
| 121 |  * | ||
| 122 |  * @return 0 if no errors occurred. | ||
| 123 |  */ | ||
| 124 | int initializeModuleEvaluation(void); | ||
| 125 | |||
| 126 | /** | ||
| 127 |  * Test this module. | ||
| 128 |  * | ||
| 129 |  * @return 0 if all tests succeed. | ||
| 130 |  */ | ||
| 131 | int testModuleEvaluation(void); | ||
| 132 | |||
| 133 | #endif |