shithub: moonfish

Download patch

ref: 9fb51118ad6a2d62c77f4ae51c9a57f7dbc4def6
parent: 1a7e19ead4da96e8994df291a084fcf1f12dd568
author: zamfofex <zamfofex@twdb.moe>
date: Tue Dec 12 23:21:05 EST 2023

fix PST evaluation and search

--- a/chess.c
+++ b/chess.c
@@ -284,6 +284,8 @@
 	type = (piece & 0xF) - 1;
 	color = (piece >> 4) - 1;
 	
+	if (color == 0) y = 7 - y;
+	
 	if (x < 4) x = 4 - x;
 	else x %= 4;
 	
--- a/search.c
+++ b/search.c
@@ -24,14 +24,12 @@
 	
 	if (depth <= 0)
 	{
-		if (depth <= -4)
-		{
-			if (chess->white) return chess->score;
-			else return -chess->score;
-		}
+		score = chess->score;
+		if (!chess->white) score *= -1;
 		
+		if (depth <= -4) return score;
 		if (chess->score >= beta) return beta;
-		if (chess->score > alpha) alpha = chess->score;
+		if (chess->score > alpha) alpha = score;
 	}
 	
 	for (y = 0 ; y < 8 ; y++)
--