src/rollout.cpp
// On turn, deal out all river cards.  Compute WML for all hands.
On turn, deal out all river cards.  Compute WML for all hands.
On turn deal out all river cards . Compute WML for all hands .
short *ComputeRollout(unsigned int st, double *percentiles, unsigned int num_percentiles,
		      double squashing, bool wins) {
  unsigned int num_boards = BoardTree::NumBoards(st);
  unsigned int num_board_cards = Game::NumBoardCards(st);
  unsigned int num_hole_card_pairs = Game::NumHoleCardPairs(st);
  unsigned long long int num_hands = num_boards * num_hole_card_pairs;
  unsigned long long int num_vals = num_hands * num_percentiles;
  short *pct_vals;
  if (st == 0) {
    pct_vals = ComputePreflopPercentiles(percentiles, num_percentiles, wins);
  } else {
    pct_vals = new short[num_vals];
    Card board[5];
    for (unsigned int bd = 0; bd < num_boards; ++bd) {
      if (bd % 1000 == 0) fprintf(stderr, "bd %i\n", bd);
      const Card *st_board = BoardTree::Board(st, bd);
      for (unsigned int i = 0; i < num_board_cards; ++i) {
	board[i] = st_board[i];
      }
      unsigned int h = bd * num_hole_card_pairs;
      vector<short> *wmls = ComputeRollout(board, wins, st);
      unsigned int max_card = Game::MaxCard();
      unsigned int num_enc = (max_card + 1) * (max_card + 1);
      for (unsigned int i = 0; i < num_enc; ++i) {
	vector<short> &v = wmls[i];
	if (v.size() == 0) continue;
	GetPercentiles(v, percentiles, num_percentiles, &pct_vals[h * num_percentiles]);
	++h;
      }
      delete [] wmls;
    }
  }
  if (squashing == 1.0) {
    return pct_vals;
  }
  short min_val = 32700;
  short max_val = -32700;
  for (unsigned long long int i = 0; i < num_vals; ++i) {
    short val = pct_vals[i];
    if (val < min_val) min_val = val;
    if (val > max_val) max_val = val;
  }
  for (unsigned long long int i = 0; i < num_vals; ++i) {
    short val = pct_vals[i];
    short norm_val = -(val - max_val);
    pct_vals[i] = (short)pow(norm_val, squashing);
  }
  return pct_vals;
}
short * ComputeRollout ( unsigned int st , double * percentiles , unsigned int num_percentiles , double squashing , bool wins ) { unsigned int num_boards = BoardTree :: NumBoards ( st ) ; unsigned int num_board_cards = Game :: NumBoardCards ( st ) ; unsigned int num_hole_card_pairs = Game :: NumHoleCardPairs ( st ) ; unsigned long long int num_hands = num_boards * num_hole_card_pairs ; unsigned long long int num_vals = num_hands * num_percentiles ; short * pct_vals ; if ( st == 0 ) { pct_vals = ComputePreflopPercentiles ( percentiles , num_percentiles , wins ) ; } else { pct_vals = new short [ num_vals ] ; Card board [ 5 ] ; for ( unsigned int bd = 0 ; bd < num_boards ; ++ bd ) { if ( bd % 1000 == 0 ) fprintf ( stderr , " \n " , bd ) ; const Card * st_board = BoardTree :: Board ( st , bd ) ; for ( unsigned int i = 0 ; i < num_board_cards ; ++ i ) { board [ i ] = st_board [ i ] ; } unsigned int h = bd * num_hole_card_pairs ; vector < short > * wmls = ComputeRollout ( board , wins , st ) ; unsigned int max_card = Game :: MaxCard ( ) ; unsigned int num_enc = ( max_card + 1 ) * ( max_card + 1 ) ; for ( unsigned int i = 0 ; i < num_enc ; ++ i ) { vector < short > & v = wmls [ i ] ; if ( v . size ( ) == 0 ) continue ; GetPercentiles ( v , percentiles , num_percentiles , & pct_vals [ h * num_percentiles ] ) ; ++ h ; } delete [ ] wmls ; } } if ( squashing == 1.0 ) { return pct_vals ; } short min_val = 32700 ; short max_val = -32700 ; for ( unsigned long long int i = 0 ; i < num_vals ; ++ i ) { short val = pct_vals [ i ] ; if ( val < min_val ) min_val = val ; if ( val > max_val ) max_val = val ; } for ( unsigned long long int i = 0 ; i < num_vals ; ++ i ) { short val = pct_vals [ i ] ; short norm_val = - ( val - max_val ) ; pct_vals [ i ] = ( short ) pow ( norm_val , squashing ) ; } return pct_vals ; }
On turn, deal out all river cards.
On turn deal out all river cards .
// Renormalize vals so that worse hands have higher values and the lowest // value is zero.  Then squash by raising to the given power.