summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-08-30 23:13:50 +0300
committereug-vs <eugene@eug-vs.xyz>2022-08-30 23:13:50 +0300
commitff0593e32a5f08f4f716f3660d95c9a1f10fbfe5 (patch)
treeef0058cea66192d9db5be52582c0f420c2734a67
parentb99cda9530a54e459eb49b50cf1922b38c7432ec (diff)
downloadc-chess-ff0593e32a5f08f4f716f3660d95c9a1f10fbfe5.tar.gz
fix: compute positioning for color
-rw-r--r--src/main.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/main.c b/src/main.c
index 4471c37..f8592dc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -452,29 +452,30 @@ int compute_positioning_score(int* board, int color) {
for (double file = 0; file < 8; file++) {
int index = rank * 16 + file;
int piece = board[index];
- int score = 7 - (fabs(rank - center) + fabs(file - center));
+ if (piece % 2 == color) {
+ int score = 7 - (fabs(rank - center) + fabs(file - center));
- int multiplier = 1;
- switch (piece & NO_COLOR) {
- case KNIGHT:
- multiplier = 4;
- break;
- case BISHOP:
- multiplier = 3;
- break;
- case PAWN:
- multiplier = 2;
- break;
- case KING:
- multiplier = -5; // Discourage king in center (encourage castle)
- // TODO: encourage king in center after opponent has low material <= 6
- break;
- default:
- multiplier = 1;
- break;
+ int multiplier = 1;
+ switch (piece & NO_COLOR) {
+ case KNIGHT:
+ multiplier = 4;
+ break;
+ case BISHOP:
+ multiplier = 3;
+ break;
+ case PAWN:
+ multiplier = 2;
+ break;
+ case KING:
+ multiplier = -5; // Discourage king in center (encourage castle)
+ // TODO: encourage king in center after opponent has low material <= 6
+ break;
+ default:
+ multiplier = 1;
+ break;
+ }
+ total_score += score * multiplier;
}
-
- total_score += score * multiplier;
}
}