ref: 7a1b95f35a97d9dc73ce866c93ef7c0bf5389746
parent: 2169d2bd3e0c2292f0bb58e2e12d30c1b859ec70
author: zamfofex <zamfofex@twdb.moe>
date: Sat Nov 30 07:28:56 EST 2024
improve search
--- a/search.c
+++ b/search.c
@@ -93,9 +93,8 @@
static void moonfish_discard(struct moonfish_node *node)
{int i;
- if (node->count == 0) return;
for (i = 0 ; i < node->count ; i++) moonfish_discard(node->children + i);
- free(node->children);
+ if (node->count > 0) free(node->children);
}
static void moonfish_node(struct moonfish_node *node)
@@ -123,6 +122,12 @@
int child_count;
struct moonfish_move moves[32];
+ if (node->count == -2) return;
+ if (moonfish_finished(chess)) {+ node->count = -2;
+ return;
+ }
+
node->children = NULL;
child_count = 0;
@@ -198,8 +203,6 @@
if (n == -2) break;
#endif
- if (moonfish_finished(chess)) node->count = -2;
-
next = NULL;
max_confidence = -1;
@@ -297,16 +300,11 @@
for (i = 0 ; i < count ; i++) {chess = *chess0;
leaf = moonfish_select(node, &chess);
- if (leaf->count == -2) {- leaf->score = 0;
- moonfish_propagate(leaf);
- if (moonfish_checkmate(&chess)) {- moonfish_propagate_bounds(leaf, 1);
- }
- continue;
- }
moonfish_expand(leaf, &chess);
moonfish_propagate(leaf);
+ if (leaf->count == -2 && moonfish_check(&chess)) {+ moonfish_propagate_bounds(leaf, 1);
+ }
}
}
--
⑨