Cinnamon  1.1
chess engine
Eval.h
Go to the documentation of this file.
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_KING = 30;
00026     static const int BACKWARD_PAWN = 2;
00027     static const int BISHOP_ON_QUEEN = 2;
00028     static const int BISHOP_TRAPPED = 5;
00029     static const int NO_PAWNS = 15;
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 KNIGHT_TRAPPED = 5;
00040     static const int OPEN_FILE = 10;
00041     static const int OPEN_FILE_Q = 3;
00042     static const int PAWN_7H = 32;
00043     static const int PAWN_CENTER = 15;
00044     static const int PAWN_IN_RACE = 114;
00045     static const int PAWN_ISOLATED = 3;
00046     static const int PAWN_NEAR_KING = 2;
00047     static const int PAWN_BLOCKED = 5;
00048     static const int ROOK_7TH_RANK = 10;
00049     static const int ROOK_BLOCKED = 13;
00050     static const int ROOK_TRAPPED = 6;
00051     static const int UNDEVELOPED = 4;
00052     static const int UNPROTECTED_PAWNS = 5;
00053 #ifdef DEBUG_MODE
00054     int evaluationCount[2];
00055 #endif
00056     void openColumn(int side);
00057     template <int side,_Tstatus status> int evaluatePawn();
00058     template <int side,_Tstatus status> int evaluateBishop(const u64,u64,u64);
00059     template <_Tstatus status> int evaluateQueen(int side,u64 enemies,u64 friends);
00060     template <int side,_Tstatus status> int evaluateKnight(const u64,const u64);
00061     template <int side,_Tstatus status> int evaluateRook(const u64,u64 enemies,u64 friends);
00062     template <_Tstatus status> int evaluateKing(int side,u64 squares);
00063 
00064     template <int side> int lazyEvalSide() {
00065         return _bits::bitCount(chessboard[PAWN_BLACK+side]) * VALUEPAWN + _bits::bitCount(chessboard[ROOK_BLACK+side]) * VALUEROOK + _bits::bitCount(chessboard[BISHOP_BLACK+side]) * VALUEBISHOP
00066                + _bits::bitCount(chessboard[KNIGHT_BLACK+side]) * VALUEKNIGHT + _bits::bitCount(chessboard[QUEEN_BLACK+side]) * VALUEQUEEN;
00067     }
00068 };
00069 #endif
00070 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines