Beispiel #1
0
int main()
{
    double start_time[10];
    int i, j;
    int sorted_players[10];
    
    testgame = new_game(10);
    for (i = 0; i < 10; i++) {
        testgame->players[i].active = 1;
    }
    print_deck();
    puts("*** AFTER SHUFFLING ***");
    shuffle_deck(testgame);
    print_deck();
    puts("*** COMMUNITY CARDS ***");
    deal_community(testgame);
    print_community();
    puts("*** DEALING CARDS ***");
    deal_cards();
    print_hands();

    puts("*** SORTING PLAYERS ***");
    get_player_ranks(testgame, sorted_players);
    puts("In order of card ranking (low to high):");
    for (i = 0; i < 10; i++)
        printf("Player %d\n", sorted_players[i]);

    /*
    puts("*** BENCHMARKING ***");
    start_time[0] = get_time();
    for (i = 0; i < 5000; i++)
        shuffle_deck();
    printf("Shuffled deck 5,000 times in %f\n", get_time() - start_time[0]);

    for (i = 0; i < 10; i++) {
        start_time[i] = get_time();
        for (j = 0; j < 100000; j++)
            get_best_player_hand(i);
        printf("Calculated best hand for Player %d 100,000 times in %f\n", i, get_time() - start_time[i]);
    }
    */

    return 0;
}
Beispiel #2
0
void
print_set(struct filter_set_head *set)
{
	struct filter_set	*s;

	if (TAILQ_EMPTY(set))
		return;

	printf("set { ");
	TAILQ_FOREACH(s, set, entry) {
		switch (s->type) {
		case ACTION_SET_LOCALPREF:
			printf("localpref %u ", s->action.metric);
			break;
		case ACTION_SET_RELATIVE_LOCALPREF:
			printf("localpref %+d ", s->action.relative);
			break;
		case ACTION_SET_MED:
			printf("metric %u ", s->action.metric);
			break;
		case ACTION_SET_RELATIVE_MED:
			printf("metric %+d ", s->action.relative);
			break;
		case ACTION_SET_WEIGHT:
			printf("weight %u ", s->action.metric);
			break;
		case ACTION_SET_RELATIVE_WEIGHT:
			printf("weight %+d ", s->action.relative);
			break;
		case ACTION_SET_NEXTHOP:
			printf("nexthop %s ", log_addr(&s->action.nexthop));
			break;
		case ACTION_SET_NEXTHOP_REJECT:
			printf("nexthop reject ");
			break;
		case ACTION_SET_NEXTHOP_BLACKHOLE:
			printf("nexthop blackhole ");
			break;
		case ACTION_SET_NEXTHOP_NOMODIFY:
			printf("nexthop no-modify ");
			break;
		case ACTION_SET_NEXTHOP_SELF:
			printf("nexthop self ");
			break;
		case ACTION_SET_PREPEND_SELF:
			printf("prepend-self %u ", s->action.prepend);
			break;
		case ACTION_SET_PREPEND_PEER:
			printf("prepend-neighbor %u ", s->action.prepend);
			break;
		case ACTION_DEL_COMMUNITY:
			printf("community delete ");
			print_community(s->action.community.as,
			    s->action.community.type);
			printf(" ");
			break;
		case ACTION_SET_COMMUNITY:
			printf("community ");
			print_community(s->action.community.as,
			    s->action.community.type);
			printf(" ");
			break;
		case ACTION_PFTABLE:
			printf("pftable %s ", s->action.pftable);
			break;
		case ACTION_RTLABEL:
			printf("rtlabel %s ", s->action.rtlabel);
			break;
		case ACTION_SET_ORIGIN:
			printf("origin ");
			print_origin(s->action.origin);
			break;
		case ACTION_RTLABEL_ID:
		case ACTION_PFTABLE_ID:
			/* not possible */
			printf("king bula saiz: config broken");
			break;
		case ACTION_SET_EXT_COMMUNITY:
			printf("ext-community ");
			print_extcommunity(&s->action.ext_community);
			break;
		case ACTION_DEL_EXT_COMMUNITY:
			printf("ext-community delete ");
			print_extcommunity(&s->action.ext_community);
			break;
		}
	}
	printf("}");
}