/* * Gnome Nine Mens Morris * Written by Dirk Farin * * 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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "eval.hh" #include #include #include using namespace std; double CountEval::Eval(const Board& b) { int material = b.n_white - b.n_black; double freedom=0; for (int n=0;n<3*8;n++) { if (b.board[n]==WHITE) freedom += b.Freedom(n); if (b.board[n]==BLACK) freedom -= b.Freedom(n); } double centers=0; centers += b.board[9] + b.board[11] + b.board[13] + b.board[15]; double fullmills=0; bool white_has_mill=false; for (int i=0;i<16;i++) { if (b.board[milltab_short[i][0]]== b.board[milltab_short[i][1]] && b.board[milltab_short[i][1]]== b.board[milltab_short[i][2]]) fullmills += b.board[milltab_short[i][0]]; #if 0 if (b.board[milltab_short[i][0]]==WHITE && b.board[milltab_short[i][1]]==WHITE && b.board[milltab_short[i][2]]==WHITE) white_has_mill = true; #endif } return material + 0.3*freedom + 0.2*centers + 0.4*fullmills; // + (white_has_mill ? 50 : 0); }