示例#1
0
文件: eval.c 项目: kaspersky/faile
long int eval (const int white_to_move, const int white_castled, const int black_castled, const int wking_loc, const int bking_loc, int board[], int moved[], int pieces[], const int num_pieces, const long piece_count, const long start_piece_count) {

  /* select the appropriate eval() routine: */

  if (piece_count > 11) {
    return (opn_eval (white_to_move, white_castled, black_castled, wking_loc, bking_loc, board, moved, pieces, num_pieces));
  }
  else if (piece_count < 5) {
    return (end_eval (white_to_move, board, pieces, num_pieces, piece_count, start_piece_count));
  }
  else {
    return (mid_eval (white_to_move, white_castled, black_castled, wking_loc, bking_loc, board, moved, pieces, num_pieces, piece_count, start_piece_count));
  }

}
示例#2
0
文件: eval.c 项目: nmamano/Chespel
long int eval (void) {
  long int score = 0;
  /* select the appropriate eval() routine: */
  if (piece_count > 11) {
    if (_default_PStables) score = score + opn_eval_tables();
    score = score + (opn_eval() / _centipawn_value);
    return score;
  }
  else if (piece_count < 5) {
    if (_default_PStables) score = score + end_eval_tables();
    score = score + (end_eval() / _centipawn_value);
    return score;
  }
  else {
    if (_default_PStables) score = score + mid_eval_tables();
    score = score + (mid_eval() / _centipawn_value);
    return score;
  }
}
示例#3
0
文件: main.c 项目: patmanteau/iclc
int repl() {
#ifdef HAVE_READLINE
    history_truncate_file(history_filename(), 1000);
    read_history(history_filename());
#endif // HAVE_READLINE


    // Eingabeschleife als REPL(read-eval-print loop) -> Eingabe, Verarbeitung, Ausgabe
    do {
        char *user_input = NULL;
        //////////////////////
        // read
        //////////////////////

#ifdef HAVE_READLINE
        user_input = readline("?: ");
        
        if (!user_input) break;
        strim(user_input);

        if (*user_input) add_history(user_input);
#else
        // Eingabepuffer als "String" mit Maximallänge
        user_input = calloc(LINE_BUFFER_SIZE, sizeof(char));
        printf("?: ");
        // Bei end-of-file oder Lesefehler gibt fgets NULL zurück
        // und das Programm soll beendet werden (analog zur Shell)
        //
        // break ist eigentlich nicht schön (=nicht im Struktogramm
        // abbildbar ;) ), dient aber hier der Klarheit, da einige
        // if entfallen können
        if (!fgets(user_input, LINE_BUFFER_SIZE, stdin)) break;
        strim(user_input);
#endif // HAVE_READLINE
        
        //////////////////////
        // eval
        //////////////////////
        
        // Abbruch durch User?
        if (strcmp(user_input, "\\quit") == 0) break;

        // 1. Parsen
        parse_context *p_ctx = start_parse(user_input);

        // 2. Baum traversieren
        if (parse(p_ctx) == 0) {
            eval_context *e_ctx = eval(p_ctx->ast_root);
            if (e_ctx == NULL) fprintf(stderr, "Fatal evaluation error.\n");
            if (e_ctx->success) {
                //////////////////////
                // print
                //////////////////////
                printf("-> %.50Lg\n", e_ctx->result);
            } else {
                print_eval_errors(e_ctx);
            }
            end_eval(e_ctx);
        } else {
            print_parse_errors(p_ctx);
        }
        // Aufräumen
        end_parse(p_ctx);
        free(user_input);
    } while (1); // loop....

#ifdef HAVE_READLINE
    write_history(history_filename());
#endif // HAVE_READLINE

    printf("End.\n");
    return 0;
}