diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-08-31 01:02:11 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-08-31 01:02:11 +0300 |
commit | fa5d16da163a2434e92d6db745bf44ff51e254ca (patch) | |
tree | c31d1dc59db14961c7be729eb04c06ef9dc676af | |
parent | 707a6261673b09b13709d7c2cf266471b881674c (diff) | |
download | c-chess-fa5d16da163a2434e92d6db745bf44ff51e254ca.tar.gz |
feat: cleanup logs
-rw-r--r-- | src/main.c | 78 |
1 files changed, 5 insertions, 73 deletions
@@ -372,72 +372,6 @@ int compute_material_advantage(int* board, int color) { return counter; } -/* - * Calculate amount of squares attack by players pieces - * Returns number in range (0, 64) - */ -int compute_coverage(int* board, int color) { - int hit_map[128]; - for (int rank = 7; rank >= 0; rank--) { - for (int file = 0; file < 8; file++) { - hit_map[rank * 16 + file] = 0; - } - } - - for (int rank = 7; rank >= 0; rank--) { - for (int file = 0; file < 8; file++) { - int origin = rank * 16 + file; - int piece = board[origin]; - if (piece != EMPTY && piece % 2 == color) { - int* legal_move; - switch (piece & NO_COLOR) { - case KNIGHT: - legal_move = knightMoves; - break; - case BISHOP: - legal_move = bishopMoves; - break; - case ROOK: - legal_move = rookMoves; - break; - case QUEEN: - legal_move = queenMoves; - break; - case KING: - legal_move = kingMoves; - break; - case PAWN: - if (piece & BLACK) legal_move = blackPawnAttackMoves; - else legal_move = pawnAttackMoves; - break; - default: - break; - } - - while(*legal_move) { - for (int square = origin + *legal_move; !(square & 0x88); square += *legal_move) { - hit_map[square] = 1; - int target_piece = board[square]; - - if (target_piece != EMPTY) break; - if ((piece & NO_COLOR) == PAWN || (piece & NO_COLOR) == KNIGHT || (piece & NO_COLOR) == KING) break; - } - legal_move++; - } - } - } - } - - int counter = 0; - for (int rank = 7; rank >= 0; rank--) { - for (int file = 0; file < 8; file++) { - counter += hit_map[rank * 16 + file]; - } - } - - return counter; -} - int list_available_moves(Move* moves, int* board, int color) { int moves_count = 0; @@ -568,8 +502,6 @@ int main() { while (1) { if (color == PLAYER) { - // 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(); } else { @@ -580,6 +512,11 @@ int main() { move = find_best_move(board, color, 0, -INFINITY, +INFINITY, &metrics); end = clock(); printf("[%i positions analyzed in %f seconds]\n", metrics, (double)(end - start) / CLOCKS_PER_SEC); + + char move_in_notation[] = "xy XY"; + index_to_notation(move.origin, move_in_notation); + index_to_notation(move.destination, move_in_notation + 3); + printf("%s: %s with score %i in #%i moves\n", COLORS[color], move_in_notation, move.value, MAX_DEPTH); } int error = validate_move(move, color, board); @@ -593,11 +530,6 @@ int main() { print_board(board); - char move_in_notation[] = "xy XY"; - index_to_notation(move.origin, move_in_notation); - index_to_notation(move.destination, move_in_notation + 3); - printf("%s: %s with score %i in #%i moves\n", COLORS[color], move_in_notation, move.value, MAX_DEPTH); - color ^= 1; } } |