shithub: moonfish

Download patch

ref: d37505170634ba4610cfba72e663c6fe4a10c266
parent: 36c08442df593bd6d90ed9c296786defc6bbe841
author: zamfofex <zamfofex@twdb.moe>
date: Tue Jan 9 12:20:43 EST 2024

add depth reporting information

--- a/main.c
+++ b/main.c
@@ -96,11 +96,11 @@
 			if (depth >= 0)
 				score = moonfish_best_move_depth(ctx, &move, depth);
 			else if (ctx->chess.white)
-				score = moonfish_best_move_time(ctx, &move, wtime, btime);
+				score = moonfish_best_move_time(ctx, &move, &depth, wtime, btime);
 			else
-				score = moonfish_best_move_time(ctx, &move, btime, wtime);
+				score = moonfish_best_move_time(ctx, &move, &depth, btime, wtime);
 			
-			printf("info depth 1 ");
+			printf("info depth %d ", depth);
 			if (score >= moonfish_omega || score <= -moonfish_omega)
 				printf("score mate %d\n", moonfish_countdown(score));
 			else
--- a/moonfish.h
+++ b/moonfish.h
@@ -75,7 +75,7 @@
 void moonfish_unplay(struct moonfish_chess *chess, struct moonfish_move *move);
 
 int moonfish_best_move_depth(struct moonfish *ctx, struct moonfish_move *move, int depth);
-int moonfish_best_move_time(struct moonfish *ctx, struct moonfish_move *move, long int our_time, long int their_time);
+int moonfish_best_move_time(struct moonfish *ctx, struct moonfish_move *move, int *depth, long int our_time, long int their_time);
 int moonfish_countdown(int score);
 
 void moonfish_move(struct moonfish_chess *chess, struct moonfish_move *move, unsigned char from, unsigned char to);
--- a/search.c
+++ b/search.c
@@ -345,11 +345,10 @@
 
 #endif
 
-int moonfish_best_move_time(struct moonfish *ctx, struct moonfish_move *best_move, long int our_time, long int their_time)
+int moonfish_best_move_time(struct moonfish *ctx, struct moonfish_move *best_move, int *i, long int our_time, long int their_time)
 {
 	long int d, t, t0, t1;
 	int score;
-	int i;
 	int init;
 	int r;
 	
@@ -361,17 +360,17 @@
 	if (d < 0) d = 0;
 	d += our_time / 8;
 	
-	for (i = 3 ; i < 32 ; i++)
+	for (*i = 1 ; *i < 32 ; (*i)++)
 	{
 		t0 = moonfish_clock(ctx);
-		score = moonfish_iteration(ctx, best_move, i, &init);
-		t1 = moonfish_clock(ctx);
+		score = moonfish_iteration(ctx, best_move, *i, &init);
+		t1 = moonfish_clock(ctx) + 50;
 		
 		r = (t1 - t0) / (t + 1);
 		t = t1 - t0;
 		
-		if (t * r > d) break;
 		d -= t;
+		if (t * r > d) break;
 	}
 	
 	return score;
--