From 6519ca979e0bf295a9482dcadd324307f6f9b32f Mon Sep 17 00:00:00 2001 From: Maurizio Monge Date: Fri, 5 Oct 2007 05:44:38 +0200 Subject: [PATCH] readd old eval. --- evaluate.cpp | 791 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 791 insertions(+) create mode 100644 evaluate.cpp diff --git a/evaluate.cpp b/evaluate.cpp new file mode 100644 index 0000000..205bb1a --- /dev/null +++ b/evaluate.cpp @@ -0,0 +1,791 @@ +/*************************************************************************** + evaluate.cpp - description + ------------------- + begin : Wed Mar 13 2002 + copyright : (C) 2002-2005 by Maurizio Monge + email : monge@linuz.sns.it + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "board.h" +#include "evaluations.h" + +#define ROOK_SEVENTH 19 +#define ROOK_OPEN_FILE 14 +#define ROOK_SEMIOPEN_FILE 9 +#define ISULATED_PAWN -10 +#define DOUBLED_PAWN -8 +#define BACKWARD_PAWN -3 +#define BACKWARD_OPEN_FILE_PAWN -10 +#define COUPLED_PAWN 11 +#define DEFENDED_PAWN 4 +#define PASSED_PAWN 30 +#define BLOCKED_PASSER 12 +#define BLOCKED_BACKWARD -13 +#define BLOCKED_ISULATED -13 +#define PASSED_PIECE 9 +#define ATTACKING_PIECE 7 +#define ATTACKING_PAWN 4 +#define DEFEND_PASSED_PAWN 13 +#define CONNECTED_ROOKS 15 +#define UNDEVELOPED 10 +#define TWO_BISHOPS 13 + +#define VERY_UNSAFE_KING_LATERAL -16 +#define UNSAFE_KING_LATERAL -10 +#define VERY_UNSAFE_KING -23 +#define UNSAFE_KING -14 + +//------------------------------------------------------ + +int coupled_pawns[7] = { 2, 4, 8, 10, 8, 4, 2 }; + +int controlled_bonus[128] = { + 1,1,1,1,1,1,1,1,ENDL, + 1,1,2,2,2,2,1,1,ENDL, + 1,2,3,4,4,3,2,1,ENDL, + 1,2,4,5,5,4,2,1,ENDL, + 1,2,4,5,5,4,2,1,ENDL, + 1,2,3,4,4,3,2,1,ENDL, + 1,1,2,2,2,2,1,1,ENDL, + 1,1,1,1,1,1,1,1,ENDL }; + +int kn_val[128] = { + 285,289,295,300,300,295,289,285,ENDL, + 295,307,307,307,307,307,307,295,ENDL, + 297,307,311,311,311,311,307,297,ENDL, + 299,307,311,312,312,311,307,299,ENDL, + 299,307,311,312,312,311,307,299,ENDL, + 297,307,311,311,311,311,307,297,ENDL, + 295,307,307,307,307,307,307,295,ENDL, + 285,289,295,300,300,295,289,285,ENDL +}; + +int bsh_val[128] = { + 312,298,300,307,307,300,298,312,ENDL, + 311,314,311,311,311,311,314,311,ENDL, + 312,313,315,314,314,315,313,312,ENDL, + 312,313,314,315,315,314,313,312,ENDL, + 312,313,314,315,315,314,313,312,ENDL, + 312,313,315,314,314,315,313,312,ENDL, + 311,314,311,311,311,311,314,311,ENDL, + 312,298,300,307,307,300,298,312,ENDL +}; + +int paw_val[128] = { + 0,0,0,0,0,0,0,0,ENDL, + -3,0,1,-15,-15,1,0,-3,ENDL, + -2,1,3,7,7,3,1,-2,ENDL, + -1,2,9,16,16,9,2,-1,ENDL, + 0,4,11,22,22,11,4,0,ENDL, + 1,5,12,24,24,12,5,1,ENDL, + 2,6,14,26,26,14,6,2,ENDL, + 0,0,0,0,0,0,0,0,ENDL +}; + +int king_safety[128] = { + 0,0,-2,-30,-30,-25,0,0,ENDL, + -1,-4,-20,-100,-100,-20,-4,-1,ENDL, + -300,-300,-300,-300,-300,-300,-300,-300,ENDL, + -300,-300,-300,-300,-300,-300,-300,-300,ENDL, + -300,-300,-300,-300,-300,-300,-300,-300,ENDL, + -300,-300,-300,-300,-300,-300,-300,-300,ENDL, + -1,-4,-20,-100,-100,-20,-4,-1,ENDL, + 0,0,-2,-30,-30,-25,0,0,ENDL +}; + +int endgame_king_val[128] = { + -5,-5,1,2,2,1,-5,-5,ENDL, + -5,1,4,8,8,4,1,-5,ENDL, + 0,4,10,12,12,10,4,0,ENDL, + 1,8,12,14,14,12,8,1,ENDL, + 1,8,12,14,14,12,8,1,ENDL, + 0,4,10,12,12,10,4,0,ENDL, + -5,1,4,8,8,4,1,-5,ENDL, + -5,-5,1,2,2,1,-5,-5,ENDL + }; + +int backward_pawn[8] = { -1, -2, -3, -5, -5, -3, -2, -1 }; +int doubled_pawn[8] = { -6, -5, -4, -2, -2, -4, -5, -6 }; + +int queen_tropism[8] = { 0, 51, 70, 40, 10, 0, 0, 0}; +int rook_tropism[8] = { 0, 3, 2, 1, 0, 0, 0, 0}; +int knight_tropism[8] = { 0, 10, 7, 5, 2, 0, 0, 0}; +int bishop_tropism[8] = { 0, 3, 3, 2, 1, 0, 0, 0}; +int rook_attack_tropism[8] = { 0, 5, 3, 0, 0, 0, 0, 0}; +int knight_attack_tropism[8] = { 0, 5, 3, 0, 0, 0, 0, 0}; +int bishop_attack_tropism[8] = { 0, 5, 3, 0, 0, 0, 0, 0}; + +int piece_val[] = { 500, 325, 1000, 325, 100, 0 }; + +inline int distance(uint8_t a, uint8_t b) +{ + return MAX(ABS(X(a)-X(b)), ABS(Y(a)-Y(b))); +} + +int16_t Board::dummy_evaluate() +{ + int material[2] = { 0, 0 }; + + int p=0; + for(int col=0;col<2;col++) + for(int i=0;i<6;i++) + material[col] += mat_tracking[p++].count * piece_val[i]; + + return material[IS_WHITE(color_to_move)] - + material[IS_WHITE(other_color)]; +} + +#if 0 +//5x5? +int16_t Board::evaluate(uint8_t eng_color, int16_t alpha, int16_t beta) +{ + //return 0; + + int material[2] = { 0, 0 }; + int evaluation[2] = { 0, 0 }; + int king_danger[2] = { 0, 0 }; + int tropism[2] = { 0,0 }; + + int p=0; + for(int col=0;col<2;col++) + for(int i=0;i<6;i++) + material[col] += mat_tracking[p++].count * piece_val[i]; + + //return material[IS_WHITE(color_to_move)] - + // material[IS_WHITE(other_color)]; + + for(int is_white=0;is_white<2;is_white++) + { + uint8_t color = is_white ? WHITE : BLACK; + uint8_t othcol = OTHER_COLOR(color); + uint8_t up = up_dir[is_white]; + uint8_t up_left = up+LEFT; + uint8_t up_right = up+RIGHT; + uint8_t othpawn = PAWN|othcol; + uint8_t mypawn = PAWN|color; + MatTrack *mt = (is_white ? mat_tracking+5 : mat_tracking-1); + + /* Evaluate bishops */ + for(int i=mt[BISHOP].count-1;i>=0;i--) + { + int16_t v = 0; + uint8_t pos = mt[BISHOP].pos[i]; + + for(int i=3;i>=0;i--) + { + register uint8_t currpos = pos; + register uint8_t currinc = bishmoves[i]; + + while(1) + { + currpos += currinc; + + if(data[currpos]) + break; + + uint8_t p1 = currpos + up_left; + uint8_t p2 = currpos + up_right; + if( data[p1]!=othpawn && data[p2]!=othpawn ) + v += controlled_bonus[currpos]; + else + v++; + } + } + + v += 315; + evaluation[is_white] += v; + } + + /* Evaluate rooks */ + for(int i=mt[ROOK].count-1;i>=0;i--) + { + int16_t v = 0; + uint8_t pos = mt[ROOK].pos[i]; + + for(int i=3;i>=0;i--) + { + register uint8_t currpos = pos; + register uint8_t currinc = rookmoves[i]; + + while(1) + { + currpos += currinc; + + if(data[currpos]) + break; + + uint8_t p1 = currpos + up_left; + uint8_t p2 = currpos + up_right; + if( data[p1]!=othpawn && data[p2]!=othpawn ) + v += controlled_bonus[currpos]; + else + v++; + } + } + + v += 500; + evaluation[is_white] += v; + } + + /* Evaluate queen(s) */ + for(int i=mt[QUEEN].count-1;i>=0;i--) + { + int16_t v = 0; + uint8_t pos = mt[QUEEN].pos[i]; + + for(int i=7;i>=0;i--) + { + register uint8_t currpos = pos; + register uint8_t currinc = kingmoves[i]; + + do + { + currpos += currinc; + if(data[currpos]) + break; + + v += controlled_bonus[currpos]; + } + while(!IS_OF_COLOR(data[currpos],othcol)); + } + + v += 960; + evaluation[is_white] += v; + } + + /* Evaluate knights */ + for(int i=mt[KNIGHT].count-1;i>=0;i--) + { + //evaluation[is_white] += 325; + //continue; + + int16_t v = 0; + uint8_t pos = mt[KNIGHT].pos[i]; + KnightMove* hm = &knightmoves[pos]; + + for(int i=hm->numm;i>=0;i--) + { + register uint8_t currpos = hm->jump[i]; + if(IS_OF_COLOR(data[currpos], color)) + continue; + + uint8_t p1 = currpos + up_left; + uint8_t p2 = currpos + up_right; + + if(data[p1]!=othpawn && data[p2]!=othpawn) + { + v += controlled_bonus[currpos]; + + /* give a bonus activity value if attacking a pawn/piece + that is not defended by an enemy pawn */ + if(IS_OF_COLOR(data[currpos], othcol)) + v += PIECE_OF(data[currpos])==PAWN + ? ATTACKING_PAWN : ATTACKING_PIECE; + } + else + v++; + } + + v += 310; + evaluation[is_white] += v; + } + + /* Evaluate pawns */ + for(int i=mt[PAWN].count-1;i>=0;i--) + { + int16_t v = 0; + uint8_t pos = mt[PAWN].pos[i]; + uint8_t x = X(pos); + uint8_t y = is_white ? Y(pos) : 7-Y(pos); + + /* passed pawn */ + v = 100; + if( (x==0||!line_pawns[1-is_white][x-1].count || + line_pawns[1-is_white][x-1].pos[0]>=7-y) && + (x==4||!line_pawns[1-is_white][x+1].count || + line_pawns[1-is_white][x+1].pos[0]>=7-y) && + !line_pawns[1-is_white][x].count) + { + if(COLOR_OF(up_dir[is_white]+pos) == othcol) + v += 100; + else + v += 200; + } + evaluation[is_white] += v; + } + } + + + /*evaluation[0] += (1500*(evaluation[0]-evaluation[1]))/ + (2000+material[0]+material[1]); + evaluation[0] += tropism[0] * 200 / MAX(200 + king_danger[1], 70); + evaluation[1] += tropism[1] * 200 / MAX(200 + king_danger[0], 70);*/ + + int16_t retv = /*5 +*/ evaluation[IS_WHITE(color_to_move)] - + evaluation[IS_WHITE(other_color)]; + return retv; +} +#else +//CHESS +int16_t Board::evaluate(uint8_t eng_color, int16_t alpha, int16_t beta) +{ + int material[2] = { 0, 0 }; + int evaluation[2] = { 0, 0 }; + int king_danger[2] = { 0, 0 }; + int tropism[2] = { 0,0 }; + + int p=0; + for(int col=0;col<2;col++) + for(int i=0;i<6;i++) + material[col] += mat_tracking[p++].count * piece_val[i]; + + /*return material[IS_WHITE(color_to_move)] - + material[IS_WHITE(other_color)];*/ + /*int16_t approx = 5+material[IS_WHITE(color_to_move)] - + material[IS_WHITE(other_color)]; + if(approx > beta+400) + return beta; + if(approx < alpha-400) + return alpha;*/ + + for(int is_white=0;is_white<2;is_white++) + { + uint8_t color = is_white ? WHITE : BLACK; + uint8_t othcol = OTHER_COLOR(color); + uint8_t up = up_dir[is_white]; + uint8_t up_left = up+LEFT; + uint8_t up_right = up+RIGHT; + uint8_t othpawn = PAWN|othcol; + uint8_t mypawn = PAWN|color; + int mt = (is_white ? +5 : -1); + + /* Evaluate bishops */ + for(int i=mat_tracking[BISHOP+mt].count-1;i>=0;i--) + { + int16_t v = 0; + uint8_t pos = mat_tracking[BISHOP+mt].pos[i]; + + for(int i=3;i>=0;i--) + { + register uint8_t currpos = pos; + register uint8_t currinc = bishmoves[i]; + + while(1) + { + currpos += currinc; + + if(OUT_OF_BOARD(currpos)) + break; + + if(data[currpos]) + break; + + uint8_t p1 = currpos + up_left; + uint8_t p2 = currpos + up_right; + if( (OUT_OF_BOARD(p1) || data[p1]!=othpawn) + && (OUT_OF_BOARD(p2) || data[p2]!=othpawn) ) + v += controlled_bonus[currpos]; + else + v++; + } + + if(OUT_OF_BOARD(currpos)) + continue; + + if(COLOR_OF(data[currpos]) == othcol) + { + uint8_t p1 = currpos + up_left; + uint8_t p2 = currpos + up_right; + + /* give a bonus activity value if attacking a pawn/piece + that is not defended by an enemy pawn */ + if( (OUT_OF_BOARD(p1) || data[p1]!=othpawn) + && (OUT_OF_BOARD(p2) || data[p2]!=othpawn) ) + v += PIECE_OF(data[currpos])==PAWN + ? ATTACKING_PAWN : ATTACKING_PIECE; + tropism[is_white] += + bishop_attack_tropism[distance(currpos, king_pos[1-is_white])]; + } + else if(data[currpos] == mypawn) + { + uint8_t x = X(currpos); + uint8_t y = is_white ? Y(currpos) : 7-Y(currpos); + + /* give a bonus for defending passed pawns */ + if( (x==0||!line_pawns[1-is_white][x-1].count || + line_pawns[1-is_white][x-1].pos[0]>=7-y) && + (x==7||!line_pawns[1-is_white][x+1].count || + line_pawns[1-is_white][x+1].pos[0]>=7-y) && + !line_pawns[1-is_white][x].count) + { + v += DEFEND_PASSED_PAWN/2; + } + } + } + if(v=7-y) && + (x==7||!line_pawns[!is_white][x+1].count || + line_pawns[!is_white][x+1].pos[0]>=7-y) ) + v += PASSED_PIECE; + + evaluation[is_white] += v; + } + /* bonus for having both bishops */ + if(mat_tracking[BISHOP+mt].count == 2) + evaluation[is_white] += TWO_BISHOPS; + + /* Evaluate rooks */ + for(int i=mat_tracking[ROOK+mt].count-1;i>=0;i--) + { + int16_t v = 0; + uint8_t pos = mat_tracking[ROOK+mt].pos[i]; + + for(int i=3;i>=0;i--) + { + register uint8_t currpos = pos; + register uint8_t currinc = rookmoves[i]; + + while(1) + { + currpos += currinc; + + if(OUT_OF_BOARD(currpos)) + break; + + if(data[currpos]) + break; + + uint8_t p1 = currpos + up_left; + uint8_t p2 = currpos + up_right; + if( (OUT_OF_BOARD(p1) || data[p1]!=othpawn) + && (OUT_OF_BOARD(p2) || data[p2]!=othpawn) ) + v += controlled_bonus[currpos]; + else + v++; + } + + if(OUT_OF_BOARD(currpos)) + continue; + + if(COLOR_OF(data[currpos]) == othcol) + { + uint8_t p1 = currpos + up_left; + uint8_t p2 = currpos + up_right; + + /* give a bonus activity value if attacking a pawn/piece + that is not defended by an enemy pawn */ + if( (OUT_OF_BOARD(p1) || data[p1]!=othpawn) + && (OUT_OF_BOARD(p2) || data[p2]!=othpawn) ) + v += PIECE_OF(data[currpos])==PAWN + ? ATTACKING_PAWN : ATTACKING_PIECE; + + tropism[is_white] += + rook_attack_tropism[distance(currpos, king_pos[1-is_white])]; + } + else if(data[currpos] == mypawn) + { + uint8_t x = X(currpos); + uint8_t y = is_white ? Y(currpos) : 7-Y(currpos); + + /* give a bonus for defending passed pawns */ + if( (x==0||!line_pawns[1-is_white][x-1].count || + line_pawns[1-is_white][x-1].pos[0]>=7-y) && + (x==7||!line_pawns[1-is_white][x+1].count || + line_pawns[1-is_white][x+1].pos[0]>=7-y) && + !line_pawns[1-is_white][x].count) + { + v += DEFEND_PASSED_PAWN; + } + } + else if((~BISHOP&data[currpos])==(ROOK|color)) + v += CONNECTED_ROOKS; + } + if(v=0;i--) + { + int16_t v = 0; + uint8_t pos = mat_tracking[QUEEN+mt].pos[i]; + + for(int i=7;i>=0;i--) + { + register uint8_t currpos = pos; + register uint8_t currinc = kingmoves[i]; + + do + { + currpos += currinc; + + if(OUT_OF_BOARD(currpos)) + break; + if(data[currpos]) + break; + + v += controlled_bonus[currpos]; + } + while(!IS_OF_COLOR(data[currpos],othcol)); + } + + /* evaluate less queen activity, so ratta won't go + around with the queen all the time */ + v /= 16; + + /* bonus for 7th or open file */ + if(line_pawns[is_white][X(pos)].count == 0) + { + if(line_pawns[1-is_white][X(pos)].count == 0) + v += ROOK_OPEN_FILE/2; + else + v += ROOK_SEMIOPEN_FILE/2; + } + if(Y(pos) == (color==WHITE?6:1)) + v += ROOK_SEVENTH/2; + + v += 960; + tropism[is_white] += queen_tropism[distance(pos, king_pos[1-is_white])]; + + if(color == eng_color) v += 17; + + evaluation[is_white] += v; + } + + /* Evaluate knights */ + for(int i=mat_tracking[KNIGHT+mt].count-1;i>=0;i--) + { + //evaluation[is_white] += 325; + //continue; + + int16_t v = 0; + uint8_t pos = mat_tracking[KNIGHT+mt].pos[i]; + KnightMove* hm = &knightmoves[pos]; + + for(int i=hm->numm;i>=0;i--) + { + register uint8_t currpos = hm->jump[i]; + if(IS_OF_COLOR(data[currpos], color)) + continue; + + uint8_t p1 = currpos + up_left; + uint8_t p2 = currpos + up_right; + + if((OUT_OF_BOARD(p1) || data[p1]!=othpawn) && + (OUT_OF_BOARD(p2) || data[p2]!=othpawn)) + { + v += controlled_bonus[currpos]; + + /* give a bonus activity value if attacking a pawn/piece + that is not defended by an enemy pawn */ + if(IS_OF_COLOR(data[currpos], othcol)) + v += PIECE_OF(data[currpos])==PAWN + ? ATTACKING_PAWN : ATTACKING_PIECE; + } + else + v++; + + if(IS_OF_COLOR(data[currpos], othcol)) + { + tropism[is_white] += + knight_attack_tropism[distance(currpos, king_pos[!is_white])]; + } + else if(data[currpos] == mypawn) + { + uint8_t x = X(currpos); + uint8_t y = is_white ? Y(currpos) : 7-Y(currpos); + + /* give a bonus for defending passed pawns */ + if( (x==0||!line_pawns[1-is_white][x-1].count || + line_pawns[1-is_white][x-1].pos[0]>=7-y) && + (x==7||!line_pawns[1-is_white][x+1].count || + line_pawns[1-is_white][x+1].pos[0]>=7-y) && + !line_pawns[1-is_white][x].count) + { + v += DEFEND_PASSED_PAWN/2; + } + } + } + if(v=7-y) && + (x==7||!line_pawns[!is_white][x+1].count || + line_pawns[!is_white][x+1].pos[0]<=7-y) ) + v += PASSED_PIECE; + + evaluation[is_white] += v; + } + + /* Evaluate pawns */ + for(int i=mat_tracking[PAWN+mt].count-1;i>=0;i--) + { + int16_t v = 0; + uint8_t pos = mat_tracking[PAWN+mt].pos[i]; + uint8_t x = X(pos); + uint8_t y = is_white ? Y(pos) : 7-Y(pos); + + v += (100 + paw_val[POS_XY(x,y)]); + if( (x == 0 || line_pawns[is_white][x-1].count == 0) && + (x == 7 || line_pawns[is_white][x+1].count == 0) ) + { + v += ISULATED_PAWN; + if(COLOR_OF(data[uint8_t(up+pos)]) == othcol) + v += BLOCKED_ISULATED; + } + + if( (x == 0 || line_pawns[is_white][x-1].count == 0 + || line_pawns[is_white][x-1].pos[0] > y) && + (x == 7 || line_pawns[is_white][x+1].count == 0 + || line_pawns[is_white][x+1].pos[0] > y) ) + { + v += backward_pawn[x]; + if(!line_pawns[1-is_white][x].count) + v += BACKWARD_OPEN_FILE_PAWN; + if(COLOR_OF(data[uint8_t(up+pos)]) == othcol + && PIECE_OF(data[uint8_t(up+pos)]) != PAWN) + v += BLOCKED_BACKWARD; + } + + if(x!=0 && data[LEFT_OF(pos)]==data[pos]) + v += MAX(y-2,0)*coupled_pawns[x]; + if(x!=0 && (data[LEFTUP_OF(pos)]==data[pos] || + data[LEFTDOWN_OF(pos)]==data[pos])) + v += DEFENDED_PAWN; + + /* passed pawn */ + if( (x==0||!line_pawns[1-is_white][x-1].count || + line_pawns[1-is_white][x-1].pos[0]>=7-y) && + (x==7||!line_pawns[1-is_white][x+1].count || + line_pawns[1-is_white][x+1].pos[0]>=7-y) && + !line_pawns[1-is_white][x].count) + { + if(COLOR_OF(up_dir[is_white]+pos) == othcol) + v += MAX(y-2,1)*BLOCKED_PASSER; + else + v += MAX(y-2,1)*PASSED_PAWN; + } + + /* doubled pawns */ + if(line_pawns[is_white][x].count > 1) + v += doubled_pawn[x]; + + evaluation[is_white] += v; + } + + /* Evaluate king */ + for(int i=mat_tracking[KING+mt].count-1;i>=0;i--) + { + int16_t v = 0; + uint8_t pos = mat_tracking[KING+mt].pos[i]; + uint8_t x = X(pos); + + if( is_white ? !(castle_passing_mask & 0x30) : + !(castle_passing_mask & 0xc0) ) + { + if(material[!is_white]>=1500) + { + v += king_safety[pos]; + if(x!=0) + { + if((!line_pawns[1-is_white][x-1].count) || + line_pawns[1-is_white][x-1].pos[0]>=3) + v += VERY_UNSAFE_KING_LATERAL; + if(!line_pawns[is_white][x-1].count || + line_pawns[is_white][x-1].pos[0]>=2) + v += UNSAFE_KING_LATERAL; + } + if(x!=7) + { + if((!line_pawns[1-is_white][x+1].count) || + line_pawns[1-is_white][x+1].pos[0]>=3) + v += VERY_UNSAFE_KING_LATERAL; + if(!line_pawns[is_white][x+1].count || + line_pawns[is_white][x+1].pos[0]>=2) + v += UNSAFE_KING_LATERAL; + } + if((!line_pawns[1-is_white][x].count) || + line_pawns[1-is_white][x].pos[0]>=3) + v += VERY_UNSAFE_KING; + if(!line_pawns[is_white][x].count || + line_pawns[is_white][x].pos[0]>=2) + v += UNSAFE_KING; + + v = v * (material[!is_white]-1500)/1500; + if(color == eng_color) + v *= 2; + king_danger[is_white] = v; + } + if(material[!is_white]<2400) + v += endgame_king_val[pos]; + } + else + v -= 65; + + evaluation[is_white] += v; + } + } + + + evaluation[0] += (1500*(evaluation[0]-evaluation[1]))/ + (2000+material[0]+material[1]); + evaluation[0] += tropism[0] * 200 / MAX(200 + king_danger[1], 70); + evaluation[1] += tropism[1] * 200 / MAX(200 + king_danger[0], 70); + + int16_t retv = 5 + evaluation[IS_WHITE(color_to_move)] - + evaluation[IS_WHITE(other_color)]; + + if(mat_tracking[PAWN-1].count + mat_tracking[PAWN+5].count >= 15) + retv += color_to_move == eng_color ? -15 : 15; + else if(mat_tracking[PAWN-1].count + mat_tracking[PAWN+5].count >= 15) + retv += color_to_move == eng_color ? -8 : 8; + + return retv; +} +#endif + -- 2.11.4.GIT