<commit_before>#include "board.h"
#include "pieces.h"
#include "check.h"

int in_check(int player)
{
    square key;
    int is_in_check;
    register int file, rank;

    key = '\0';
    switch (player)
    {
    case WHITE:
        key = WHITE_KING;
        break;
    case BLACK:
        key = BLACK_KING;
        break;
    default:
        return -1;
    }

    rank = file = -1;
    while (++rank < BOARD_SIZE)
        while (++file < BOARD_SIZE)
            if (board[rank][file] == key)
                break;
    if (file >= BOARD_SIZE || rank >= BOARD_SIZE)
        return -1; /* no King found--cannot interpret King safety */

    is_in_check  = 0;
    is_in_check |= test_King(file, rank);
    is_in_check |= test_rook(file, rank);
    is_in_check |= test_knight(file, rank);
    is_in_check |= test_pawn(file, rank);
    is_in_check |= test_bishop(file, rank);
    is_in_check |= test_Queen(file, rank);
    return (is_in_check);
}

int get_player_by_square(int file, int rank)
{
    switch (board[rank][file])
    {
    case WHITE_KING:
    case WHITE_QUEEN:
    case WHITE_ROOK:
    case WHITE_BISHOP:
    case WHITE_KNIGHT:
    case WHITE_PAWN:<commit_msg>fixed severe bug with king search loop scope in check analysis<commit_after>#include "board.h"
#include "pieces.h"
#include "check.h"

int in_check(int player)
{
    square key;
    int is_in_check;
    register int file, rank;

    key = '\0';
    switch (player)
    {
    case WHITE:
        key = WHITE_KING;
        break;
    case BLACK:
        key = BLACK_KING;
        break;
    default:
        return -1;
    }

    rank = file = -1;
    while (++rank < BOARD_SIZE)
        while (++file < BOARD_SIZE)
            if (board[rank][file] == key)
                goto king_search_finished;

king_search_finished:
    if (file >= BOARD_SIZE || rank >= BOARD_SIZE)
        return -1; /* no King found--cannot interpret King safety */

    is_in_check  = 0;
    is_in_check |= test_King(file, rank);
    is_in_check |= test_rook(file, rank);
    is_in_check |= test_knight(file, rank);
    is_in_check |= test_pawn(file, rank);
    is_in_check |= test_bishop(file, rank);
    is_in_check |= test_Queen(file, rank);
    return (is_in_check);
}

int get_player_by_square(int file, int rank)
{
    switch (board[rank][file])
    {
    case WHITE_KING:
    case WHITE_QUEEN:
    case WHITE_ROOK:
    case WHITE_BISHOP:
    case WHITE_KNIGHT:
    case WHITE_PAWN:
{'fraction_non_alphanumeric': 0.11535303776683087, 'fraction_numerical': 0.004105090311986864, 'mean_word_length': 2.4814285714285713, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4339254', 'n_tokens_mistral': 896, 'n_tokens_neox': 871, 'n_words': 213}