diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-08-30 23:32:20 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-08-30 23:52:29 +0300 |
commit | 77c25a994fea0b01a51668feca4e04b1762d98b4 (patch) | |
tree | 0185376c8881e669594cd7aacdd3973fad48e031 | |
parent | ff0593e32a5f08f4f716f3660d95c9a1f10fbfe5 (diff) | |
download | c-chess-77c25a994fea0b01a51668feca4e04b1762d98b4.tar.gz |
feat!: account for mobility instead of coverage
-rw-r--r-- | src/main.c | 25 |
1 files changed, 9 insertions, 16 deletions
@@ -351,19 +351,19 @@ int compute_material_advantage(int* board, int color) { counter += evaluate_pawn(piece, rank) * sign; break; case KNIGHT: - counter += 3 * sign; + counter += 30 * sign; break; case BISHOP: - counter += 3 * sign; + counter += 30 * sign; break; case ROOK: - counter += 4 * sign; + counter += 45 * sign; break; case QUEEN: - counter += 9 * sign; + counter += 90 * sign; break; default: - counter += 1 * sign; + counter += 0 * sign; break; } } @@ -487,16 +487,9 @@ int compute_positioning_score(int* board, int color) { * for WHITE, meaining WHITE tries to maximize this * value and BLACK tries to minimize it. */ -int compute_score(int* board) { +int compute_score(int* board, int mobility) { int material_advantage = compute_material_advantage(board, WHITE); - - int coverage_score = compute_coverage(board, WHITE) - compute_coverage(board, BLACK); - int normalized_coverage = coverage_score / 2; - - int positioning_score = compute_positioning_score(board, WHITE) - compute_positioning_score(board, BLACK); - int normalized_positioning = positioning_score / 7; - - return 3 * material_advantage + coverage_score + positioning_score; + return material_advantage + mobility; } int list_available_moves(Move* moves, int* board, int color) { @@ -583,7 +576,7 @@ Move find_best_move(int* board, int color, int depth, int alpha, int beta, int* move.value = depth < MAX_DEPTH ? find_best_move(board, 1 - color, depth + 1, alpha, beta, metrics).value - : compute_score(board); + : compute_score(board, color == WHITE ? availabel_moves_count : -availabel_moves_count); reverse_move(move, captured_piece, board); @@ -613,7 +606,7 @@ int main() { while (1) { if (color == PLAYER) { - printf("Current score is %i\n", compute_score(board)); + // printf("Current score is %i\n", compute_score(board)); printf("White coverage: %i, black coverage: %i\n", compute_coverage(board, WHITE), compute_coverage(board, BLACK)); printf("Enter a move for %s:\n", COLORS[color]); move = input_move(); |