Example #1
0
int Euler54::compute_best_hand(Euler54::Hand _hand){
    if(royal_flush(_hand)){
        std::cout << "Royal Flush" << std::endl;
        return 10;
    }else if(straight_flush(_hand)){
        std::cout << "Straight Flush" << std::endl;
        return 9;
    }else if(quads(_hand)){
        std::cout << "Quads" << std::endl;
        return 8;   
    }else if(full_house(_hand)){
        std::cout << "Full House" << std::endl;
        return 7;
    }else if(flush(_hand)){
        std::cout << "Flush" << std::endl;
        return 6;
    }else if(straight(_hand)){
        std::cout << "Straight" << std::endl;
        return 5;
    }else if(trips(_hand)){
        std::cout << "Trips" << std::endl;
        return 4;
    }else if(two_pair(_hand)){
        std::cout << "Two Pair" << std::endl;
        return 3;
    }else if(pair(_hand, 0)){
        std::cout << "Pair" << std::endl;
        return 2;
    }else{
        set_highest_card(highest_card(_hand));
        std::cout << "you have the high card " << print_card(current_highest_card) << std::endl;
        return 1;
        std::cout << " you got squat " << std::endl;
    }
}
Example #2
0
std::pair<int, int> Pokerhand::hand_value() {
    int val;

    if ((val = royal_flush()))
        return std::make_pair(10, val);
    if ((val = straight_flush()))
        return std::make_pair(9, val);
    if ((val = four()))
        return std::make_pair(8, val);
    if ((val = full_house()))
        return std::make_pair(7, val);
    if ((val = flush()))
        return std::make_pair(6, val);
    if ((val = straight()))
        return std::make_pair(5, val);
    if ((val = three()))
        return std::make_pair(4, val);
    if ((val = pairs()))
        return std::make_pair(3, val);
    if ((val = pair()))
        return std::make_pair(2, val);
    if ((val = high_card()))
        return std::make_pair(1, val);

    return std::make_pair(0, val);
}
Example #3
0
File: adlint.c Project: gembaf/wint
int final_attack(Handcard hd[], Cards remain_card, Cards hand_card, Cards deck_card, int cg)
{
  int k1;
  int len = 0;
  int flag;
  int disc_num;
  int hand[HNUM]; // 特別  役判定に用いる
  
  // 判定用の手札を作成
  for ( k1 = 0; k1 < HNUM; k1++ ) { hand[k1] = hd[k1].num_val; }

  // ロイヤルストレート
  if ( poker_point(hand) >= P9 ) { return -1; }
  disc_num = royal_straight_flush(hd, remain_card, deck_card, cg);
  if ( disc_num != -1 ) { return disc_num; }

  // ストレートフラッシュ
  if ( poker_point(hand) >= P8 ) { return -1; }
  disc_num = straight_flush(hd, hand_card, deck_card, cg);
  if ( disc_num != -1 ) { return disc_num; }

  // フォーカード
  if ( poker_point(hand) >= P7 ) { return -1; }
  disc_num = four_of_a_kind(hd, remain_card, hand_card, deck_card, cg);
  if ( disc_num != -1 ) { return disc_num; }

  // ストレート
  flag = 0;
  if ( poker_point(hand) >= P4 ) { return -1; }
  for ( k1 = 0; k1 < 13; k1++ ) {
    if ( remain_card.num[k1] >= 1 ) { len++; }
    else { len = 0; }
    if ( len >= 5) { flag = 1; }
  }
  if ( flag ) { return straight(hd, remain_card, hand_card, deck_card, cg); }

  flag = 0;
  // フラッシュ
  if ( poker_point(hand) >= P5 ) { return -1; }
  for ( k1 = 0; k1 < 4; k1++ ) {
    if ( remain_card.sut[k1] >= 5 ) { flag = 1; }
  }
  if ( flag ) {
    disc_num = flush(hd, hand_card, deck_card, cg);
    return disc_num;
  }
  // フルハウス ペア系
  if ( poker_point(hand) >= P6 ) { return -1; }
  for (k1 = 0; k1 < HNUM; k1++ ) {
    if ( remain_card.num[hd[k1].num] == 1 ) { return k1; }
  }
  for (k1 = 0; k1 < HNUM; k1++ ) {
    if ( remain_card.num[hd[k1].num] == 2 ) { return k1; }
  }
  return disc_num;
}
Example #4
0
score getscore(hand h)
{
	score s;
	s.rank = hicard;
	s.topcard = h[4];

	// order dependency:
	if ( num_pairs(h)==1 ) {
		s.rank = pair;
		s.topcard = gtc_pairs(h);
	}

	if ( num_pairs(h)==2 ) {
		s.rank = two_pairs;
		s.topcard = gtc_pairs(h);
	}

	if ( three_of_kind(h) ) {
		s.rank = three_kind;
		s.topcard = gtc_threes(h);
	}

	if ( isstraight(h) ) {
		s.rank = straight;
		s.topcard = h[4];
	}

	if ( isflush(h) ) {
		s.rank = flush;
		s.topcard = h[4];
	}

	if ( ishouse(h) ) {
		s.rank = house;
		s.topcard = gtc_pairs(h);
		if ( gtc_threes(h).value > s.topcard.value )
			s.topcard = gtc_threes(h);
	}

	if ( four_of_kind(h) ) {
		s.rank = four_kind;
		s.topcard = gtc_fours(h);
	}

	if ( straight_flush(h) ) {
		s.rank = sflush;
		s.topcard = h[4];
	}

	if ( royal_flush(h) ) {
		s.rank = rflush;
		s.topcard = h[4];
	}

	return s;
}
Example #5
0
bool Euler54::royal_flush(Hand _hand){
    if(straight_flush(_hand)){
        for(int i = 0; i < _hand.cards.size(); i++){
            if(_hand.cards[i].value < 10){
                return false;
            }
        }
        Card temp_card;
        temp_card.value = 14;
        temp_card.suit = find_suit(_hand, 14);
        current_highest_card = temp_card;
        return true;
    }
    return false;
}  
Example #6
0
int royal_flush(hand h)
{
	return h[0].value==10 && straight_flush(h);
}