src/cfr_utils.cpp
// Abstracted, integer regrets
// No flooring here.  Will be done later.
Abstracted, integer regrets
No flooring here.  Will be done later.
Abstracted integer regrets No flooring here . Will be done later .
void VCFR::UpdateRegretsBucketed(Node *node, int **street_buckets, double *vals, double **succ_vals,
				 int *regrets) {
  int st = node->Street();
  int num_succs = node->NumSuccs();
  int num_hole_card_pairs = Game::NumHoleCardPairs(st);
  int ceiling = regret_ceilings_[st];
  if (nn_regrets_) {
    for (int i = 0; i < num_hole_card_pairs; ++i) {
      int b = street_buckets[st][i];
      int *my_regrets = regrets + b * num_succs;
      for (int s = 0; s < num_succs; ++s) {
	double d = succ_vals[s][i] - vals[i];
	int di = lrint(d * regret_scaling_[st]);
	int ri = my_regrets[s] + di;
	if (ri > ceiling) {
	  my_regrets[s] = ceiling;
	} else {
	  my_regrets[s] = ri;
	}
      }
    }
  } else {
    for (int i = 0; i < num_hole_card_pairs; ++i) {
      int b = street_buckets[st][i];
      int *my_regrets = regrets + b * num_succs;
      bool overflow = false;
      for (int s = 0; s < num_succs; ++s) {
	double d = succ_vals[s][i] - vals[i];
	my_regrets[s] += lrint(d * regret_scaling_[st]);
	if (my_regrets[s] < -2000000000 || my_regrets[s] > 2000000000) {
	  overflow = true;
	}
      }
      if (overflow) {
	for (int s = 0; s < num_succs; ++s) {
	  my_regrets[s] /= 2;
	}
      }
    }
  }
}
void VCFR :: UpdateRegretsBucketed ( Node * node , int * * street_buckets , double * vals , double * * succ_vals , int * regrets ) { int st = node -> Street ( ) ; int num_succs = node -> NumSuccs ( ) ; int num_hole_card_pairs = Game :: NumHoleCardPairs ( st ) ; int ceiling = regret_ceilings_ [ st ] ; if ( nn_regrets_ ) { for ( int i = 0 ; i < num_hole_card_pairs ; ++ i ) { int b = street_buckets [ st ] [ i ] ; int * my_regrets = regrets + b * num_succs ; for ( int s = 0 ; s < num_succs ; ++ s ) { double d = succ_vals [ s ] [ i ] - vals [ i ] ; int di = lrint ( d * regret_scaling_ [ st ] ) ; int ri = my_regrets [ s ] + di ; if ( ri > ceiling ) { my_regrets [ s ] = ceiling ; } else { my_regrets [ s ] = ri ; } } } } else { for ( int i = 0 ; i < num_hole_card_pairs ; ++ i ) { int b = street_buckets [ st ] [ i ] ; int * my_regrets = regrets + b * num_succs ; bool overflow = false ; for ( int s = 0 ; s < num_succs ; ++ s ) { double d = succ_vals [ s ] [ i ] - vals [ i ] ; my_regrets [ s ] += lrint ( d * regret_scaling_ [ st ] ) ; if ( my_regrets [ s ] < -2000000000 || my_regrets [ s ] > 2000000000 ) { overflow = true ; } } if ( overflow ) { for ( int s = 0 ; s < num_succs ; ++ s ) { my_regrets [ s ] /= 2 ; } } } } }
Abstracted, integer regrets
No flooring here.
Abstracted integer regrets No flooring here .
// Need different implementation for doubles