src/rollout.cpp
// Not practical for preflop for full-deck holdem.
Not practical for preflop for full-deck holdem.
Not practical for preflop for full - deck holdem .
static vector<short> *ComputeRollout(Card *board, bool wins, unsigned int st) {
  unsigned int max_street = Game::MaxStreet();
  unsigned int max_card = Game::MaxCard();
  unsigned int num_enc = (max_card + 1) * (max_card + 1);
  vector<short> *wmls = new vector<short>[num_enc];
  if (st == max_street) {
    short *wmls1 = RiverHandStrength(board, wins);
    for (unsigned int i = 0; i < num_enc; ++i) {
      short wml = wmls1[i];
      if (wml != 32000) {
	wmls[i].push_back(wml);
      }
    }
    delete [] wmls1;
  } else {
    unsigned int num_board_cards = Game::NumBoardCards(st);
    unsigned int nst = st + 1;
    unsigned int num_new_board_cards = Game::NumCardsForStreet(nst);
    if (num_new_board_cards == 1) {
      for (unsigned int c = 0; c <= max_card; ++c) {
	if (InCards(c, board, num_board_cards)) continue;
	board[num_board_cards] = c;
	vector<short> *next_wmls = ComputeRollout(board, wins, nst);
	for (unsigned int i = 0; i < num_enc; ++i) {
	  vector<short> &v = next_wmls[i];
	  unsigned int num = v.size();
	  for (unsigned int j = 0; j < num; ++j) {
	    wmls[i].push_back(v[j]);
	  }
	}
	delete [] next_wmls;
      }
    } else if (num_new_board_cards == 3) {
      unsigned int hi, mid, lo;
      for (hi = 2; hi <= max_card; ++hi) {
	if (InCards(hi, board, num_board_cards)) continue;
	board[num_board_cards] = hi;
	for (mid = 1; mid < hi; ++mid) {
	  if (InCards(mid, board, num_board_cards)) continue;
	  board[num_board_cards + 1] = mid;
	  for (lo = 0; lo < mid; ++lo) {
	    board[num_board_cards + 2] = lo;
	    vector<short> *next_wmls = ComputeRollout(board, wins, nst);
	    for (unsigned int i = 0; i < num_enc; ++i) {
	      vector<short> &v = next_wmls[i];
	      unsigned int num = v.size();
	      for (unsigned int j = 0; j < num; ++j) {
		wmls[i].push_back(v[j]);
	      }
	    }
	    delete [] next_wmls;
	  }
	}
      }
    } else {
      fprintf(stderr, "Unhandled number of new board cards: %u\n",
	      num_new_board_cards);
      exit(-1);
    }
  }
  return wmls;
}
static vector < short > * ComputeRollout ( Card * board , bool wins , unsigned int st ) { unsigned int max_street = Game :: MaxStreet ( ) ; unsigned int max_card = Game :: MaxCard ( ) ; unsigned int num_enc = ( max_card + 1 ) * ( max_card + 1 ) ; vector < short > * wmls = new vector < short > [ num_enc ] ; if ( st == max_street ) { short * wmls1 = RiverHandStrength ( board , wins ) ; for ( unsigned int i = 0 ; i < num_enc ; ++ i ) { short wml = wmls1 [ i ] ; if ( wml != 32000 ) { wmls [ i ] . push_back ( wml ) ; } } delete [ ] wmls1 ; } else { unsigned int num_board_cards = Game :: NumBoardCards ( st ) ; unsigned int nst = st + 1 ; unsigned int num_new_board_cards = Game :: NumCardsForStreet ( nst ) ; if ( num_new_board_cards == 1 ) { for ( unsigned int c = 0 ; c <= max_card ; ++ c ) { if ( InCards ( c , board , num_board_cards ) ) continue ; board [ num_board_cards ] = c ; vector < short > * next_wmls = ComputeRollout ( board , wins , nst ) ; for ( unsigned int i = 0 ; i < num_enc ; ++ i ) { vector < short > & v = next_wmls [ i ] ; unsigned int num = v . size ( ) ; for ( unsigned int j = 0 ; j < num ; ++ j ) { wmls [ i ] . push_back ( v [ j ] ) ; } } delete [ ] next_wmls ; } } else if ( num_new_board_cards == 3 ) { unsigned int hi , mid , lo ; for ( hi = 2 ; hi <= max_card ; ++ hi ) { if ( InCards ( hi , board , num_board_cards ) ) continue ; board [ num_board_cards ] = hi ; for ( mid = 1 ; mid < hi ; ++ mid ) { if ( InCards ( mid , board , num_board_cards ) ) continue ; board [ num_board_cards + 1 ] = mid ; for ( lo = 0 ; lo < mid ; ++ lo ) { board [ num_board_cards + 2 ] = lo ; vector < short > * next_wmls = ComputeRollout ( board , wins , nst ) ; for ( unsigned int i = 0 ; i < num_enc ; ++ i ) { vector < short > & v = next_wmls [ i ] ; unsigned int num = v . size ( ) ; for ( unsigned int j = 0 ; j < num ; ++ j ) { wmls [ i ] . push_back ( v [ j ] ) ; } } delete [ ] next_wmls ; } } } } else { fprintf ( stderr , " \n " , num_new_board_cards ) ; exit ( -1 ) ; } } return wmls ; }
Not practical for preflop for full-deck holdem.
Not practical for preflop for full - deck holdem .