src/mp_ecfr_node.cpp
// folded: which players have folded
// active: which players are active (not folded and not all-in)
// contributions: how many chips each player has contributed
// stack_sizes: starting stack sizes of each player
which players have folded
active: which players are active (not folded and not all-in)
contributions: how many chips each player has contributed
stack_sizes: starting stack sizes of each player
which players have folded active : which players are active ( not folded and not all - in ) contributions : how many chips each player has contributed stack_sizes : starting stack sizes of each player
MPECFRNode::MPECFRNode(Node *node, const Buckets &buckets, bool *folded, bool *active,
		       int *contributions, int *stack_sizes) {
  terminal_ = node->Terminal();
  if (terminal_) {
    showdown_ = node->Showdown();
    last_bet_to_ = node->LastBetTo();
    player_remaining_ = node->PlayerActing();
    if (showdown_) {
      SetShowdownPots(folded, active, contributions, stack_sizes);
    }
    return;
  }
  st_ = node->Street();
  player_acting_ = node->PlayerActing();
  if (folded[player_acting_]) {
    fprintf(stderr, "Folded player acting?!?\n");
    exit(-1);
  }
  if (! active[player_acting_]) {
    fprintf(stderr, "Inactive player acting?!?\n");
    exit(-1);
  }
  int num_buckets = buckets.NumBuckets(st_);
  num_succs_ = node->NumSuccs();
  if (num_succs_ > 1) {
    int num_values = num_buckets * num_succs_;
    regrets_.reset(new double[num_values]);
    sumprobs_.reset(new int[num_values]);
    for (int i = 0; i < num_values; ++i) {
      regrets_[i] = 0;
      sumprobs_[i] = 0;
    }
  }
  int csi = node->CallSuccIndex();
  int fsi = node->FoldSuccIndex();
  succs_.reset(new unique_ptr<MPECFRNode>[num_succs_]);
  for (int s = 0; s < num_succs_; ++s) {
    int old_contribution = contributions[player_acting_];
    int new_contribution = old_contribution;
    bool new_folded = false;
    bool new_active = true;
    Node *succ = node->IthSucc(s);
    if (s == csi) {
      int stack_size = stack_sizes[player_acting_];
      int last_bet_to = node->LastBetTo();
      if (last_bet_to >= stack_size) {
	new_contribution = stack_size;
	new_active = false;
      } else {
	new_contribution = last_bet_to;
      }
    } else if (s == fsi) {
      new_folded = true;
      new_active = false;
    } else {
      new_contribution = succ->LastBetTo();
      if (new_contribution > stack_sizes[player_acting_]) {
	fprintf(stderr, "Bet more than stack?!?\n");
	exit(-1);
      }
    }
    folded[player_acting_] = new_folded;
    active[player_acting_] = new_active;
    contributions[player_acting_] = new_contribution;
    succs_[s].reset(new MPECFRNode(succ, buckets, folded, active, contributions, stack_sizes));
    folded[player_acting_] = false;
    active[player_acting_] = true;
    contributions[player_acting_] = old_contribution;
  }
}
MPECFRNode :: MPECFRNode ( Node * node , const Buckets & buckets , bool * folded , bool * active , int * contributions , int * stack_sizes ) { terminal_ = node -> Terminal ( ) ; if ( terminal_ ) { showdown_ = node -> Showdown ( ) ; last_bet_to_ = node -> LastBetTo ( ) ; player_remaining_ = node -> PlayerActing ( ) ; if ( showdown_ ) { SetShowdownPots ( folded , active , contributions , stack_sizes ) ; } return ; } st_ = node -> Street ( ) ; player_acting_ = node -> PlayerActing ( ) ; if ( folded [ player_acting_ ] ) { fprintf ( stderr , " \n " ) ; exit ( -1 ) ; } if ( ! active [ player_acting_ ] ) { fprintf ( stderr , " \n " ) ; exit ( -1 ) ; } int num_buckets = buckets . NumBuckets ( st_ ) ; num_succs_ = node -> NumSuccs ( ) ; if ( num_succs_ > 1 ) { int num_values = num_buckets * num_succs_ ; regrets_ . reset ( new double [ num_values ] ) ; sumprobs_ . reset ( new int [ num_values ] ) ; for ( int i = 0 ; i < num_values ; ++ i ) { regrets_ [ i ] = 0 ; sumprobs_ [ i ] = 0 ; } } int csi = node -> CallSuccIndex ( ) ; int fsi = node -> FoldSuccIndex ( ) ; succs_ . reset ( new unique_ptr < MPECFRNode > [ num_succs_ ] ) ; for ( int s = 0 ; s < num_succs_ ; ++ s ) { int old_contribution = contributions [ player_acting_ ] ; int new_contribution = old_contribution ; bool new_folded = false ; bool new_active = true ; Node * succ = node -> IthSucc ( s ) ; if ( s == csi ) { int stack_size = stack_sizes [ player_acting_ ] ; int last_bet_to = node -> LastBetTo ( ) ; if ( last_bet_to >= stack_size ) { new_contribution = stack_size ; new_active = false ; } else { new_contribution = last_bet_to ; } } else if ( s == fsi ) { new_folded = true ; new_active = false ; } else { new_contribution = succ -> LastBetTo ( ) ; if ( new_contribution > stack_sizes [ player_acting_ ] ) { fprintf ( stderr , " \n " ) ; exit ( -1 ) ; } } folded [ player_acting_ ] = new_folded ; active [ player_acting_ ] = new_active ; contributions [ player_acting_ ] = new_contribution ; succs_ [ s ] . reset ( new MPECFRNode ( succ , buckets , folded , active , contributions , stack_sizes ) ) ; folded [ player_acting_ ] = false ; active [ player_acting_ ] = true ; contributions [ player_acting_ ] = old_contribution ; } }
folded: which players have folded
active: which players are active (not folded and not all-in)
contributions: how many chips each player has contributed
stack_sizes: starting stack sizes of each player
folded : which players have folded active : which players are active ( not folded and not all - in ) contributions : how many chips each player has contributed stack_sizes : starting stack sizes of each player
// No longer just one player remaining // Only store regrets, etc. if there is more than one succ // Restore old values