ref: cf02115762da42294a526181433a2acbe1cbc0df
parent: 064bf1d47185e98e4defe6199befbc1d80c3b39b
author: zamfofex <zamfofex@twdb.moe>
date: Thu Nov 28 07:51:20 EST 2024
make small threading fix
--- a/search.c
+++ b/search.c
@@ -189,13 +189,16 @@
for (;;) {#ifdef moonfish_no_threads
- if (node->count == 0) break;
+ if (node->count <= 0) break;
#else
n = 0;
if (atomic_compare_exchange_strong(&node->count, &n, -1)) break;
if (n == -1) continue;
+ if (n == -2) break;
#endif
+ if (moonfish_finished(chess)) node->count = -2;
+
next = NULL;
max_confidence = -1;
@@ -293,13 +296,12 @@
for (i = 0 ; i < count ; i++) {chess = *chess0;
leaf = moonfish_select(node, &chess);
- if (moonfish_finished(&chess)) {+ if (leaf->count == -2) {leaf->score = 0;
moonfish_propagate(leaf);
if (moonfish_checkmate(&chess)) {moonfish_propagate_bounds(leaf, 1);
}
- leaf->count = 0;
continue;
}
moonfish_expand(leaf, &chess);
--
⑨