shithub: moonfish

Download patch

ref: 84b5cfe4a187f48ec80123dea6ef8bbb2fdc2bba
parent: e99b05234836f9b02d998e6e78c6655c38ae1c8f
author: zamfofex <zamfofex@twdb.moe>
date: Tue Nov 14 17:29:25 EST 2023

fix search

--- a/search.c
+++ b/search.c
@@ -109,14 +109,7 @@
 	for (x = 0 ; x < 8 ; x++)
 	{
 		moonfish_moves(&ctx->chess, moves, (x + 1) + (y + 2) * 10);
-		while (moves->piece != moonfish_outside)
-		{
-			moonfish_play(&ctx->chess, moves);
-			if (moonfish_validate(&ctx->chess))
-				moonfish_unplay(&ctx->chess, moves++);
-			else
-				moonfish_unplay(&ctx->chess, moves);
-		}
+		while (moves->piece != moonfish_outside) moves++;
 	}
 	
 	moves = move_array;
@@ -125,6 +118,12 @@
 	{
 		moonfish_play(&ctx->chess, moves);
 		
+		if (!moonfish_validate(&ctx->chess))
+		{
+			moonfish_unplay(&ctx->chess, moves++);
+			continue;
+		}
+		
 		infos[i].move = *moves;
 		infos[i].chess = ctx->chess;
 		infos[i].depth = depth;
@@ -148,6 +147,7 @@
 				result = pthread_join(infos[j].thread, NULL);
 				if (result)
 				{
+					fprintf(stderr, "%s: %s\n", ctx->argv0, strerror(result));
 					exit(1);
 				}
 				
--