ref: 2e051ff4bf5c6373c335ffd8c21d27ea4b9176cf
parent: 9ea4043307d508c1b82ae7e358177f4587f988ef
author: zamfofex <zamfofex@twdb.moe>
date: Tue Jan 7 02:03:10 EST 2025
make small style changes
--- a/chess.c
+++ b/chess.c
@@ -82,15 +82,10 @@
static int moonfish_attacked(struct moonfish_chess *chess, int from, int to)
{- int piece;
struct moonfish_chess other;
-
- if (chess->white) piece = moonfish_white_king;
- else piece = moonfish_black_king;
-
other = *chess;
other.board[from] = moonfish_empty;
- other.board[to] = piece;
+ other.board[to] = chess->white ? moonfish_white_king : moonfish_black_king;
return moonfish_check(&other);
}
@@ -98,7 +93,7 @@
{int to;
- if (!chess->ooo[1 - chess->white]) return;
+ if (!chess->ooo[chess->white ^ 1]) return;
to = from - 3;
while (to != from) {@@ -118,7 +113,7 @@
{int to;
- if (!chess->oo[1 - chess->white]) return;
+ if (!chess->oo[chess->white ^ 1]) return;
to = from + 2;
while (to != from) {@@ -261,10 +256,12 @@
int i, count;
struct moonfish_move moves[32];
+#ifndef moonfish_mini
if (name[0] < 'a' || name[0] > 'h') return 1;
if (name[1] < '1' || name[1] > '8') return 1;
if (name[2] < 'a' || name[2] > 'h') return 1;
if (name[3] < '1' || name[3] > '8') return 1;
+#endif
x0 = name[0] - 'a';
y0 = name[1] - '1';
@@ -279,10 +276,12 @@
if (name[4] == 'n') type = moonfish_knight;
if (type == moonfish_empty) return 1;
+#ifndef moonfish_mini
if (type == moonfish_king && x0 == 4) {if (x1 == 0) x1 = 2;
if (x1 == 7) x1 = 6;
}
+#endif
from = (x0 + 1) + (y0 + 2) * 10;
to = (x1 + 1) + (y1 + 2) * 10;
--- a/moonfish.h
+++ b/moonfish.h
@@ -29,7 +29,7 @@
/* whereas the pieces closest to black have a higher index */
/* this makes so that the board is flipped when displayed naively! (be careful) */
-/* the board is not just an 8 x 8 array because of an optisation that is performed when generating moves */
+/* the board is not just an 8 x 8 array because of an optimisation that is performed when generating moves */
/* ~ ~ ~ ~ ~ */
--- a/search.c
+++ b/search.c
@@ -85,7 +85,7 @@
static short int moonfish_score(struct moonfish_chess *chess)
{- static int phases[] = {0, 1, 1, 2, 4, 0};+ static int values[] = {0, 1, 1, 2, 4, 0};int x, y;
int x1, y1;
@@ -118,7 +118,7 @@
score0 -= moonfish_values0[i] * (color * 2 - 1);
score1 -= moonfish_values1[i] * (color * 2 - 1);
- phase += phases[type];
+ phase += values[type];
}
}
@@ -506,13 +506,13 @@
return root;
}
+#ifndef moonfish_mini
+
void moonfish_finish(struct moonfish_root *root)
{moonfish_discard(&root->node);
free(root);
}
-
-#ifndef moonfish_mini
void moonfish_stop(struct moonfish_root *root)
{--
⑨