From 761743dbc795c2d25db16f48f207e6a39d12dfa7 Mon Sep 17 00:00:00 2001 From: vivien Date: Sat, 7 Mar 2020 21:05:18 +0100 Subject: [PATCH] fix pseudo legal move stuff, another one ... maybe the last TCEC crash. And re-tune everything --- Add-On/texelTuning.cc | 596 +++++++++++++++++++++--------------------- minic.cc | 133 +++++----- 2 files changed, 369 insertions(+), 360 deletions(-) diff --git a/Add-On/texelTuning.cc b/Add-On/texelTuning.cc index d5b2a0eb..653bb4a1 100644 --- a/Add-On/texelTuning.cc +++ b/Add-On/texelTuning.cc @@ -69,7 +69,7 @@ double E(const std::vector &data, size_t miniBatchSize) { for(auto k = begin; k != end; ++k) { e += std::pow((data[k].result+1)*0.5 - Sigmoid(data[k].p),2); } - acc.store( acc + e ); + acc.store( acc.load() + e ); }; std::vector threads(DynamicConfig::threads); @@ -147,14 +147,14 @@ std::vector ComputeGradient(std::vector > & x0, st return g; } -std::vector > TexelOptimizeGD(const std::vector >& initialGuess, std::vector &data, const size_t batchSize) { +std::vector > TexelOptimizeGD(const std::vector >& initialGuess, std::vector &data, const size_t batchSize, const int loops = 100) { DynamicConfig::disableTT = true; std::ofstream str("tuning.csv"); int it = 0; Randomize(data, batchSize); std::vector > bestParam = initialGuess; std::vector previousUpdate(batchSize,0); - while (it < 100000 ) { + while (it < loops ) { std::vector g = ComputeGradient(bestParam, data, batchSize, false); double gmax = -1; for (size_t k = 0; k < bestParam.size(); ++k) { @@ -274,8 +274,8 @@ void TexelTuning(const std::string & filename) { ExtendedPosition::readEPDFile(filename,positions); for(size_t k = 0 ; k < positions.size() ; ++k){ ExtendedPosition * p = new ExtendedPosition(positions[k],false); - data.push_back({p, getResult(p->_extendedParams["c9"][0])}); - //data.push_back({p, getResult2(p->_extendedParams["c2"][0])}); + data.push_back({p, getResult(p->_extendedParams["c9"][0])}); // zurichess + //data.push_back({p, getResult2(p->_extendedParams["c2"][0])}); // lichess-quiet // +1 white win, -1 black wins, 0 draw if (k % 50000 == 0) Logging::LogIt(Logging::logInfo) << k << " position read"; } @@ -288,347 +288,357 @@ void TexelTuning(const std::string & filename) { //for(int k=0 ; k<13; ++k){Values[k] = 450; ValuesEG[k] = 450;} - std::vector > guess; - - /* - guess.push_back(Texel::TexelParam(Values[P_wp+PieceShift], 20, 200, "pawn", [](const ScoreType& s){Values[P_bp+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - guess.push_back(Texel::TexelParam(Values[P_wn+PieceShift], 150, 600, "knight", [](const ScoreType& s){Values[P_bn+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - guess.push_back(Texel::TexelParam(Values[P_wb+PieceShift], 150, 600, "bishop", [](const ScoreType& s){Values[P_bb+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - guess.push_back(Texel::TexelParam(Values[P_wr+PieceShift], 200, 800, "rook", [](const ScoreType& s){Values[P_br+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - guess.push_back(Texel::TexelParam(Values[P_wq+PieceShift], 600, 1800, "queen", [](const ScoreType& s){Values[P_bq+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - guess.push_back(Texel::TexelParam(ValuesEG[P_wp+PieceShift], 50, 200, "EGpawn", [](const ScoreType& s){ValuesEG[P_bp+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - guess.push_back(Texel::TexelParam(ValuesEG[P_wn+PieceShift], 150, 600, "EGknight", [](const ScoreType& s){ValuesEG[P_bn+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - guess.push_back(Texel::TexelParam(ValuesEG[P_wb+PieceShift], 150, 600, "EGbishop", [](const ScoreType& s){ValuesEG[P_bb+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - guess.push_back(Texel::TexelParam(ValuesEG[P_wr+PieceShift], 200, 800, "EGrook", [](const ScoreType& s){ValuesEG[P_br+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - guess.push_back(Texel::TexelParam(ValuesEG[P_wq+PieceShift], 600, 1800, "EGqueen", [](const ScoreType& s){ValuesEG[P_bq+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); - */ - - /* - guess.push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[0], -3000, 3000, "cp")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[1], -3000, 3000, "cn")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[2], -3000, 3000, "cb")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[3], -3000, 3000, "cr")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[4], -3000, 3000, "cq")); - //guess.push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[5], -3000, 3000, "ck")); - */ - - /* - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[0][MG], -150, 300, "aqp")); - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[1][MG], -150, 300, "aqn")); - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[2][MG], -150, 300, "aqb")); - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[3][MG], -150, 300, "aqr")); - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[4][MG], -150, 300, "aqq")); - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[0][EG], -150, 300, "aqpeg")); - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[1][EG], -150, 300, "aqneg")); - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[2][EG], -150, 300, "aqbeg")); - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[3][EG], -150, 300, "aqreg")); - guess.push_back(Texel::TexelParam(EvalConfig::attQueenMalus[4][EG], -150, 300, "aqqeg")); - */ - - /* - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][0], -3000, 3000, "ap")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][1], -3000, 3000, "an")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][2], -3000, 3000, "ab")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][3], -3000, 3000, "ar")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][4], -3000, 3000, "aq")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][5], -3000, 3000, "ak")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][0], -3000, 3000, "dp")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][1], -3000, 3000, "dn")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][2], -3000, 3000, "db")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][3], -3000, 3000, "dr")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][4], -3000, 3000, "dq")); - //guess.push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][5], -3000, 3000, "dk")); + std::map > > guess; + + guess["piecesValue"].push_back(Texel::TexelParam(Values[P_wp+PieceShift], 20, 200, "pawn", [](const ScoreType& s){Values[P_bp+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + guess["piecesValue"].push_back(Texel::TexelParam(Values[P_wn+PieceShift], 150, 600, "knight", [](const ScoreType& s){Values[P_bn+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + guess["piecesValue"].push_back(Texel::TexelParam(Values[P_wb+PieceShift], 150, 600, "bishop", [](const ScoreType& s){Values[P_bb+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + guess["piecesValue"].push_back(Texel::TexelParam(Values[P_wr+PieceShift], 200, 800, "rook", [](const ScoreType& s){Values[P_br+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + guess["piecesValue"].push_back(Texel::TexelParam(Values[P_wq+PieceShift], 600, 1800, "queen", [](const ScoreType& s){Values[P_bq+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + guess["piecesValue"].push_back(Texel::TexelParam(ValuesEG[P_wp+PieceShift], 50, 200, "EGpawn", [](const ScoreType& s){ValuesEG[P_bp+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + guess["piecesValue"].push_back(Texel::TexelParam(ValuesEG[P_wn+PieceShift], 150, 600, "EGknight", [](const ScoreType& s){ValuesEG[P_bn+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + guess["piecesValue"].push_back(Texel::TexelParam(ValuesEG[P_wb+PieceShift], 150, 600, "EGbishop", [](const ScoreType& s){ValuesEG[P_bb+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + guess["piecesValue"].push_back(Texel::TexelParam(ValuesEG[P_wr+PieceShift], 200, 800, "EGrook", [](const ScoreType& s){ValuesEG[P_br+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + guess["piecesValue"].push_back(Texel::TexelParam(ValuesEG[P_wq+PieceShift], 600, 1800, "EGqueen", [](const ScoreType& s){ValuesEG[P_bq+PieceShift] = -s; MaterialHash::InitMaterialScore(false);})); + + guess["safeChecks"].push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[0], -3000, 3000, "cp")); + guess["safeChecks"].push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[1], -3000, 3000, "cn")); + guess["safeChecks"].push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[2], -3000, 3000, "cb")); + guess["safeChecks"].push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[3], -3000, 3000, "cr")); + guess["safeChecks"].push_back(Texel::TexelParam(EvalConfig::kingAttSafeCheck[4], -3000, 3000, "cq")); + + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][0], -3000, 3000, "ap")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][1], -3000, 3000, "an")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][2], -3000, 3000, "ab")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][3], -3000, 3000, "ar")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][4], -3000, 3000, "aq")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[0][5], -3000, 3000, "ak")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][0], -3000, 3000, "dp")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][1], -3000, 3000, "dn")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][2], -3000, 3000, "db")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][3], -3000, 3000, "dr")); + guess["attDefKing"].push_back(Texel::TexelParam(EvalConfig::kingAttWeight[1][4], -3000, 3000, "dq")); + + guess["attOpenFile"].push_back(Texel::TexelParam(EvalConfig::kingAttOpenfile , -400, 800, "kingAttOpenfile")); + guess["attOpenFile"].push_back(Texel::TexelParam(EvalConfig::kingAttSemiOpenfileOur , -400, 800, "kingAttSemiOpenfileOur")); + guess["attOpenFile"].push_back(Texel::TexelParam(EvalConfig::kingAttSemiOpenfileOpp , -400, 800, "kingAttSemiOpenfileOpp")); + + guess["attFunction"].push_back(Texel::TexelParam(EvalConfig::kingAttMax , -400, 800, "kattmax",[](const ScoreType & ){EvalConfig::initEval();})); + guess["attFunction"].push_back(Texel::TexelParam(EvalConfig::kingAttScale , -400, 800, "kattscale",[](const ScoreType & ){EvalConfig::initEval();})); + guess["attFunction"].push_back(Texel::TexelParam(EvalConfig::kingAttTrans , -400, 800, "kingAttTrans",[](const ScoreType & ){EvalConfig::initEval();})); + guess["attFunction"].push_back(Texel::TexelParam(EvalConfig::kingAttOffset , -400, 800, "kingAttOffset",[](const ScoreType & ){EvalConfig::initEval();})); + + guess["pawnMob"].push_back(Texel::TexelParam(EvalConfig::pawnMobility[MG] , -500, 500,"pmobility0")); + guess["pawnMob"].push_back(Texel::TexelParam(EvalConfig::pawnMobility[EG] , -500, 500,"pmobility1")); - - guess.push_back(Texel::TexelParam(EvalConfig::kingAttOpenfile , -400, 800, "kingAttOpenfile")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttSemiOpenfileOur , -400, 800, "kingAttSemiOpenfileOur")); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttSemiOpenfileOpp , -400, 800, "kingAttSemiOpenfileOpp")); - - guess.push_back(Texel::TexelParam(EvalConfig::kingAttMax , -400, 800, "kattmax",[](const ScoreType & ){initEval();})); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttScale , -400, 800, "kattscale",[](const ScoreType & ){initEval();})); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttTrans , -400, 800, "kingAttTrans",[](const ScoreType & ){initEval();})); - guess.push_back(Texel::TexelParam(EvalConfig::kingAttOffset , -400, 800, "kingAttOffset",[](const ScoreType & ){initEval();})); - - guess.push_back(Texel::TexelParam(EvalConfig::pawnMobility[MG] , -500, 500,"pmobility0")); - guess.push_back(Texel::TexelParam(EvalConfig::pawnMobility[EG] , -500, 500,"pmobility1")); - - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[1][MG] , -150, 150,"protectedPasserFactor")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[1][EG] , -150, 150,"protectedPasserFactorEG")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[2][MG] , -150, 150,"protectedPasserFactor")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[2][EG] , -150, 150,"protectedPasserFactorEG")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[3][MG] , -150, 150,"protectedPasserFactor")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[3][EG] , -150, 150,"protectedPasserFactorEG")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[4][MG] , -150, 150,"protectedPasserFactor")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[4][EG] , -150, 150,"protectedPasserFactorEG")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[5][MG] , -150, 150,"protectedPasserFactor")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[5][EG] , -150, 150,"protectedPasserFactorEG")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[6][MG] , -150, 150,"protectedPasserFactor")); - guess.push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[6][EG] , -150, 150,"protectedPasserFactorEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[1][MG] , -150, 150,"freePasserBonus")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[1][EG] , -150, 150,"freePasserBonusEG")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[2][MG] , -150, 150,"freePasserBonus")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[2][EG] , -150, 150,"freePasserBonusEG")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[3][MG] , -150, 150,"freePasserBonus")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[3][EG] , -150, 150,"freePasserBonusEG")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[4][MG] , -150, 150,"freePasserBonus")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[4][EG] , -150, 150,"freePasserBonusEG")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[5][MG] , -150, 150,"freePasserBonus")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[5][EG] , -150, 150,"freePasserBonusEG")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[6][MG] , -150, 150,"freePasserBonus")); - guess.push_back(Texel::TexelParam(EvalConfig::freePasserBonus[6][EG] , -150, 150,"freePasserBonusEG")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[1][MG] , -150, 150,"protectedPasserFactor")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[1][EG] , -150, 150,"protectedPasserFactorEG")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[2][MG] , -150, 150,"protectedPasserFactor")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[2][EG] , -150, 150,"protectedPasserFactorEG")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[3][MG] , -150, 150,"protectedPasserFactor")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[3][EG] , -150, 150,"protectedPasserFactorEG")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[4][MG] , -150, 150,"protectedPasserFactor")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[4][EG] , -150, 150,"protectedPasserFactorEG")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[5][MG] , -150, 150,"protectedPasserFactor")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[5][EG] , -150, 150,"protectedPasserFactorEG")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[6][MG] , -150, 150,"protectedPasserFactor")); + guess["protectedPasser"].push_back(Texel::TexelParam(EvalConfig::protectedPasserBonus[6][EG] , -150, 150,"protectedPasserFactorEG")); + + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[1][MG] , -150, 150,"freePasserBonus")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[1][EG] , -150, 150,"freePasserBonusEG")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[2][MG] , -150, 150,"freePasserBonus")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[2][EG] , -150, 150,"freePasserBonusEG")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[3][MG] , -150, 150,"freePasserBonus")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[3][EG] , -150, 150,"freePasserBonusEG")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[4][MG] , -150, 150,"freePasserBonus")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[4][EG] , -150, 150,"freePasserBonusEG")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[5][MG] , -150, 150,"freePasserBonus")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[5][EG] , -150, 150,"freePasserBonusEG")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[6][MG] , -150, 150,"freePasserBonus")); + guess["freePasser"].push_back(Texel::TexelParam(EvalConfig::freePasserBonus[6][EG] , -150, 150,"freePasserBonusEG")); for (int k = 0 ; k < 9 ; ++k ){ - guess.push_back(Texel::TexelParam(EvalConfig::adjKnight[k][MG] , -150, 150,"adjKnightMG"+std::to_string(k))); - guess.push_back(Texel::TexelParam(EvalConfig::adjKnight[k][EG] , -150, 150,"adjKnightEG"+std::to_string(k))); + guess["adjustN"].push_back(Texel::TexelParam(EvalConfig::adjKnight[k][MG] , -150, 150,"adjKnightMG"+std::to_string(k))); + guess["adjustN"].push_back(Texel::TexelParam(EvalConfig::adjKnight[k][EG] , -150, 150,"adjKnightEG"+std::to_string(k))); } + for (int k = 0 ; k < 9 ; ++k ){ - guess.push_back(Texel::TexelParam(EvalConfig::adjRook[k][MG] , -150, 150,"adjRookMG"+std::to_string(k))); - guess.push_back(Texel::TexelParam(EvalConfig::adjRook[k][EG] , -150, 150,"adjRookEG"+std::to_string(k))); + guess["adjustR"].push_back(Texel::TexelParam(EvalConfig::adjRook[k][MG] , -150, 150,"adjRookMG"+std::to_string(k))); + guess["adjustR"].push_back(Texel::TexelParam(EvalConfig::adjRook[k][EG] , -150, 150,"adjRookEG"+std::to_string(k))); } for (int k = 0 ; k < 9 ; ++k ){ - guess.push_back(Texel::TexelParam(EvalConfig::bishopPairBonus[k][MG] , -500, 500,"bishop pair"+std::to_string(k))); - guess.push_back(Texel::TexelParam(EvalConfig::bishopPairBonus[k][EG] , -500, 500,"bishop pair EG"+std::to_string(k))); + guess["adjustB"].push_back(Texel::TexelParam(EvalConfig::bishopPairBonus[k][MG] , -500, 500,"bishop pair"+std::to_string(k))); + guess["adjustB"].push_back(Texel::TexelParam(EvalConfig::bishopPairBonus[k][EG] , -500, 500,"bishop pair EG"+std::to_string(k))); } - */ - /* for (int k = 0 ; k < 9 ; ++k ){ - guess.push_back(Texel::TexelParam(EvalConfig::badBishop[k][MG] , -500, 500,"badBishop"+std::to_string(k))); - guess.push_back(Texel::TexelParam(EvalConfig::badBishop[k][EG] , -500, 500,"badBishopEG"+std::to_string(k))); + guess["badBishop"].push_back(Texel::TexelParam(EvalConfig::badBishop[k][MG] , -500, 500,"badBishop"+std::to_string(k))); + guess["badBishop"].push_back(Texel::TexelParam(EvalConfig::badBishop[k][EG] , -500, 500,"badBishopEG"+std::to_string(k))); } - */ - /* - guess.push_back(Texel::TexelParam(EvalConfig::knightPairMalus[MG] , -500, 500,"knight pair")); - guess.push_back(Texel::TexelParam(EvalConfig::rookPairMalus [MG] , -500, 500,"rook pair")); - - guess.push_back(Texel::TexelParam(EvalConfig::knightPairMalus[EG] , -500, 500,"knight pair EG")); - guess.push_back(Texel::TexelParam(EvalConfig::rookPairMalus [EG] , -500, 500,"rook pair EG")); - - guess.push_back(Texel::TexelParam(EvalConfig::rookOnOpenFile [MG] , -500, 500,"rookOnOpenFile")); - guess.push_back(Texel::TexelParam(EvalConfig::rookOnOpenSemiFileOpp[MG] , -500, 500,"rookOnOpenSemiFileOpp")); - guess.push_back(Texel::TexelParam(EvalConfig::rookOnOpenSemiFileOur[MG] , -500, 500,"rookOnOpenSemiFileOur")); - guess.push_back(Texel::TexelParam(EvalConfig::rookOnOpenFile [EG] , -500, 500,"rookOnOpenFileEG")); - guess.push_back(Texel::TexelParam(EvalConfig::rookOnOpenSemiFileOpp[EG] , -500, 500,"rookOnOpenSemiFileOppEG")); - guess.push_back(Texel::TexelParam(EvalConfig::rookOnOpenSemiFileOur[EG] , -500, 500,"rookOnOpenSemiFileOurEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[1][MG], -1500, 1500,"passer 1")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[2][MG], -1500, 1500,"passer 2")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[3][MG], -1500, 1500,"passer 3")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[4][MG], -1500, 1500,"passer 4")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[5][MG], -1500, 1500,"passer 5")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[6][MG], -1500, 1500,"passer 6")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[1][EG], -1500, 1500,"passer 1")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[2][EG], -1500, 1500,"passer 2")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[3][EG], -1500, 1500,"passer 3")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[4][EG], -1500, 1500,"passer 4")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[5][EG], -1500, 1500,"passer 5")); - guess.push_back(Texel::TexelParam(EvalConfig::passerBonus[6][EG], -1500, 1500,"passer 6")); - - guess.push_back(Texel::TexelParam(EvalConfig::pieceFrontPawn[MG],-150,550,"pieceFrontPawn")); - guess.push_back(Texel::TexelParam(EvalConfig::pieceFrontPawn[EG],-150,550,"pieceFrontPawnEG")); - */ + guess["pairAdjust"].push_back(Texel::TexelParam(EvalConfig::knightPairMalus[MG] , -500, 500,"knight pair")); + guess["pairAdjust"].push_back(Texel::TexelParam(EvalConfig::rookPairMalus [MG] , -500, 500,"rook pair")); + guess["pairAdjust"].push_back(Texel::TexelParam(EvalConfig::knightPairMalus[EG] , -500, 500,"knight pair EG")); + guess["pairAdjust"].push_back(Texel::TexelParam(EvalConfig::rookPairMalus [EG] , -500, 500,"rook pair EG")); + + guess["rookOpen"].push_back(Texel::TexelParam(EvalConfig::rookOnOpenFile [MG] , -500, 500,"rookOnOpenFile")); + guess["rookOpen"].push_back(Texel::TexelParam(EvalConfig::rookOnOpenSemiFileOpp[MG] , -500, 500,"rookOnOpenSemiFileOpp")); + guess["rookOpen"].push_back(Texel::TexelParam(EvalConfig::rookOnOpenSemiFileOur[MG] , -500, 500,"rookOnOpenSemiFileOur")); + guess["rookOpen"].push_back(Texel::TexelParam(EvalConfig::rookOnOpenFile [EG] , -500, 500,"rookOnOpenFileEG")); + guess["rookOpen"].push_back(Texel::TexelParam(EvalConfig::rookOnOpenSemiFileOpp[EG] , -500, 500,"rookOnOpenSemiFileOppEG")); + guess["rookOpen"].push_back(Texel::TexelParam(EvalConfig::rookOnOpenSemiFileOur[EG] , -500, 500,"rookOnOpenSemiFileOurEG")); + + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[1][MG], -1500, 1500,"passer 1")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[2][MG], -1500, 1500,"passer 2")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[3][MG], -1500, 1500,"passer 3")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[4][MG], -1500, 1500,"passer 4")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[5][MG], -1500, 1500,"passer 5")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[6][MG], -1500, 1500,"passer 6")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[1][EG], -1500, 1500,"passer 1")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[2][EG], -1500, 1500,"passer 2")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[3][EG], -1500, 1500,"passer 3")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[4][EG], -1500, 1500,"passer 4")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[5][EG], -1500, 1500,"passer 5")); + guess["passer"].push_back(Texel::TexelParam(EvalConfig::passerBonus[6][EG], -1500, 1500,"passer 6")); + + guess["pieceBlocking"].push_back(Texel::TexelParam(EvalConfig::pieceFrontPawn[MG],-150,550,"pieceFrontPawn")); + guess["pieceBlocking"].push_back(Texel::TexelParam(EvalConfig::pieceFrontPawn[EG],-150,550,"pieceFrontPawnEG")); + + guess["holes"].push_back(Texel::TexelParam(EvalConfig::holesMalus[MG],-150,550,"holesMalus")); + guess["holes"].push_back(Texel::TexelParam(EvalConfig::holesMalus[EG],-150,550,"holesMalusEG")); + guess["holes"].push_back(Texel::TexelParam(EvalConfig::outpost[MG],-150,550,"outpost")); + guess["holes"].push_back(Texel::TexelParam(EvalConfig::outpost[EG],-150,550,"outpostEG")); + + guess["center"].push_back(Texel::TexelParam(EvalConfig::centerControl[MG],-150,550,"center")); + guess["center"].push_back(Texel::TexelParam(EvalConfig::centerControl[EG],-150,550,"centerEG")); + + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::doublePawnMalus [0][MG],-150,550,"doublePawnMalus[0]")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::doublePawnMalus [0][EG],-150,550,"doublePawnMalusEG[0]")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::isolatedPawnMalus[0][MG],-150,550,"isolatedPawnMalus[0]")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::isolatedPawnMalus[0][EG],-150,550,"isolatedPawnMalusEG[0]")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::backwardPawnMalus[0][MG], -150, 550, "backwardPawnMalus0")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::backwardPawnMalus[0][EG], -150, 550, "backwardPawnMalusEG0")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::doublePawnMalus [1][MG], -150, 550, "doublePawnMalus[1]")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::doublePawnMalus [1][EG], -150, 550, "doublePawnMalusEG[1]")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::isolatedPawnMalus[1][MG], -150, 550, "isolatedPawnMalus[1]")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::isolatedPawnMalus[1][EG], -150, 550, "isolatedPawnMalusEG[1]")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::backwardPawnMalus[1][MG], -150, 550, "backwardPawnMalus1")); + guess["pawnStructure"].push_back(Texel::TexelParam(EvalConfig::backwardPawnMalus[1][EG], -150, 550, "backwardPawnMalusEG1")); + + guess["shield"].push_back(Texel::TexelParam(EvalConfig::pawnShieldBonus[MG] ,-150,550,"pawnShieldBonus0")); + guess["shield"].push_back(Texel::TexelParam(EvalConfig::pawnShieldBonus[EG] ,-150,550,"pawnShieldBonus1")); + + guess["kingNearPassed"].push_back(Texel::TexelParam(EvalConfig::kingNearPassedPawn[MG],-150,550,"kingNearPassedPawn")); + guess["kingNearPassed"].push_back(Texel::TexelParam(EvalConfig::kingNearPassedPawn[EG],-150,550,"kingNearPassedPawnEG")); + + guess["rookBehindPassed"].push_back(Texel::TexelParam(EvalConfig::rookBehindPassed[MG] , -500, 500,"rookBehindPassed0")); + guess["rookBehindPassed"].push_back(Texel::TexelParam(EvalConfig::rookBehindPassed[EG] , -500, 500,"rookBehindPassed1")); + + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[1][MG], -1500, 1500,"candidate 1")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[2][MG], -1500, 1500,"candidate 2")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[3][MG], -1500, 1500,"candidate 3")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[4][MG], -1500, 1500,"candidate 4")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[5][MG], -1500, 1500,"candidate 5")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[6][MG], -1500, 1500,"candidate 6")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[1][EG], -1500, 1500,"candidateEG 1")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[2][EG], -1500, 1500,"candidateEG 2")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[3][EG], -1500, 1500,"candidateEG 3")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[4][EG], -1500, 1500,"candidateEG 4")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[5][EG], -1500, 1500,"candidateEG 5")); + guess["candidate"].push_back(Texel::TexelParam(EvalConfig::candidate[6][EG], -1500, 1500,"candidateEG 6")); - /* - guess.push_back(Texel::TexelParam(EvalConfig::holesMalus[MG],-150,550,"holesMalus")); - guess.push_back(Texel::TexelParam(EvalConfig::holesMalus[EG],-150,550,"holesMalusEG")); - guess.push_back(Texel::TexelParam(EvalConfig::outpost[MG],-150,550,"outpost")); - guess.push_back(Texel::TexelParam(EvalConfig::outpost[EG],-150,550,"outpostEG")); - */ - - guess.push_back(Texel::TexelParam(EvalConfig::centerControl[MG],-150,550,"center")); - guess.push_back(Texel::TexelParam(EvalConfig::centerControl[EG],-150,550,"centerEG")); - - /* - guess.push_back(Texel::TexelParam(EvalConfig::doublePawnMalus [0][MG],-150,550,"doublePawnMalus[0]")); - guess.push_back(Texel::TexelParam(EvalConfig::doublePawnMalus [0][EG],-150,550,"doublePawnMalusEG[0]")); - guess.push_back(Texel::TexelParam(EvalConfig::isolatedPawnMalus[0][MG],-150,550,"isolatedPawnMalus[0]")); - guess.push_back(Texel::TexelParam(EvalConfig::isolatedPawnMalus[0][EG],-150,550,"isolatedPawnMalusEG[0]")); - guess.push_back(Texel::TexelParam(EvalConfig::backwardPawnMalus[0][MG], -150, 550, "backwardPawnMalus0")); - guess.push_back(Texel::TexelParam(EvalConfig::backwardPawnMalus[0][EG], -150, 550, "backwardPawnMalusEG0")); - guess.push_back(Texel::TexelParam(EvalConfig::doublePawnMalus [1][MG], -150, 550, "doublePawnMalus[1]")); - guess.push_back(Texel::TexelParam(EvalConfig::doublePawnMalus [1][EG], -150, 550, "doublePawnMalusEG[1]")); - guess.push_back(Texel::TexelParam(EvalConfig::isolatedPawnMalus[1][MG], -150, 550, "isolatedPawnMalus[1]")); - guess.push_back(Texel::TexelParam(EvalConfig::isolatedPawnMalus[1][EG], -150, 550, "isolatedPawnMalusEG[1]")); - guess.push_back(Texel::TexelParam(EvalConfig::backwardPawnMalus[1][MG], -150, 550, "backwardPawnMalus1")); - guess.push_back(Texel::TexelParam(EvalConfig::backwardPawnMalus[1][EG], -150, 550, "backwardPawnMalusEG1")); - */ - - /* - guess.push_back(Texel::TexelParam(EvalConfig::pawnShieldBonus[MG] ,-150,550,"pawnShieldBonus0")); - guess.push_back(Texel::TexelParam(EvalConfig::pawnShieldBonus[EG] ,-150,550,"pawnShieldBonus1")); - */ - - /* - guess.push_back(Texel::TexelParam(EvalConfig::kingNearPassedPawn[MG],-150,550,"kingNearPassedPawn")); - guess.push_back(Texel::TexelParam(EvalConfig::kingNearPassedPawn[EG],-150,550,"kingNearPassedPawnEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::rookBehindPassed[MG] , -500, 500,"rookBehindPassed0")); - guess.push_back(Texel::TexelParam(EvalConfig::rookBehindPassed[EG] , -500, 500,"rookBehindPassed1")); - - guess.push_back(Texel::TexelParam(EvalConfig::candidate[1][MG], -1500, 1500,"candidate 1")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[2][MG], -1500, 1500,"candidate 2")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[3][MG], -1500, 1500,"candidate 3")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[4][MG], -1500, 1500,"candidate 4")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[5][MG], -1500, 1500,"candidate 5")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[6][MG], -1500, 1500,"candidate 6")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[1][EG], -1500, 1500,"candidateEG 1")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[2][EG], -1500, 1500,"candidateEG 2")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[3][EG], -1500, 1500,"candidateEG 3")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[4][EG], -1500, 1500,"candidateEG 4")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[5][EG], -1500, 1500,"candidateEG 5")); - guess.push_back(Texel::TexelParam(EvalConfig::candidate[6][EG], -1500, 1500,"candidateEG 6")); - */ - - /* for (int k = 0; k < 6; ++k) { - guess.push_back(Texel::TexelParam(EvalConfig::threatByMinor[k][MG], -200, 200, "threatByMinor" + std::to_string(k) )); - guess.push_back(Texel::TexelParam(EvalConfig::threatByMinor[k][EG], -200, 200, "threatByMinorEG" + std::to_string(k))); + guess["minorThreat"].push_back(Texel::TexelParam(EvalConfig::threatByMinor[k][MG], -200, 200, "threatByMinor" + std::to_string(k) )); + guess["minorThreat"].push_back(Texel::TexelParam(EvalConfig::threatByMinor[k][EG], -200, 200, "threatByMinorEG" + std::to_string(k))); } for (int k = 0; k < 6; ++k) { - guess.push_back(Texel::TexelParam(EvalConfig::threatByRook[k][MG], -200, 200, "threatByRook" + std::to_string(k))); - guess.push_back(Texel::TexelParam(EvalConfig::threatByRook[k][EG], -200, 200, "threatByRookEG" + std::to_string(k))); + guess["rookThreat"].push_back(Texel::TexelParam(EvalConfig::threatByRook[k][MG], -200, 200, "threatByRook" + std::to_string(k))); + guess["rookThreat"].push_back(Texel::TexelParam(EvalConfig::threatByRook[k][EG], -200, 200, "threatByRookEG" + std::to_string(k))); } for (int k = 0; k < 6; ++k) { - guess.push_back(Texel::TexelParam(EvalConfig::threatByQueen[k][MG], -200, 200, "threatByQueen" + std::to_string(k))); - guess.push_back(Texel::TexelParam(EvalConfig::threatByQueen[k][EG], -200, 200, "threatByQueenEG" + std::to_string(k))); + guess["queenThreat"].push_back(Texel::TexelParam(EvalConfig::threatByQueen[k][MG], -200, 200, "threatByQueen" + std::to_string(k))); + guess["queenThreat"].push_back(Texel::TexelParam(EvalConfig::threatByQueen[k][EG], -200, 200, "threatByQueenEG" + std::to_string(k))); } for (int k = 0; k < 6; ++k) { - guess.push_back(Texel::TexelParam(EvalConfig::threatByKing[k][MG], -200, 200, "threatByKing" + std::to_string(k))); - guess.push_back(Texel::TexelParam(EvalConfig::threatByKing[k][EG], -200, 200, "threatByKingEG" + std::to_string(k))); + guess["kingThreat"].push_back(Texel::TexelParam(EvalConfig::threatByKing[k][MG], -200, 200, "threatByKing" + std::to_string(k))); + guess["kingThreat"].push_back(Texel::TexelParam(EvalConfig::threatByKing[k][EG], -200, 200, "threatByKingEG" + std::to_string(k))); } - */ - /* for (int k = 0 ; k < 6 ; ++k ){ for(int i = 0 ; i < 29 ; ++i){ - guess.push_back(Texel::TexelParam(EvalConfig::MOB[k][i][MG],-200,200,"mob"+std::to_string(k)+"_"+std::to_string(i))); + guess["mobility"].push_back(Texel::TexelParam(EvalConfig::MOB[k][i][MG],-200,200,"mob"+std::to_string(k)+"_"+std::to_string(i))); } } for (int k = 0 ; k < 6 ; ++k ){ for(int i = 0 ; i < 29 ; ++i){ - guess.push_back(Texel::TexelParam(EvalConfig::MOB[k][i][EG],-200,200,"mobeg"+std::to_string(k)+"_"+std::to_string(i))); + guess["mobility"].push_back(Texel::TexelParam(EvalConfig::MOB[k][i][EG],-200,200,"mobeg"+std::to_string(k)+"_"+std::to_string(i))); } } - */ - /* + for (int k = 0 ; k < 6 ; ++k ){ for(int i = 0 ; i < 64 ; ++i){ - guess.push_back(Texel::TexelParam(EvalConfig::PST[k][i][MG],-200,200,"pst"+std::to_string(k)+"_"+std::to_string(i))); + guess["PST"].push_back(Texel::TexelParam(EvalConfig::PST[k][i][MG],-200,200,"pst"+std::to_string(k)+"_"+std::to_string(i))); } } for (int k = 0 ; k < 6 ; ++k ){ for(int i = 0 ; i < 64 ; ++i){ - guess.push_back(Texel::TexelParam(EvalConfig::PST[k][i][EG],-200,200,"psteg"+std::to_string(k)+"_"+std::to_string(i))); + guess["PST"].push_back(Texel::TexelParam(EvalConfig::PST[k][i][EG],-200,200,"psteg"+std::to_string(k)+"_"+std::to_string(i))); } } - */ - /* - guess.push_back(Texel::TexelParam(EvalConfig::rookQueenSameFile[MG] , -500, 500,"rookQueenSameFile")); - guess.push_back(Texel::TexelParam(EvalConfig::rookQueenSameFile[EG] , -500, 500,"rookQueenSameFileEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::rookFrontQueenMalus[MG] , -500, 500,"rookFrontQueenMalus")); - guess.push_back(Texel::TexelParam(EvalConfig::rookFrontQueenMalus[EG] , -500, 500,"rookFrontQueenMalusEG")); - */ + guess["rookQueenFile"].push_back(Texel::TexelParam(EvalConfig::rookQueenSameFile[MG] , -500, 500,"rookQueenSameFile")); + guess["rookQueenFile"].push_back(Texel::TexelParam(EvalConfig::rookQueenSameFile[EG] , -500, 500,"rookQueenSameFileEG")); + + guess["rookFrontQueen"].push_back(Texel::TexelParam(EvalConfig::rookFrontQueenMalus[MG] , -500, 500,"rookFrontQueenMalus")); + guess["rookFrontQueen"].push_back(Texel::TexelParam(EvalConfig::rookFrontQueenMalus[EG] , -500, 500,"rookFrontQueenMalusEG")); + + guess["rookFrontKing"].push_back(Texel::TexelParam(EvalConfig::rookFrontKingMalus[MG] , -500, 500,"rookFrontKingMalus")); + guess["rookFrontKing"].push_back(Texel::TexelParam(EvalConfig::rookFrontKingMalus[EG] , -500, 500,"rookFrontKingMalusEG")); + + guess["hanging"].push_back(Texel::TexelParam(EvalConfig::hangingPieceMalus[MG] , -500, 500,"hangingPieceMalus")); + guess["hanging"].push_back(Texel::TexelParam(EvalConfig::hangingPieceMalus[EG] , -500, 500,"hangingPieceMalusEG")); + + guess["initiative"].push_back(Texel::TexelParam(EvalConfig::initiative[0][MG] , -500, 500,"initiativeMG0")); + guess["initiative"].push_back(Texel::TexelParam(EvalConfig::initiative[0][EG] , -500, 500,"initiativeEG0")); + guess["initiative"].push_back(Texel::TexelParam(EvalConfig::initiative[1][MG] , -500, 500,"initiativeMG1")); + guess["initiative"].push_back(Texel::TexelParam(EvalConfig::initiative[1][EG] , -500, 500,"initiativeEG1")); + guess["initiative"].push_back(Texel::TexelParam(EvalConfig::initiative[2][MG] , -500, 500,"initiativeMG2")); + guess["initiative"].push_back(Texel::TexelParam(EvalConfig::initiative[2][EG] , -500, 500,"initiativeEG2")); + guess["initiative"].push_back(Texel::TexelParam(EvalConfig::initiative[3][MG] , -500, 500,"initiativeMG3")); + guess["initiative"].push_back(Texel::TexelParam(EvalConfig::initiative[3][EG] , -500, 500,"initiativeEG3")); + + guess["pawnAtt"].push_back(Texel::TexelParam(EvalConfig::pawnSafeAtt[MG] , -500, 500,"pawnSafeAtt")); + guess["pawnAtt"].push_back(Texel::TexelParam(EvalConfig::pawnSafeAtt[EG] , -500, 500,"pawnSafeAttEG")); + guess["pawnAtt"].push_back(Texel::TexelParam(EvalConfig::pawnSafePushAtt[MG] , -500, 500,"pawnSafePushAtt")); + guess["pawnAtt"].push_back(Texel::TexelParam(EvalConfig::pawnSafePushAtt[EG] , -500, 500,"pawnSafePushAttEG")); + + guess["storm"].push_back(Texel::TexelParam(EvalConfig::pawnStormMalus[MG] , -500, 500,"pawnStormMalus")); + guess["storm"].push_back(Texel::TexelParam(EvalConfig::pawnStormMalus[EG] , -500, 500,"pawnStormMalusEG")); + + guess["minorOnOpen"].push_back(Texel::TexelParam(EvalConfig::minorOnOpenFile[MG] , -500, 500,"minorOnOpenFile")); + guess["minorOnOpen"].push_back(Texel::TexelParam(EvalConfig::minorOnOpenFile[EG] , -500, 500,"minorOnOpenFileEG")); + + guess["queenNearKing"].push_back(Texel::TexelParam(EvalConfig::queenNearKing[MG] , -500, 500,"queenNearKing")); + guess["queenNearKing"].push_back(Texel::TexelParam(EvalConfig::queenNearKing[EG] , -500, 500,"queenNearKingEG")); + + guess["pawnlessFlank"].push_back(Texel::TexelParam(EvalConfig::pawnlessFlank[MG] , -500, 500,"pawnlessFlank")); + guess["pawnlessFlank"].push_back(Texel::TexelParam(EvalConfig::pawnlessFlank[EG] , -500, 500,"pawnlessFlankEG")); + + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [0][MG] , -100, 100, "ppinK")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [0][EG] , -100, 100, "ppinKEG")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[0][MG] , -100, 100, "ppinq")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[0][EG] , -100, 100, "ppinqEG")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [1][MG] , -100, 100, "npinK")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [1][EG] , -100, 100, "npinKEG")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[1][MG] , -100, 100, "npinq")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[1][EG] , -100, 100, "npinqEG")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [2][MG] , -100, 100, "bpinK")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [2][EG] , -100, 100, "bpinKEG")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[2][MG] , -100, 100, "bpinq")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[2][EG] , -100, 100, "bpinqEG")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [3][MG] , -100, 100, "rpinK")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [3][EG] , -100, 100, "rpinKEG")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[3][MG] , -100, 100, "rpinq")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[3][EG] , -100, 100, "rpinqEG")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [4][MG] , -100, 100, "qpinK")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedKing [4][EG] , -100, 100, "qpinKEG")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[4][MG] , -100, 100, "qpinq")); + guess["pinned"].push_back(Texel::TexelParam(EvalConfig::pinnedQueen[4][EG] , -100, 100, "qpinqEG")); + + guess["tempo"].push_back(Texel::TexelParam(EvalConfig::tempo[MG] , -500, 500,"tempo")); + guess["tempo"].push_back(Texel::TexelParam(EvalConfig::tempo[EG] , -500, 500,"tempoEG")); - /* - guess.push_back(Texel::TexelParam(EvalConfig::hangingPieceMalus[MG] , -500, 500,"hangingPieceMalus")); - guess.push_back(Texel::TexelParam(EvalConfig::hangingPieceMalus[EG] , -500, 500,"hangingPieceMalusEG")); - */ - - /* - guess.push_back(Texel::TexelParam(EvalConfig::initiative[0][MG] , -500, 500,"initiativeMG0")); - guess.push_back(Texel::TexelParam(EvalConfig::initiative[0][EG] , -500, 500,"initiativeEG0")); - */ - /* - guess.push_back(Texel::TexelParam(EvalConfig::initiative[1][MG] , -500, 500,"initiativeMG1")); - guess.push_back(Texel::TexelParam(EvalConfig::initiative[1][EG] , -500, 500,"initiativeEG1")); - */ - /* - guess.push_back(Texel::TexelParam(EvalConfig::initiative[2][MG] , -500, 500,"initiativeMG2")); - guess.push_back(Texel::TexelParam(EvalConfig::initiative[2][EG] , -500, 500,"initiativeEG2")); - */ - /* - guess.push_back(Texel::TexelParam(EvalConfig::initiative[3][MG] , -500, 500,"initiativeMG3")); - guess.push_back(Texel::TexelParam(EvalConfig::initiative[3][EG] , -500, 500,"initiativeEG3")); - */ - - /* - guess.push_back(Texel::TexelParam(EvalConfig::pawnSafeAtt[MG] , -500, 500,"pawnSafeAtt")); - guess.push_back(Texel::TexelParam(EvalConfig::pawnSafeAtt[EG] , -500, 500,"pawnSafeAttEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::pawnSafePushAtt[MG] , -500, 500,"pawnSafePushAtt")); - guess.push_back(Texel::TexelParam(EvalConfig::pawnSafePushAtt[EG] , -500, 500,"pawnSafePushAttEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::pawnStormMalus[MG] , -500, 500,"pawnStormMalus")); - guess.push_back(Texel::TexelParam(EvalConfig::pawnStormMalus[EG] , -500, 500,"pawnStormMalusEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::rookFrontKingMalus[MG] , -500, 500,"rookFrontKingMalus")); - guess.push_back(Texel::TexelParam(EvalConfig::rookFrontKingMalus[EG] , -500, 500,"rookFrontKingMalusEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::minorOnOpenFile[MG] , -500, 500,"minorOnOpenFile")); - guess.push_back(Texel::TexelParam(EvalConfig::minorOnOpenFile[EG] , -500, 500,"minorOnOpenFileEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::queenNearKing[MG] , -500, 500,"queenNearKing")); - guess.push_back(Texel::TexelParam(EvalConfig::queenNearKing[EG] , -500, 500,"queenNearKingEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::pawnlessFlank[MG] , -500, 500,"pawnlessFlank")); - guess.push_back(Texel::TexelParam(EvalConfig::pawnlessFlank[EG] , -500, 500,"pawnlessFlankEG")); - - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [0][MG] , -100, 100, "ppinK")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [0][EG] , -100, 100, "ppinKEG")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[0][MG] , -100, 100, "ppinq")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[0][EG] , -100, 100, "ppinqEG")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [1][MG] , -100, 100, "npinK")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [1][EG] , -100, 100, "npinKEG")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[1][MG] , -100, 100, "npinq")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[1][EG] , -100, 100, "npinqEG")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [2][MG] , -100, 100, "bpinK")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [2][EG] , -100, 100, "bpinKEG")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[2][MG] , -100, 100, "bpinq")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[2][EG] , -100, 100, "bpinqEG")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [3][MG] , -100, 100, "rpinK")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [3][EG] , -100, 100, "rpinKEG")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[3][MG] , -100, 100, "rpinq")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[3][EG] , -100, 100, "rpinqEG")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [4][MG] , -100, 100, "qpinK")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedKing [4][EG] , -100, 100, "qpinKEG")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[4][MG] , -100, 100, "qpinq")); - guess.push_back(Texel::TexelParam(EvalConfig::pinnedQueen[4][EG] , -100, 100, "qpinqEG")); - */ - - /* - - guess.push_back(Texel::TexelParam(EvalConfig::tempo[EG] , -500, 500,"tempo")); - */ - - /* for (Mat m1 = M_p; m1 <= M_q; ++m1) { for (Mat m2 = M_p; m2 <= m1; ++m2) { - guess.push_back(Texel::TexelParam(EvalConfig::imbalance_mines[m1-1][m2-1][MG], -3000, 3000, "imbalance_mines" + std::to_string(m1) + "_" + std::to_string(m2))); - guess.push_back(Texel::TexelParam(EvalConfig::imbalance_theirs[m1-1][m2-1][MG], -3000, 3000, "imbalance_theirs" + std::to_string(m1) + "_" + std::to_string(m2))); - guess.push_back(Texel::TexelParam(EvalConfig::imbalance_mines[m1-1][m2-1][EG], -3000, 3000, "imbalance_minesEG" + std::to_string(m1) + "_" + std::to_string(m2))); - guess.push_back(Texel::TexelParam(EvalConfig::imbalance_theirs[m1-1][m2-1][EG], -3000, 3000, "imbalance_theirsEG" + std::to_string(m1) + "_" + std::to_string(m2))); + guess["imbalance"].push_back(Texel::TexelParam(EvalConfig::imbalance_mines[m1-1][m2-1][MG], -3000, 3000, "imbalance_mines" + std::to_string(m1) + "_" + std::to_string(m2))); + guess["imbalance"].push_back(Texel::TexelParam(EvalConfig::imbalance_theirs[m1-1][m2-1][MG], -3000, 3000, "imbalance_theirs" + std::to_string(m1) + "_" + std::to_string(m2))); + guess["imbalance"].push_back(Texel::TexelParam(EvalConfig::imbalance_mines[m1-1][m2-1][EG], -3000, 3000, "imbalance_minesEG" + std::to_string(m1) + "_" + std::to_string(m2))); + guess["imbalance"].push_back(Texel::TexelParam(EvalConfig::imbalance_theirs[m1-1][m2-1][EG], -3000, 3000, "imbalance_theirsEG" + std::to_string(m1) + "_" + std::to_string(m2))); } } - */ + + for(auto it = guess.begin() ; it != guess.end(); ++it){ + std::cout << "\"" << it->first << "\","; + } computeOptimalK(data); Logging::LogIt(Logging::logInfo) << "Optimal K " << Texel::K; - Logging::LogIt(Logging::logInfo) << "Initial values :"; - for (size_t k = 0; k < guess.size(); ++k) Logging::LogIt(Logging::logInfo) << guess[k].name << " " << guess[k]; - std::vector > optim = Texel::TexelOptimizeGD(guess, data, batchSize); - //std::vector > optim = Texel::TexelOptimizeNaive(guess, data, batchSize); + std::vector todo = { + //"piecesValue", + //"PST", + //"mobility", + + "passer", + "freePasser", + "protectedPasser", + "kingNearPassed", + "pawnStructure", + "candidate", + + "pawnMob", + "pawnAtt", + + "rookBehindPassed", + "rookFrontKing", + "rookFrontQueen", + "rookOpen", + "rookQueenFile", + + "pairAdjust", + "adjustN", + "adjustR", + "adjustB", + "badBishop", + + "shield", + "queenNearKing", + + "holes", + "center", + "pieceBlocking", + "minorOnOpen", + + "hanging", + "pinned", - Logging::LogIt(Logging::logInfo) << "Optimized values :"; - for (size_t k = 0; k < optim.size(); ++k) Logging::LogIt(Logging::logInfo) << optim[k].name << " " << optim[k]; + "attDefKing", + "attFunction", + "pawnlessFlank", + "attOpenFile", + + "imbalance", + "initiative", + + "kingThreat", + "minorThreat", + "queenThreat", + "rookThreat", + + //"safeChecks", + + "storm", + + "tempo" + }; + + for(auto loops = 0 ; loops < 10 ; ++loops){ + for(auto it = todo.begin() ; it != todo.end(); ++it){ + if ( guess.find(*it) == guess.end() ) continue; + Logging::LogIt(Logging::logInfo) << "Initial values :"; + for (size_t k = 0; k < guess[*it].size(); ++k) Logging::LogIt(Logging::logInfo) << guess[*it][k].name << " " << guess[*it][k]; + std::vector > optim = Texel::TexelOptimizeGD(guess[*it], data, batchSize, 10*guess[*it].size()); + Logging::LogIt(Logging::logInfo) << "Optimized values :"; + for (size_t k = 0; k < optim.size(); ++k) Logging::LogIt(Logging::logInfo) << optim[k].name << " " << optim[k]; + } + for(auto it = todo.begin() ; it != todo.end(); ++it){ + for (size_t k = 0; k < guess[*it].size(); ++k) Logging::LogIt(Logging::logInfo) << guess[*it][k].name << " " << guess[*it][k]; + } + } for (size_t k = 0; k < data.size(); ++k) delete data[k].p; } diff --git a/minic.cc b/minic.cc index d52339c8..1bad5a4b 100644 --- a/minic.cc +++ b/minic.cc @@ -325,20 +325,20 @@ namespace EvalConfig { CONST_TEXEL_TUNING EvalScore imbalance_mines[5][5] = { // pawn knight bishop rook queen - { { 12, 99} }, // Pawn - { {205,234}, {-119,-247} }, // Knight - { {262,129}, {-356,-290}, {-161,-242} }, // Bishop - { {393,395}, {-299,-251}, {-328,-404},{ -255, -462} }, // Rook - { {507,473}, {-425,-350}, {-608,-510},{-1162,-1092}, {-392,-388} } // Queen + { { -4, 90} }, // Pawn + { {115,291}, {-132,-263} }, // Knight + { {256,248}, {-239,-245}, {-199,-288} }, // Bishop + { {313,512}, {-208,-206}, {-232,-430},{ -178, -440} }, // Rook + { {543,568}, {-482,-354}, {-701,-524},{-1207,-1130}, {-413,-412} } // Queen }; CONST_TEXEL_TUNING EvalScore imbalance_theirs[5][5] = { // pawn knight bishop rook queen - { {-188,-301} }, // Pawn - { { 294, 284}, { -23,-17} }, // Knight - { { 243, 416}, { 3,-45}, { -58, -53} }, // Bishop - { { 284, 626}, { 31,-54}, {-116,-153}, {-108,-146} }, // Rook - { { 705, 753}, { 394,351}, { 381, 307}, { 327, 329}, {36,25} } // Queen + { {-163,-227} }, // Pawn + { { 269, 323}, { 1,-38} }, // Knight + { { 190, 463}, { 26,-74}, { 7, -42} }, // Bishop + { { 211, 602}, { 106,-67}, { -17,-203}, { -33,-180} }, // Rook + { { 725, 873}, { 446,347}, { 481, 300}, { 383, 331}, {36,14} } // Queen }; CONST_TEXEL_TUNING EvalScore PST[6][64] = { @@ -404,54 +404,53 @@ CONST_TEXEL_TUNING EvalScore PST[6][64] = { } }; -CONST_TEXEL_TUNING EvalScore pawnShieldBonus = {2, -2}; -CONST_TEXEL_TUNING EvalScore passerBonus[8] = { { 0, 0 }, {20, -40} , {6, -19}, {-10, 13}, {10, 37}, {33, 71}, {42, 109}, {0, 0}}; -CONST_TEXEL_TUNING EvalScore rookBehindPassed = { -8,41}; -CONST_TEXEL_TUNING EvalScore kingNearPassedPawn = { -9,13}; +CONST_TEXEL_TUNING EvalScore pawnShieldBonus = {4, -1}; +CONST_TEXEL_TUNING EvalScore passerBonus[8] = { { 0, 0 }, {16, -32} , { 0, -10}, {-8, 14}, {6, 47}, {41, 54}, {52, 66}, {0, 0}}; +CONST_TEXEL_TUNING EvalScore rookBehindPassed = {-12,52}; +CONST_TEXEL_TUNING EvalScore kingNearPassedPawn = { -9,15}; enum PawnEvalSemiOpen{ Close=0, SemiOpen=1}; ///@todo make this depends on file! (/rank?) -CONST_TEXEL_TUNING EvalScore doublePawnMalus[2] = {{ 28, 10 },{ 12, 17 }}; // close semiopenfile -CONST_TEXEL_TUNING EvalScore isolatedPawnMalus[2] = {{ 10, 5 },{ 15, 17 }}; // close semiopenfile -CONST_TEXEL_TUNING EvalScore backwardPawnMalus[2] = {{ 2, 1 },{ 26, -6 }}; // close semiopenfile -CONST_TEXEL_TUNING EvalScore holesMalus = { -5, 1}; -CONST_TEXEL_TUNING EvalScore pieceFrontPawn = { -13,13}; -CONST_TEXEL_TUNING EvalScore outpost = { 14,19}; -CONST_TEXEL_TUNING EvalScore centerControl = { 7,-2}; -CONST_TEXEL_TUNING EvalScore candidate[8] = { {0, 0}, {-30, 11}, {-15, 0}, { 14, 6}, { 24, 51}, {-11, 14}, {-11, 14}, { 0, 0} }; -CONST_TEXEL_TUNING EvalScore protectedPasserBonus[8]={ {0, 0}, { 8, 17}, { 8 , 4}, { 14, 2}, { 14, 11}, { 12, 19}, { 8 , 16}, { 0, 0} }; -CONST_TEXEL_TUNING EvalScore freePasserBonus[8] = { {0, 0}, { -5, 27}, {-24, 19}, {-22, 22}, {-19, 41}, { -5, 74}, {-23, 77}, { 0, 0} }; -CONST_TEXEL_TUNING EvalScore pawnMobility = { -1,15}; -CONST_TEXEL_TUNING EvalScore pawnSafeAtt = { 34,12}; -CONST_TEXEL_TUNING EvalScore pawnSafePushAtt = { 20, 6}; -CONST_TEXEL_TUNING EvalScore pawnlessFlank = {-10,-19}; -CONST_TEXEL_TUNING EvalScore pawnStormMalus = { 14,-22}; -CONST_TEXEL_TUNING EvalScore rookOnOpenFile = { 54, 0}; -CONST_TEXEL_TUNING EvalScore rookOnOpenSemiFileOur = { 8, 3}; -CONST_TEXEL_TUNING EvalScore rookOnOpenSemiFileOpp = { 22, 0}; - -CONST_TEXEL_TUNING EvalScore rookQueenSameFile = { 6, -3}; -CONST_TEXEL_TUNING EvalScore rookFrontQueenMalus = { -8,-18}; -CONST_TEXEL_TUNING EvalScore rookFrontKingMalus = {-12, 5}; -CONST_TEXEL_TUNING EvalScore minorOnOpenFile = { 11, -3}; -//CONST_TEXEL_TUNING EvalScore attQueenMalus[5] = {{2,-5},{-16,4},{-40,-16},{-57,-3},{32,39}}; - -CONST_TEXEL_TUNING EvalScore pinnedKing [5] = { { -5, -9}, { 13, 65}, { -8, 66}, {-16, 61}, {-1, 27} }; -CONST_TEXEL_TUNING EvalScore pinnedQueen[5] = { { 12,-34}, {-25, 10}, { 5, 10}, { 1, 10}, {31, 34} }; - -CONST_TEXEL_TUNING EvalScore hangingPieceMalus = {-24, -11}; - -CONST_TEXEL_TUNING EvalScore threatByMinor[6] = { { -11, -5 },{ -20,-27 },{ -19, -10 },{ -25, 11 },{ -16, -9 },{ 0, 0 } }; -CONST_TEXEL_TUNING EvalScore threatByRook[6] = { { -5, -5 },{ -11, -1 },{ -4, -3 },{ -4, -1 },{ -7, -9 },{ 0, 0 } }; -CONST_TEXEL_TUNING EvalScore threatByQueen[6] = { { -4, 21 },{ 1, -2 },{ 20, -9 },{ 31, -7 },{ 16, -6 },{ 0, 0 } }; -CONST_TEXEL_TUNING EvalScore threatByKing[6] = { { -6,-17 },{ -5, 1 },{ -4, -10 },{ -5, -7 },{ 0, 0 },{ 0, 0 } }; - -CONST_TEXEL_TUNING EvalScore adjKnight[9] = { {-24,-27}, { -12, 9}, { -4, 18}, { 1, 17}, { 12, 22}, { 17, 24}, { 14, 46}, { 26, 40}, { 22, 10} }; -CONST_TEXEL_TUNING EvalScore adjRook[9] = { { 24, 22}, { 9, 7}, { 15, 1}, { 1, 4}, {-17, 13}, {-23, 24}, {-24, 32}, {-23, 46}, { -3, 17} }; -CONST_TEXEL_TUNING EvalScore badBishop[9] = { {-16, 3}, {-12, -1}, {-11, 8}, { -6, 14}, { 1, 18}, { 4, 30}, { 14, 31}, { 19, 48}, { 36, 68} }; -CONST_TEXEL_TUNING EvalScore bishopPairBonus[9] = { { 31, 56}, { 31, 57}, { 27, 63}, { 14, 77}, { 24, 62}, { 29, 62}, { 37, 61}, { 38, 58}, { 33, 53} }; -CONST_TEXEL_TUNING EvalScore knightPairMalus = { 4, -9}; -CONST_TEXEL_TUNING EvalScore rookPairMalus = { 3,-14}; -CONST_TEXEL_TUNING EvalScore queenNearKing = {-2, 9}; +CONST_TEXEL_TUNING EvalScore doublePawnMalus[2] = {{ 23, 13 },{ 11, 17 }}; // close semiopenfile +CONST_TEXEL_TUNING EvalScore isolatedPawnMalus[2] = {{ 9, 7 },{ 17, 17 }}; // close semiopenfile +CONST_TEXEL_TUNING EvalScore backwardPawnMalus[2] = {{ 2, -3 },{ 23, -3 }}; // close semiopenfile +CONST_TEXEL_TUNING EvalScore holesMalus = { -4, 2}; +CONST_TEXEL_TUNING EvalScore pieceFrontPawn = {-14,15}; +CONST_TEXEL_TUNING EvalScore outpost = { 15,19}; +CONST_TEXEL_TUNING EvalScore centerControl = { 4, 0}; +CONST_TEXEL_TUNING EvalScore candidate[8] = { {0, 0}, { -7, 0}, {-17, 8}, { 3, 25}, { 23, 76}, { 34, 64}, { 34, 64}, { 0, 0} }; +CONST_TEXEL_TUNING EvalScore protectedPasserBonus[8]={ {0, 0}, { 24, -8}, { 14, -9}, { 26, -7}, { 1, 14}, { 36, 47}, { 7, 9}, { 0, 0} }; +CONST_TEXEL_TUNING EvalScore freePasserBonus[8] = { {0, 0}, { 14, 6}, { -6, 6}, { -7, 21}, { -9, 39}, { 6,122}, { 50,150}, { 0, 0} }; +CONST_TEXEL_TUNING EvalScore pawnMobility = { -5, 17}; +CONST_TEXEL_TUNING EvalScore pawnSafeAtt = { 59, 23}; +CONST_TEXEL_TUNING EvalScore pawnSafePushAtt = { 16, 8}; +CONST_TEXEL_TUNING EvalScore pawnlessFlank = {-18,-20}; +CONST_TEXEL_TUNING EvalScore pawnStormMalus = { 14,-20}; +CONST_TEXEL_TUNING EvalScore rookOnOpenFile = { 57, 9}; +CONST_TEXEL_TUNING EvalScore rookOnOpenSemiFileOur = { 17, 0}; +CONST_TEXEL_TUNING EvalScore rookOnOpenSemiFileOpp = { 37, 0}; + +CONST_TEXEL_TUNING EvalScore rookQueenSameFile = { 8, 3}; +CONST_TEXEL_TUNING EvalScore rookFrontQueenMalus = { -3,-29}; +CONST_TEXEL_TUNING EvalScore rookFrontKingMalus = {-14, 8}; +CONST_TEXEL_TUNING EvalScore minorOnOpenFile = { 8, 4}; + +CONST_TEXEL_TUNING EvalScore pinnedKing [5] = { { -4,-11}, { 8, 64}, {-12, 69}, {-14, 67}, {-14, 13} }; +CONST_TEXEL_TUNING EvalScore pinnedQueen[5] = { { 5, -6}, {-27, 7}, { -2, 13}, { -3, 6}, { 32, 27} }; + +CONST_TEXEL_TUNING EvalScore hangingPieceMalus = {-36,-10}; + +CONST_TEXEL_TUNING EvalScore threatByMinor[6] = { { -16,-23 },{ -20,-43 },{ -36, -32 },{ -58,-13 },{ -57, -7 },{ -62, -25 } }; +CONST_TEXEL_TUNING EvalScore threatByRook[6] = { { -1,-27 },{ -27, -9 },{ -5, -32 },{ -16, 15 },{ -74, -2 },{ -18, -38 } }; +CONST_TEXEL_TUNING EvalScore threatByQueen[6] = { { 15, 11 },{ 0, 17 },{ 21, -13 },{ 31, -4 },{ 39, 24 },{ -29, -47 } }; +CONST_TEXEL_TUNING EvalScore threatByKing[6] = { { 19,-52 },{ -9,-21 },{ 49, -60 },{ 15,-53 },{ 0, 0 },{ 0, 0 } }; + +CONST_TEXEL_TUNING EvalScore adjKnight[9] = { {-26,-20}, { -10,-3}, { 1, -2}, { 6, 3}, { -4, 16}, { 1, 23}, { 11, 42}, { 25, 56}, { 44, 29} }; +CONST_TEXEL_TUNING EvalScore adjRook[9] = { { 24,-10}, { 15, 3}, {-23, 11}, {-46, 13}, {-47, 4}, {-42, -2}, {-44, -6}, {-42, -7}, {-44, 36} }; +CONST_TEXEL_TUNING EvalScore badBishop[9] = { { -6, -5}, { -7,15}, { -8, 29}, { 0, 35}, { 6, 39}, { 13, 45}, { 19, 40}, { 21, 50}, { 39, 65} }; +CONST_TEXEL_TUNING EvalScore bishopPairBonus[9] = { { 29, 56}, { 28, 57}, { 30, 71}, { 16, 82}, { 34, 66}, { 29, 74}, { 30, 86}, { 40, 85}, { 54, 68} }; +CONST_TEXEL_TUNING EvalScore knightPairMalus = {17, 1}; +CONST_TEXEL_TUNING EvalScore rookPairMalus = {11,-14}; +CONST_TEXEL_TUNING EvalScore queenNearKing = { 0, -2}; CONST_TEXEL_TUNING EvalScore MOB[6][29] = { {{ 23,-46}, { 23, 5}, { 29, 15}, { 32, 19}, { 40, 17}, { 39, 15}, { 28, 23}, { 35, 46}, { 29, 47} }, {{-25,-34}, {-12, 10}, { -4, 22}, { 0, 28}, { 2, 31}, { 4, 33}, { 1, 33}, { 21, 19}, { 41, 22}, {45, 36}, {55, 37}, {71, 65}, {71, 56}, {120, 95} }, @@ -460,21 +459,21 @@ CONST_TEXEL_TUNING EvalScore MOB[6][29] = { {{ 23,-46}, { 23, 5}, { 29, 15}, { {{ -3,-64}, { -3,-25}, { 2,-11}, { -1, -7}, { 8,-10}, { 8, -4}, { 3, 15}, { 7, 14}, { 13, 15}, {21, 26}, { 8, 37}, {21, 43}, {25, 48}, {19, 45}, {24, 54}}, {{ 4,-17}, { -5, 31}, {-11, 41}, {-15, 46}, {-22, 48}, {-27, 40}, {-25, 43}, {-30, 40}, {-40, 23} } }; -CONST_TEXEL_TUNING EvalScore initiative[4] = {{1,5}, {58,39}, {115,64}, {71,78}}; +CONST_TEXEL_TUNING EvalScore initiative[4] = {{0,5}, {59,40}, {115,65}, {71,88}}; enum katt_att_def : unsigned char { katt_attack = 0, katt_defence = 1 }; -CONST_TEXEL_TUNING ScoreType kingAttMax = 423; -CONST_TEXEL_TUNING ScoreType kingAttTrans = 44; -CONST_TEXEL_TUNING ScoreType kingAttScale = 16; -CONST_TEXEL_TUNING ScoreType kingAttOffset = 10; -CONST_TEXEL_TUNING ScoreType kingAttWeight[2][6] = { { 64, 224, 256, 129, 289, -32}, { 160, 96, 160, -2, 31, 0} }; +CONST_TEXEL_TUNING ScoreType kingAttMax = 428; +CONST_TEXEL_TUNING ScoreType kingAttTrans = 49; +CONST_TEXEL_TUNING ScoreType kingAttScale = 11; +CONST_TEXEL_TUNING ScoreType kingAttOffset = 9; +CONST_TEXEL_TUNING ScoreType kingAttWeight[2][6] = { { 134, 230, 246, 206, 335, -33}, { 220, 156, 138, 8, -22, 0} }; CONST_TEXEL_TUNING ScoreType kingAttSafeCheck[6] = { 128, 1184, 1152, 1056, 1024, 0}; -CONST_TEXEL_TUNING ScoreType kingAttOpenfile = 192; -CONST_TEXEL_TUNING ScoreType kingAttSemiOpenfileOpp = 97; -CONST_TEXEL_TUNING ScoreType kingAttSemiOpenfileOur = 63; +CONST_TEXEL_TUNING ScoreType kingAttOpenfile = 118; +CONST_TEXEL_TUNING ScoreType kingAttSemiOpenfileOpp = 80; +CONST_TEXEL_TUNING ScoreType kingAttSemiOpenfileOur = 108; ScoreType kingAttTable[64] = {0}; -CONST_TEXEL_TUNING EvalScore tempo = {0,0}; //{27, 26}; +CONST_TEXEL_TUNING EvalScore tempo = {0,0}; //{37, 34}; double sigmoid(double x, double m = 1.f, double trans = 0.f, double scale = 1.f, double offset = 0.f){ return m / (1 + exp((trans - x) / scale)) - offset;} void initEval(){ for(Square i = 0; i < 64; i++){ EvalConfig::kingAttTable[i] = (int) sigmoid(i,EvalConfig::kingAttMax,EvalConfig::kingAttTrans,EvalConfig::kingAttScale,EvalConfig::kingAttOffset); } }// idea taken from Topple @@ -3877,7 +3876,7 @@ bool isPseudoLegal2(const Position & p, Move m) { // validate TT move if ((BBTools::mask[from].push[p.c] & p.occupancy) == empty) validPush |= BBTools::mask[from].dpush[p.c] & ~p.occupancy; if (validPush & SquareToBitboard(to)) return true; const BitBoard validCap = BBTools::mask[from].pawnAttack[p.c] & ~p.allPieces[p.c]; - if ((validCap & SquareToBitboard(to)) && (( t != T_ep && toP != P_none) || (t == T_ep && to == p.ep))) return true; + if ((validCap & SquareToBitboard(to)) && (( t != T_ep && toP != P_none) || (t == T_ep && to == p.ep && toP == P_none))) return true; return false; } if (fromPieceType != P_wk) {