Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 99 | pmbaty | 1 | /* |
| 2 | Texel - A UCI chess engine. |
||
| 3 | Copyright (C) 2012-2014 Peter Ă–sterlund, peterosterlund2@gmail.com |
||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify |
||
| 6 | it under the terms of the GNU General Public License as published by |
||
| 7 | the Free Software Foundation, either version 3 of the License, or |
||
| 8 | (at your option) any later version. |
||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, |
||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | GNU General Public License for more details. |
||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License |
||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 17 | */ |
||
| 18 | |||
| 19 | /* |
||
| 20 | * endGameEval.hpp |
||
| 21 | * |
||
| 22 | * Created on: Dec 26, 2014 |
||
| 23 | * Author: petero |
||
| 24 | */ |
||
| 25 | |||
| 26 | #ifndef ENDGAMEEVAL_HPP_ |
||
| 27 | #define ENDGAMEEVAL_HPP_ |
||
| 28 | |||
| 29 | #include "util/util.hpp" |
||
| 30 | |||
| 31 | class Position; |
||
| 32 | |||
| 33 | class EndGameEval { |
||
| 34 | public: |
||
| 35 | /** Implements special knowledge for some endgame situations. |
||
| 36 | * If doEval is false the position is not evaluated. Instead 1 is returned if |
||
| 37 | * this function has special knowledge about the current material balance, and 0 |
||
| 38 | * is returned otherwise. */ |
||
| 39 | template <bool doEval> static int endGameEval(const Position& pos, |
||
| 40 | U64 passedPawns, |
||
| 41 | int oldScore); |
||
| 42 | |||
| 43 | /** King evaluation when no pawns left. */ |
||
| 44 | static int mateEval(int k1, int k2); |
||
| 45 | |||
| 46 | static const int winKingTable[64]; |
||
| 47 | |||
| 48 | private: |
||
| 49 | /** Return true if the side with the bishop can not win because the opponent |
||
| 50 | * has a fortress draw. */ |
||
| 51 | template <bool whiteBishop> static bool isBishopPawnDraw(const Position& pos); |
||
| 52 | |||
| 53 | static int kqkpEval(int wKing, int wQueen, int bKing, int bPawn, bool whiteMove, int score); |
||
| 54 | static int kqkrpEval(int wKing, int wQueen, int bKing, int bRook, int bPawn, bool whiteMove, int score); |
||
| 55 | |||
| 56 | static int kpkEval(int wKing, int bKing, int wPawn, bool whiteMove); |
||
| 57 | static bool kpkpEval(int wKing, int bKing, int wPawn, int bPawn, int& score); |
||
| 58 | |||
| 59 | static int krkpEval(int wKing, int bKing, int bPawn, bool whiteMove, int score); |
||
| 60 | static int krpkrEval(int wKing, int bKing, int wPawn, int wRook, int bRook, bool whiteMove); |
||
| 61 | static int krpkrpEval(int wKing, int bKing, int wPawn, int wRook, int bRook, int bPawn, bool whiteMove, int score); |
||
| 62 | |||
| 63 | static int kbnkEval(int wKing, int bKing, bool darkBishop); |
||
| 64 | |||
| 65 | static int kbpkbEval(int wKing, int wBish, int wPawn, int bKing, int bBish, int score); |
||
| 66 | static int kbpknEval(int wKing, int wBish, int wPawn, int bKing, int bKnight, int score); |
||
| 67 | static int knpkbEval(int wKing, int wKnight, int wPawn, int bKing, int bBish, int score, bool wtm); |
||
| 68 | static int knpkEval(int wKing, int wKnight, int wPawn, int bKing, int score, bool wtm); |
||
| 69 | |||
| 70 | static const int distToH1A8[8][8]; |
||
| 71 | static const U8 kpkTable[2*32*64*48/8]; |
||
| 72 | static const U8 krkpTable[2*32*48*8]; |
||
| 73 | static const U64 krpkrTable[2*24*64]; |
||
| 74 | }; |
||
| 75 | |||
| 76 | #endif |