src/tcfr.cpp
// Our old implementation which is a bit slower.
Our old implementation which is a bit slower.
Our old implementation which is a bit slower .
void TCFRThread::NoHVBDealHand(void) {
  double r;
  drand48_r(&rand_buf_, &r);
#ifdef BC
  unsigned int num_boards = BoardTree::NumBoards(max_street_);
  unsigned int msbd = r * num_boards;
  board_count_ = BoardTree::BoardCount(max_street_, msbd);
#else
  unsigned int msbd = board_table_[(int)(r * num_raw_boards_)];
#endif
  canon_bds_[max_street_] = msbd;
  for (int st = 1; st < max_street_; ++st) {
    canon_bds_[st] = BoardTree::PredBoard(msbd, st);
  }
  const Card *board = BoardTree::Board(max_street_, msbd);
  Card cards[7];
  unsigned int num_ms_board_cards = Game::NumBoardCards(max_street_);
  for (unsigned int i = 0; i < num_ms_board_cards; ++i) {
    cards[i+2] = board[i];
  }
  int end_cards = Game::MaxCard() + 1;
  for (int p = 0; p < num_players_; ++p) {
    int c1, c2;
    while (true) {
      drand48_r(&rand_buf_, &r);
      c1 = end_cards * r;
      if (InCards(c1, board, num_ms_board_cards)) continue;
      if (InCards(c1, hole_cards_, 2 * p)) continue;
      break;
    }
    hole_cards_[2 * p] = c1;
    while (true) {
      drand48_r(&rand_buf_, &r);
      c2 = end_cards * r;
      if (InCards(c2, board, num_ms_board_cards)) continue;
      if (InCards(c2, hole_cards_, 2 * p + 1)) continue;
      break;
    }
    hole_cards_[2 * p + 1] = c2;
    if (c1 > c2) {hi_cards_[p] = c1; lo_cards_[p] = c2;}
    else         {hi_cards_[p] = c2; lo_cards_[p] = c1;}
  }
  for (int p = 0; p < num_players_; ++p) hvs_[p] = 0;
  for (int st = 0; st <= max_street_; ++st) {
    int bd = canon_bds_[st];
    int num_hole_card_pairs = Game::NumHoleCardPairs(st);
    for (int p = 0; p < num_players_; ++p) {
      cards[0] = hi_cards_[p];
      cards[1] = lo_cards_[p];
      unsigned int hcp = HCPIndex(st, cards);
      unsigned int h = ((unsigned int)bd) * ((unsigned int)num_hole_card_pairs) + hcp;
      hand_buckets_[p * (max_street_ + 1) + st] = buckets_.Bucket(st, h);
      if (st == max_street_) {
	hvs_[p] = HandValueTree::Val(cards);
      }
    }
  }
}
void TCFRThread :: NoHVBDealHand ( void ) { double r ; drand48_r ( & rand_buf_ , & r ) ; #ifdef BC unsigned int num_boards = BoardTree :: NumBoards ( max_street_ ) ; unsigned int msbd = r * num_boards ; board_count_ = BoardTree :: BoardCount ( max_street_ , msbd ) ; #else unsigned int msbd = board_table_ [ ( int ) ( r * num_raw_boards_ ) ] ; #endif canon_bds_ [ max_street_ ] = msbd ; for ( int st = 1 ; st < max_street_ ; ++ st ) { canon_bds_ [ st ] = BoardTree :: PredBoard ( msbd , st ) ; } const Card * board = BoardTree :: Board ( max_street_ , msbd ) ; Card cards [ 7 ] ; unsigned int num_ms_board_cards = Game :: NumBoardCards ( max_street_ ) ; for ( unsigned int i = 0 ; i < num_ms_board_cards ; ++ i ) { cards [ i + 2 ] = board [ i ] ; } int end_cards = Game :: MaxCard ( ) + 1 ; for ( int p = 0 ; p < num_players_ ; ++ p ) { int c1 , c2 ; while ( true ) { drand48_r ( & rand_buf_ , & r ) ; c1 = end_cards * r ; if ( InCards ( c1 , board , num_ms_board_cards ) ) continue ; if ( InCards ( c1 , hole_cards_ , 2 * p ) ) continue ; break ; } hole_cards_ [ 2 * p ] = c1 ; while ( true ) { drand48_r ( & rand_buf_ , & r ) ; c2 = end_cards * r ; if ( InCards ( c2 , board , num_ms_board_cards ) ) continue ; if ( InCards ( c2 , hole_cards_ , 2 * p + 1 ) ) continue ; break ; } hole_cards_ [ 2 * p + 1 ] = c2 ; if ( c1 > c2 ) { hi_cards_ [ p ] = c1 ; lo_cards_ [ p ] = c2 ; } else { hi_cards_ [ p ] = c2 ; lo_cards_ [ p ] = c1 ; } } for ( int p = 0 ; p < num_players_ ; ++ p ) hvs_ [ p ] = 0 ; for ( int st = 0 ; st <= max_street_ ; ++ st ) { int bd = canon_bds_ [ st ] ; int num_hole_card_pairs = Game :: NumHoleCardPairs ( st ) ; for ( int p = 0 ; p < num_players_ ; ++ p ) { cards [ 0 ] = hi_cards_ [ p ] ; cards [ 1 ] = lo_cards_ [ p ] ; unsigned int hcp = HCPIndex ( st , cards ) ; unsigned int h = ( ( unsigned int ) bd ) * ( ( unsigned int ) num_hole_card_pairs ) + hcp ; hand_buckets_ [ p * ( max_street_ + 1 ) + st ] = buckets_ . Bucket ( st , h ) ; if ( st == max_street_ ) { hvs_ [ p ] = HandValueTree :: Val ( cards ) ; } } } }
Our old implementation which is a bit slower.
Our old implementation which is a bit slower .