int threads_get_and_print_results(pthread_t* threads, int threads_amount,
                                  char* location, char* prefix) {

    int i;
    thread_return* ret_data;

    print_result_header();

    for (i = 0; i < threads_amount; i++) {

        if (pthread_join(threads[i], (void*) &ret_data) != 0) {
            printf("%d - Error en finalizacion de thread %lu.\n", i + 1,
                   threads[i]); //TODO: Emprolijar y desacomplar
            continue;
        }

        if (ret_data->retcode != SUCCESS) {
            printf("%d - El thread %lu termino con error.\n", i + 1, threads[i]); //TODO: Emprolijar y desacomplar
            continue;
        }

        print_result_line(ret_data, i + 1, location, prefix);

        release_thread_retdata(ret_data);

    }

    print_result_trailer();

    return SUCCESS;

}
Exemple #2
0
static void
print_current_result(struct engine_result res)
{
    mtx_lock(&game_mutex);
    mtx_lock(&stdout_mutex);

    if (is_xboard) {
        printf("%u ", res.depth);
        if (res.sresult.value < - mate_value)
            printf("%d ",
                   -100000 - (res.sresult.value + max_value) / 2);
        else if (res.sresult.value > mate_value)
            printf("%d ",
                   100000 + (max_value - res.sresult.value) / 2);
        else
            printf("%d ", res.sresult.value);
        printf("%ju ", res.time_spent);
        printf("%ju ", res.sresult.node_count);
    }
    else if (is_uci) {
        printf("info depth %u ", res.depth);
        printf("seldepth %u ", res.sresult.selective_depth);
        if (res.sresult.value < - mate_value)
            printf("score mate -%d ",
                   (res.sresult.value + max_value) / 2);
        else if (res.sresult.value > mate_value)
            printf("score mate %d ",
                   (max_value - res.sresult.value) / 2);
        else
            printf("score cp %d ", res.sresult.value);
        printf("nodes %ju ", res.sresult.node_count);
    }
    else {
        if (res.first)
            print_result_header();
        putchar(' ');
        print_depth(res);
        putchar('\t');
        printf("%ju.%.2ju", res.time_spent / 100, res.time_spent % 100);
        putchar('\t');
        if (res.sresult.value < - mate_value)
            printf("-#%d", (res.sresult.value + max_value) / 2);
        else if (res.sresult.value > mate_value)
            printf("#%d", (max_value - res.sresult.value) / 2);
        else
            print_centipawns(res.sresult.value);
        putchar('\t');
        if (verbose)
            print_verbose_search_info(res);
        (void) print_nice_count(res.sresult.node_count);
        printf("N\t");
        (void) print_nice_count(res.sresult.qnode_count);
        printf("N\t");
    }

    if (is_uci)
        printf("pv ");
    print_move_path(game, res.pv, conf->move_not);
    putchar('\n');

    mtx_unlock(&stdout_mutex);
    mtx_unlock(&game_mutex);
}