示例#1
0
int main()
{
	unsigned int n = 0;
	int i;

	/*
	printf("Enter Number: ");
	scanf("%d", &n);
	*/
	
	for (i=1; i<=100; i++) 
		printf("%10d 	%10uld	%10uld 	%10uld	%10d \n", i, power1(2, i), power2(2, i), power3(2, i), is_prime(i));
		//printf("%d is %sa prime number\n", i, is_prime(i)?"":"not ");

	return 0;
}
void SetAggressAction(Aggress_t *agg, PokerAI *ai, VarTran_t h, int (*IsBetter)(int eval, int evalclass)) {

	int stack = h.stack;
	int round = h.round;
	//int pwr   = h.pwr;
	//int pv    = h.pv;
	
	int eval  = h.pwr;
	if (agg->type == 1) {
		eval = h.pwr;
	}
	
	int my_pos 				 = agg->my_pos;
	int beforeme_least_stack = agg->beforeme_least_stack;
	int behindme_best_stack  = agg->behindme_best_stack;
	int sum_other_stack      = agg->sum_other_stack;	
	int is_aggress			 = agg->level;
		
	//~~~~~~~~~~~~~
	int aggbet = MAX(rand()%80, rand()%(is_aggress*stack/10+1));
	//int call_no = ai->game.call_no;
	if (is_aggress 															&& 
		(ai->action.type == ACTION_FOLD||ai->action.type == ACTION_CHECK) 	){
		ai->game.call_no++;
	}
	if (is_aggress == 3) {
		DBASPRINTF("[%4d]===[in-%d-of-%d-lv-%d]", round, my_pos, h.noPlayers, is_aggress);
		if (IsBetter(eval, 3)) {
			aggbet = power3(h.call_no);
			DBASPRINTF("---call %d", h.call_amount);
			AggSetCall();
		} else if (IsBetter(eval, 4)) {
			DBASPRINTF("---raise %d", 4*aggbet);
			AggSetBet(4*aggbet);			
		} else if (h.pv >= 12) {
			DBASPRINTF("---raise %d", 2*aggbet);
			AggSetBet(2*aggbet);
		} else {
			DBASPRINTF("---call %d", h.call_amount);
			AggSetCall();			
		}
		DBASPRINTF("\n");		
	} if (is_aggress == 2) {
		DBASPRINTF("[%4d]===[in-%d-of-%d-lv-%d]", round, my_pos, h.noPlayers, is_aggress);
		if (IsBetter(eval, 3)) {
			DBASPRINTF("---raise %d", 2*aggbet);
			AggSetBet(2*aggbet);		
		} else if (IsBetter(eval, 4)) {
			DBASPRINTF("---raise %d", 2*aggbet);
			AggSetBet(2*aggbet);
		}
		DBASPRINTF("\n");			
	} else if (is_aggress == 1){
		DBASPRINTF("[%4d]===[in-%d-of-%d-lv-%d-%d<<%d<<%d]", round, my_pos, h.noPlayers, is_aggress, behindme_best_stack, stack, beforeme_least_stack);
		if (IsBetter(eval, 2)) {
			aggbet = MIN(aggbet*2, rand()%(ai->game.raise_no*behindme_best_stack/2+1));
			DBASPRINTF("---raise %d", aggbet);
			AggSetBet(aggbet);
		} else if (IsBetter(eval, 3)) {
			aggbet = MIN(aggbet*2, rand()%(ai->game.raise_no*behindme_best_stack/4+1));
			DBASPRINTF("---raise %d", aggbet);
			AggSetBet(aggbet);
		} else if (IsBetter(eval, 4)) {
			DBASPRINTF("---raise %d", aggbet);
			AggSetBet(aggbet);
		}
		DBASPRINTF("\n");
	} // END 激进地争取名次
	
	// 排第一的时候,如果对方没有机会赢,一直fold
	int all_fold_lost_money = (600-round)*(1.5*h.BB)/h.noPlayers;
	if (my_pos == 1 && (stack-sum_other_stack-all_fold_lost_money>0) ) {		
		if (IsBet() || IsAllin()) {SetCall();}
		if (IsCall()) {SetFold();}
		printf("--- fold till end --- no.1 ---\n");
	}	
}
示例#3
0
int main(int argc, char **argv) {
  fprintf(stderr, "power3() = %d\n", power3(atoi(argv[1])));
  return 0;
}
示例#4
0
int power3(int base, int exponent){
    if (exponent == 1)
        return base;
    else
        return base * power3(base, exponent - 1);
}