Skip to content

Commit a27be98

Browse files
authored
3.6.2: optimize sort (#311)
Elo | 25.11 +- 7.23 (95%) SPRT | 10.0+0.10s Threads=1 Hash=8MB LLR | 2.97 (-2.94, 2.94) [0.00, 3.00] Games | N: 2772 W: 843 L: 643 D: 1286 Penta | [11, 272, 645, 422, 36] http://chess.grantnet.us/test/39241/ Elo | 5.19 +- 2.93 (95%) SPRT | 60.0+0.60s Threads=1 Hash=64MB LLR | 2.96 (-2.94, 2.94) [0.00, 3.00] Games | N: 13334 W: 3419 L: 3220 D: 6695 Penta | [22, 1459, 3506, 1658, 22] http://chess.grantnet.us/test/39242/ bench: 1177845
1 parent 9b44a1a commit a27be98

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/moveeval.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,21 @@ const EVAL SORT_VALUE[14] = { 0, 0, VAL_P, VAL_P, VAL_N, VAL_N, VAL_B, VAL_B, VA
100100
if (i == 0 && mvlist[0].m_score == s_SortHash)
101101
return mvlist[0].m_mv;
102102

103-
auto mvSize = mvlist.Size();
104-
for (size_t j = i + 1; j < mvSize; ++j)
105-
{
106-
if (mvlist[j].m_score > mvlist[i].m_score)
107-
std::swap(mvlist[i], mvlist[j]);
103+
size_t best_idx = i;
104+
int best_score = mvlist[i].m_score;
105+
106+
// find the move with the highest score
107+
for (size_t j = i + 1; j < mvlist.Size(); ++j) {
108+
if (mvlist[j].m_score > best_score) {
109+
best_idx = j;
110+
best_score = mvlist[j].m_score;
111+
}
108112
}
113+
114+
// if we found a better move, do a single swap
115+
if (best_idx != i)
116+
std::swap(mvlist[i], mvlist[best_idx]);
117+
109118
return mvlist[i].m_mv;
110119
}
111120

src/uci.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <iostream>
3232
#include <sstream>
3333

34-
const std::string VERSION = "3.6.1";
34+
const std::string VERSION = "3.6.2";
3535
const std::string ARCHITECTURE = " 64 "
3636

3737
#if _BTYPE==0

0 commit comments

Comments
 (0)