shithub: moonfish

Download patch

ref: 37a2e71e1621e7584996fa035e73b71eae57ea06
parent: 9222d0b35ad2dada41fa4db9d29a6586aeba6e8e
author: zamfofex <zamfofex@twdb.moe>
date: Fri May 3 07:27:52 EDT 2024

reorder arguments for some functions

--- a/chess.c
+++ b/chess.c
@@ -486,7 +486,7 @@
 	if (name[4] == 'n') move->promotion = color | moonfish_knight;
 }
 
-void moonfish_to_uci(char *name, struct moonfish_move *move)
+void moonfish_to_uci(struct moonfish_move *move, char *name)
 {
 	int x, y;
 	
@@ -965,7 +965,7 @@
 	*fen = 0;
 }
 
-void moonfish_to_san(struct moonfish_chess *chess, char *name, struct moonfish_move *move)
+void moonfish_to_san(struct moonfish_chess *chess, struct moonfish_move *move, char *name)
 {
 	static char names[] = "NBRQK";
 	
--- a/main.c
+++ b/main.c
@@ -160,7 +160,7 @@
 				printf("score mate %d\n", moonfish_countdown(score));
 			else
 				printf("score cp %d\n", score);
-			moonfish_to_uci(name, &move);
+			moonfish_to_uci(&move, name);
 			printf("bestmove %s\n", name);
 		}
 		else if (!strcmp(arg, "quit"))
--- a/moonfish.h
+++ b/moonfish.h
@@ -78,7 +78,7 @@
 void moonfish_new(struct moonfish_analysis *analysis, struct moonfish_chess *chess);
 
 void moonfish_from_uci(struct moonfish_chess *chess, struct moonfish_move *move, char *name);
-void moonfish_to_uci(char *name, struct moonfish_move *move);
+void moonfish_to_uci(struct moonfish_move *move, char *name);
 
 int moonfish_validate(struct moonfish_chess *chess);
 int moonfish_check(struct moonfish_chess *chess);
@@ -91,7 +91,7 @@
 void moonfish_to_fen(struct moonfish_chess *chess, char *fen);
 
 int moonfish_from_san(struct moonfish_chess *chess, struct moonfish_move *move, char *name);
-void moonfish_to_san(struct moonfish_chess *chess, char *name, struct moonfish_move *move);
+void moonfish_to_san(struct moonfish_chess *chess, struct moonfish_move *move, char *name);
 
 int moonfish_move(struct moonfish_chess *chess, struct moonfish_move *move, unsigned char from, unsigned char to);
 
--- a/tools/analyse.c
+++ b/tools/analyse.c
@@ -372,7 +372,7 @@
 					arg = strtok_r(NULL, "\r\n\t ", &buffer);
 					if (arg == NULL) break;
 					moonfish_from_uci(&ply.chess, &move, arg);
-					moonfish_to_san(&ply.chess, san, &move);
+					moonfish_to_san(&ply.chess, &move, san);
 					length = strlen(san);
 					if (i + length > sizeof fancy->pv - 2) break;
 					moonfish_play(&ply.chess, &move);
@@ -832,8 +832,8 @@
 				fancy->plies[fancy->i].depth = 0;
 				fancy->plies[fancy->i].score *= -1;
 				
-				moonfish_to_uci(fancy->plies[fancy->i].name, &move);
-				moonfish_to_san(&fancy->plies[fancy->i].chess, fancy->plies[fancy->i].san, &move);
+				moonfish_to_uci(&move, fancy->plies[fancy->i].name);
+				moonfish_to_san(&fancy->plies[fancy->i].chess, &move, fancy->plies[fancy->i].san);
 				
 				moonfish_play(&fancy->plies[fancy->i].chess, &move);
 				fancy->x = 0;
--- a/tools/book.c
+++ b/tools/book.c
@@ -120,7 +120,7 @@
 			}
 			
 			moonfish_play(&chess, &move);
-			moonfish_to_uci(book[i][j++], &move);
+			moonfish_to_uci(&move, book[i][j++]);
 			
 			arg = strtok(NULL, "\r\n\t ");
 			if (arg == NULL || arg[0] == '#')
--- a/tools/chat.c
+++ b/tools/chat.c
@@ -269,7 +269,7 @@
 			continue;
 		}
 		
-		moonfish_to_uci(name, &move);
+		moonfish_to_uci(&move, name);
 		
 		names = realloc(names, strlen(names) + strlen(name) + 2);
 		if (names == NULL)
@@ -303,7 +303,7 @@
 		strcat(names, name0);
 		
 		moonfish_from_uci(&chess, &move, name0);
-		moonfish_to_san(&chess, name, &move);
+		moonfish_to_san(&chess, &move, name);
 		moonfish_play(&chess, &move);
 		moonfish_to_fen(&chess, fen);
 		
--- a/tools/lichess.c
+++ b/tools/lichess.c
@@ -188,7 +188,7 @@
 				for (;;)
 				{
 					moonfish_from_uci(&chess, &move, name);
-					moonfish_to_uci(name0, &move);
+					moonfish_to_uci(&move, name0);
 					fprintf(in, "%s", name0);
 					name = strtok(NULL, " ");
 					if (name == NULL) break;
--- a/tools/play.c
+++ b/tools/play.c
@@ -544,7 +544,7 @@
 			if (moonfish_move_from(&fancy->chess, &move, fancy->x, fancy->y, x1, y1) == 0)
 			{
 				*name++ = ' ';
-				moonfish_to_uci(name, &move);
+				moonfish_to_uci(&move, name);
 				name += strlen(name);
 				
 				pthread_mutex_lock(fancy->mutex);
--