コード例 #1
0
ファイル: main.c プロジェクト: nate1001/chesslib
int main(int argc, const char* argv[])
{
    CU_initialize_registry();

    chess_generate_init();

    test_chess_add_tests();
    test_move_add_tests();
    test_variation_add_tests();
    test_parse_add_tests();
    test_print_add_tests();
    test_position_add_tests();
    test_generate_add_tests();
    test_fen_add_tests();
    test_unmove_add_tests();
    test_game_add_tests();
    test_pgn_add_tests();
    test_cstring_add_tests();
    test_carray_add_tests();
    test_cbuffer_add_tests();
    test_pgn_tokenizer_add_tests();
    test_reader_add_tests();
    test_writer_add_tests();

    CU_basic_run_tests();

    CU_cleanup_registry();

    return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: alexmdc/chesslib
int main (int argc, const char* argv[])
{
    char *line, *cmd, *args;
    ChessGame* game;
    ChessGameIterator iter;
    int quit = 0;

    chess_generate_init();

    game = chess_game_new();
    chess_game_iterator_init(&iter, game);
    print_board(&iter);

    line = 0;

    for (;;)
    {
        if (line)
            free(line);

        if (quit)
            break;

        line = read_line("> ");
        if (!parse_line(line, &cmd, &args))
            continue;

        if (!strcmp(cmd, "quit") || !strcmp(cmd, "q"))
        {
            quit = 1;
        }
        else if (!strcmp(cmd, "new"))
        {
            chess_game_iterator_cleanup(&iter);
            chess_game_reset(game);
            chess_game_iterator_init(&iter, game);
            print_board(&iter);
        }
        else if (!strcmp(cmd, "fen"))
        {
            load_fen(game, args);
        }
        else if (!strcmp(cmd, "pgn"))
        {
            save_pgn(game);
        }
        else if (!strcmp(cmd, "ls"))
        {
            list_moves(&iter);
        }
        else if (!strcmp(cmd, "moves"))
        {
            game_moves(game);
        }
        else if (!strcmp(cmd, "bd"))
        {
            print_board(&iter);
        }
        else if (!strcmp(cmd, "undo"))
        {
            undo_move(&iter);
        }
        else if (!strcmp(cmd, "event"))
        {
            set_event(game, args);
        }
        else if (!strcmp(cmd, "site"))
        {
            set_site(game, args);
        }
        else if (!strcmp(cmd, "date"))
        {
            set_date(game, args);
        }
        else if (!strcmp(cmd, "round"))
        {
            set_round(game, args);
        }
        else if (!strcmp(cmd, "white"))
        {
            set_white(game, args);
        }
        else if (!strcmp(cmd, "black"))
        {
            set_black(game, args);
        }
        else if (!strcmp(cmd, "result"))
        {
            set_result(game, args);
        }
        else
        {
            handle_move(&iter, cmd);
        }
    }

    chess_game_iterator_cleanup(&iter);
    chess_game_destroy(game);

    return 0;
}