src/agent.cpp
// At least one of below_succ and above_succ is not -1.
At least one of below_succ and above_succ is not -1.
At least one of below_succ and above_succ is not - 1 .
int Agent::ChooseBetweenBetAndCall(Node *node, int below_succ, int above_succ, int actual_bet_to,
				   int actual_pot_size, Node **raise_node) {
  int selected_succ = -1;
  *raise_node = nullptr;
  int call_succ = node->CallSuccIndex();
  int smallest_bet_succ = -1;
  if (below_succ == call_succ) {
    if (above_succ != -1) {
      smallest_bet_succ = above_succ;
    }
  } else {
    int num_succs = node->NumSuccs();
    for (int s = 0; s < num_succs; ++s) {
      if (s == call_succ) continue;
      if (s == node->FoldSuccIndex()) continue;
      smallest_bet_succ = s;
      break;
    }
  }
  Node *smallest_bet_node = nullptr;
  if (smallest_bet_succ != -1) {
    smallest_bet_node = node->IthSucc(smallest_bet_succ);
  }
  if (above_succ == -1) {
    selected_succ = below_succ;
  } else if (below_succ == -1) {
    selected_succ = above_succ;
  } else {
    int below_bet_to = node->IthSucc(below_succ)->LastBetTo() * small_blind_;
    int above_bet_to = node->IthSucc(above_succ)->LastBetTo() * small_blind_;
    double below_prob = BelowProb(actual_bet_to, below_bet_to, above_bet_to, actual_pot_size);
    double r;
    drand48_r(&rand_buf_, &r);
    if (r < below_prob) {
      selected_succ = below_succ;
    } else {
      selected_succ = above_succ;
    }
  }
  if (selected_succ == call_succ) {
    *raise_node = smallest_bet_node;
  }
  return selected_succ;
}
int Agent :: ChooseBetweenBetAndCall ( Node * node , int below_succ , int above_succ , int actual_bet_to , int actual_pot_size , Node * * raise_node ) { int selected_succ = -1 ; * raise_node = nullptr ; int call_succ = node -> CallSuccIndex ( ) ; int smallest_bet_succ = -1 ; if ( below_succ == call_succ ) { if ( above_succ != -1 ) { smallest_bet_succ = above_succ ; } } else { int num_succs = node -> NumSuccs ( ) ; for ( int s = 0 ; s < num_succs ; ++ s ) { if ( s == call_succ ) continue ; if ( s == node -> FoldSuccIndex ( ) ) continue ; smallest_bet_succ = s ; break ; } } Node * smallest_bet_node = nullptr ; if ( smallest_bet_succ != -1 ) { smallest_bet_node = node -> IthSucc ( smallest_bet_succ ) ; } if ( above_succ == -1 ) { selected_succ = below_succ ; } else if ( below_succ == -1 ) { selected_succ = above_succ ; } else { int below_bet_to = node -> IthSucc ( below_succ ) -> LastBetTo ( ) * small_blind_ ; int above_bet_to = node -> IthSucc ( above_succ ) -> LastBetTo ( ) * small_blind_ ; double below_prob = BelowProb ( actual_bet_to , below_bet_to , above_bet_to , actual_pot_size ) ; double r ; drand48_r ( & rand_buf_ , & r ) ; if ( r < below_prob ) { selected_succ = below_succ ; } else { selected_succ = above_succ ; } } if ( selected_succ == call_succ ) { * raise_node = smallest_bet_node ; } return selected_succ ; }
At least one of below_succ and above_succ is not -1.
At least one of below_succ and above_succ is not - 1 .
// Some corner cases here. // Sometimes we have only one valid succ. // We have two valid succs // drand48_r(&rand_bufs_[node->PlayerActing()], &r); // Don't use above_succ; it might be kMaxUInt