diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-08-30 23:13:50 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-08-30 23:13:50 +0300 |
commit | ff0593e32a5f08f4f716f3660d95c9a1f10fbfe5 (patch) | |
tree | ef0058cea66192d9db5be52582c0f420c2734a67 | |
parent | b99cda9530a54e459eb49b50cf1922b38c7432ec (diff) | |
download | c-chess-ff0593e32a5f08f4f716f3660d95c9a1f10fbfe5.tar.gz |
fix: compute positioning for color
-rw-r--r-- | src/main.c | 43 |
1 files changed, 22 insertions, 21 deletions
@@ -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; } } |