![]() |
Cinnamon
1.0
chess engine
|
00001 #ifndef EVAL_H_ 00002 #define EVAL_H_ 00003 00004 #include "GenMoves.h" 00005 using namespace _board; 00006 using namespace _eval; 00007 00008 class Eval :public GenMoves { 00009 public: 00010 Eval( ); 00011 virtual ~Eval(); 00012 int getScore(const int side, const int alpha, const int beta); 00013 00014 template <int side> int lazyEval() { 00015 return lazyEvalSide<side>() - lazyEvalSide<side^1>(); 00016 } 00017 00018 protected: 00019 #ifdef DEBUG_MODE 00020 int LazyEvalCuts; 00021 #endif 00022 00023 private: 00024 00025 static const int ATTACK_CENTER = 5; 00026 static const int ATTACK_KING = 30; 00027 static const int BACKWARD_PAWN = 2; 00028 static const int BISHOP_ON_QUEEN = 2; 00029 static const int BISHOP_TRAPPED_DIAG = 35; 00030 static const int BONUS2BISHOP = 18; 00031 static const int CONNECTED_ROOKS = 7; 00032 static const int DOUBLED_ISOLATED_PAWNS = 14; 00033 static const int DOUBLED_PAWNS = 5; 00034 static const int END_OPENING = 6; 00035 static const int ENEMIES_PAWNS_ALL = 8; 00036 static const int ENEMY_NEAR_KING = 2; 00037 static const int FRIEND_NEAR_KING = 1; 00038 static const int HALF_OPEN_FILE_Q = 3; 00039 static const int OPEN_FILE = 10; 00040 static const int OPEN_FILE_Q = 3; 00041 static const int PAWN_7H = 32; 00042 static const int PAWN_CENTER = 15; 00043 static const int PAWN_IN_RACE = 114; 00044 static const int PAWN_ISOLATED = 3; 00045 static const int PAWN_NEAR_KING = 2; 00046 static const int ROOK_7TH_RANK = 10; 00047 static const int ROOK_BLOCKED = 13; 00048 static const int SPACE = 1; 00049 static const int UNDEVELOPED = 9; 00050 static const int UNPROTECTED_PAWNS = 5; 00051 #ifdef DEBUG_MODE 00052 int N_EVALUATION[2]; 00053 #endif 00054 void openColumn(int side); 00055 template <int side,_Tstatus status> int evaluatePawn(); 00056 template <int side,_Tstatus status> int evaluateBishop(); 00057 template <_Tstatus status> int evaluateQueen(int side); 00058 template <int side,_Tstatus status> int evaluateKnight(); 00059 template <int side,_Tstatus status> int evaluateRook(); 00060 template <_Tstatus status> int evaluateKing(int side); 00061 00062 template <int side> int lazyEvalSide() { 00063 return _bits::bitCount(chessboard[PAWN_BLACK+side]) * VALUEPAWN + _bits::bitCount(chessboard[ROOK_BLACK+side]) * VALUEROOK + _bits::bitCount(chessboard[BISHOP_BLACK+side]) * VALUEBISHOP 00064 + _bits::bitCount(chessboard[KNIGHT_BLACK+side]) * VALUEKNIGHT + _bits::bitCount(chessboard[QUEEN_BLACK+side]) * VALUEQUEEN; 00065 } 00066 00067 }; 00068 #endif