示例#1
0
文件: main.c 项目: kori4r2/trabalho6
int main(int argc, char *argv[]){

	TABLE *table = create_table();
	read_table(stdin, table);
//	print_table(table);
	PIECE_LIST *list = create_piece_list(table);
	QUEUE *queue = create_queue();
	list_moves(table, queue, list);
	print_queue(queue);
//printf("-----------------------------------------------------\n");
//	print_table(table);

	delete_queue(&queue);
	delete_list(&list);
//printf("-----------------------------------------------------\n");
//	print_table(table);
	delete_table(&table);

	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;
}