shithub: moonfish

Download patch

ref: d83ca33453bfdc474b0d7caf0e8f01886079a98c
parent: e475abcb1367ff05b438c580c3aa63e5befbe345
author: zamfofex <zamfofex@twdb.moe>
date: Thu Nov 21 03:31:00 EST 2024

make small fixes to SAN parsing

--- a/chess.c
+++ b/chess.c
@@ -485,10 +485,18 @@
 			for (i = 0 ; i < count ; i++) {
 				
 				if (chess->board[moves[i].from] % 16 != type) continue;
-				if (captured && chess->board[moves[i].to] == moonfish_empty) continue;
 				if (promotion && promotion != moves[i].chess.board[moves[i].to] % 16) continue;
 				if (moves[i].to % 10 != x1) continue;
 				if (moves[i].to / 10 - 1 != y1) continue;
+				
+				if (captured) {
+					if (chess->board[moves[i].from] % 16 == moonfish_pawn) {
+						if (moves[i].from % 10 == moves[i].to % 10) continue;
+					}
+					else {
+						if (chess->board[moves[i].to] == moonfish_empty) continue;
+					}
+				}
 				
 				if (!moonfish_validate(&moves[i].chess)) continue;
 				if (check && !moonfish_check(chess)) continue;
--- a/tools/pgn.c
+++ b/tools/pgn.c
@@ -40,7 +40,7 @@
 
 static int moonfish_isalnum(int ch)
 {
-	if (ch == '-' || ch == '_' || ch == '/') return 1;
+	if (ch == '-' || ch == '_' || ch == '/' || ch == '=') return 1;
 	if (isalnum(ch)) return 1;
 	return 0;
 }
--