ref: acfa5d7f549a2b34e7f78a83f3bc853c84d623c7
parent: ecb181c33f800ffd1e2b144d57f65dc475d578fb
author: zamfofex <zamfofex@twdb.moe>
date: Sat Dec 7 18:44:53 EST 2024
improve minification
--- a/chess.c
+++ b/chess.c
@@ -349,6 +349,51 @@
return 1;
}
+int moonfish_finished(struct moonfish_chess *chess)
+{+ struct moonfish_move moves[32];
+ int x, y;
+ int i, count;
+
+ for (y = 0 ; y < 8 ; y++) {+ for (x = 0 ; x < 8 ; x++) {+ count = moonfish_moves(chess, moves, (x + 1) + (y + 2) * 10);
+ for (i = 0 ; i < count ; i++) {+ if (moonfish_validate(&moves[i].chess)) return 0;
+ }
+ }
+ }
+
+ return 1;
+}
+
+int moonfish_equal(struct moonfish_chess *a, struct moonfish_chess *b)
+{+ int x, y, i;
+
+ if (a->white != b->white) return 0;
+ if (a->passing != b->passing) return 0;
+ if (a->oo[0] != b->oo[0]) return 0;
+ if (a->oo[1] != b->oo[1]) return 0;
+ if (a->ooo[0] != b->ooo[0]) return 0;
+ if (a->ooo[1] != b->ooo[1]) return 0;
+
+ for (y = 0 ; y < 8 ; y++) {+ for (x = 0 ; x < 8 ; x++) {+ i = (x + 1) + (y + 2) * 10;
+ if (a->board[i] != b->board[i]) {+ return 0;
+ }
+ }
+ }
+
+ return 1;
+}
+
+#ifndef moonfish_mini
+
+#include <string.h>
+
int moonfish_from_fen(struct moonfish_chess *chess, char *fen)
{int x, y;
@@ -436,56 +481,11 @@
return 0;
}
-int moonfish_finished(struct moonfish_chess *chess)
-{- struct moonfish_move moves[32];
- int x, y;
- int i, count;
-
- for (y = 0 ; y < 8 ; y++) {- for (x = 0 ; x < 8 ; x++) {- count = moonfish_moves(chess, moves, (x + 1) + (y + 2) * 10);
- for (i = 0 ; i < count ; i++) {- if (moonfish_validate(&moves[i].chess)) return 0;
- }
- }
- }
-
- return 1;
-}
-
int moonfish_checkmate(struct moonfish_chess *chess)
{if (!moonfish_check(chess)) return 0;
return moonfish_finished(chess);
}
-
-int moonfish_equal(struct moonfish_chess *a, struct moonfish_chess *b)
-{- int x, y, i;
-
- if (a->white != b->white) return 0;
- if (a->passing != b->passing) return 0;
- if (a->oo[0] != b->oo[0]) return 0;
- if (a->oo[1] != b->oo[1]) return 0;
- if (a->ooo[0] != b->ooo[0]) return 0;
- if (a->ooo[1] != b->ooo[1]) return 0;
-
- for (y = 0 ; y < 8 ; y++) {- for (x = 0 ; x < 8 ; x++) {- i = (x + 1) + (y + 2) * 10;
- if (a->board[i] != b->board[i]) {- return 0;
- }
- }
- }
-
- return 1;
-}
-
-#ifndef moonfish_mini
-
-#include <string.h>
static int moonfish_match_move(struct moonfish_chess *chess, struct moonfish_move *move, unsigned char type, unsigned char promotion, int x0, int y0, int x1, int y1, int check, int captured)
{--- a/moonfish.h
+++ b/moonfish.h
@@ -108,6 +108,8 @@
int score;
};
+#ifndef moonfish_mini
+
/* initialises the position and sets up the initial position */
/* note: this must be called *first* even if you want to use "moonfish_from_fen" */
void moonfish_chess(struct moonfish_chess *chess);
@@ -200,5 +202,7 @@
/* requests to stop searching the given state (from a different thread) */
void moonfish_stop(struct moonfish_root *root);
void moonfish_unstop(struct moonfish_root *root);
+
+#endif
#endif
--
⑨