summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}
}