diff --git a/src/search.cpp b/src/search.cpp index 1be92798..ecfc6018 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -124,7 +124,7 @@ int Search::qsearch(int depth, int alpha, int beta, int ply) { // assign a value to each move for (int i = 0; i < ml.size; i++) { - ml.list[i].value = mmlva(ml.list[i]); + ml.list[i].value = score_qmove(ml.list[i]); } // sort the moves @@ -297,8 +297,6 @@ int Search::absearch(int depth, int alpha, int beta, int ply, Stack *ss) { board.makeMove(move); - - U64 nodeCount = nodes; ss->currentmove = move.get(); bool givesCheck = board.isSquareAttacked(color, board.KingSQ(~color)); @@ -559,6 +557,18 @@ int Search::score_move(Move& move, int ply, bool ttMove) { } } +int Search::score_qmove(Move& move) { + if (move.promoted()) { + return 2147483647 - 20 + move.piece(); + } + else if (board.pieceAtB(move.to()) != None) { + return see(move, -100) ? mmlva(move) * 10000 : mmlva(move); + } + else { + return 0; + } +} + std::string Search::get_pv() { std::string line = ""; for (int i = 0; i < pv_length[0]; i++) { diff --git a/src/search.h b/src/search.h index 9921358c..e14bfd2e 100644 --- a/src/search.h +++ b/src/search.h @@ -52,6 +52,7 @@ class Search { bool see(Move& move, int threshold); int mmlva(Move& move); int score_move(Move& move, int ply, bool ttMove); + int score_qmove(Move& move); std::string get_pv(); bool store_entry(U64 index, int depth, int bestvalue, int old_alpha, int beta, U64 key, uint8_t ply); void uci_output(int score, int depth, int time);