src/mp_betting_tree.cpp
// We are contemplating adding a bet.  We might or might not be facing a previous bet.
We are contemplating adding a bet.  We might or might not be facing a previous bet.
We are contemplating adding a bet . We might or might not be facing a previous bet .
void BettingTreeBuilder::MPHandleBet(int street, int last_bet_size, int last_bet_to, int new_bet_to,
				     int num_street_bets, int num_bets, int player_acting,
				     int num_players_to_act, bool *folded, int target_player,
				     string *key, int *terminal_id,
				     vector< shared_ptr<Node> > *bet_succs) {
  if (new_bet_to <= last_bet_to) return;
  int new_bet_size = new_bet_to - last_bet_to;
  int stack_size = betting_abstraction_.StackSize();
  bool all_in_bet = (new_bet_to == stack_size);
  if (new_bet_size < betting_abstraction_.MinBet() && ! all_in_bet) {
    return;
  }
  if (new_bet_size < last_bet_size && ! all_in_bet) {
    return;
  }
  int new_pot_size = new_bet_to * 2;
  if (! all_in_bet && betting_abstraction_.CloseToAllInFrac() > 0 &&
      new_pot_size >= 2 * stack_size * betting_abstraction_.CloseToAllInFrac()) {
    return;
  }
  string new_key = *key;
  if (betting_abstraction_.BettingKey(street)) {
    AddStringToKey("b", &new_key);
    AddIntToKey(new_bet_size, &new_key);
  }
  int num_players = Game::NumPlayers();
  int num_players_remaining = 0;
  for (int p = 0; p < num_players; ++p) {
    if (! folded[p]) ++num_players_remaining;
  }
  int next_player_to_act =
    NextPlayerToAct((player_acting + 1) % num_players, folded);
  if (num_players_remaining == 1) {
    fprintf(stderr, "Only one player remaining after bet?!?\n");
    exit(-1);
  }
  shared_ptr<Node> bet =
    CreateMPSubtree(street, new_bet_size, new_bet_to, num_street_bets + 1, num_bets + 1,
		    next_player_to_act, num_players_remaining - 1, folded, target_player,
		    &new_key, terminal_id);
  bet_succs->push_back(bet);
}
void BettingTreeBuilder :: MPHandleBet ( int street , int last_bet_size , int last_bet_to , int new_bet_to , int num_street_bets , int num_bets , int player_acting , int num_players_to_act , bool * folded , int target_player , string * key , int * terminal_id , vector < shared_ptr < Node > > * bet_succs ) { if ( new_bet_to <= last_bet_to ) return ; int new_bet_size = new_bet_to - last_bet_to ; int stack_size = betting_abstraction_ . StackSize ( ) ; bool all_in_bet = ( new_bet_to == stack_size ) ; if ( new_bet_size < betting_abstraction_ . MinBet ( ) && ! all_in_bet ) { return ; } if ( new_bet_size < last_bet_size && ! all_in_bet ) { return ; } int new_pot_size = new_bet_to * 2 ; if ( ! all_in_bet && betting_abstraction_ . CloseToAllInFrac ( ) > 0 && new_pot_size >= 2 * stack_size * betting_abstraction_ . CloseToAllInFrac ( ) ) { return ; } string new_key = * key ; if ( betting_abstraction_ . BettingKey ( street ) ) { AddStringToKey ( " " , & new_key ) ; AddIntToKey ( new_bet_size , & new_key ) ; } int num_players = Game :: NumPlayers ( ) ; int num_players_remaining = 0 ; for ( int p = 0 ; p < num_players ; ++ p ) { if ( ! folded [ p ] ) ++ num_players_remaining ; } int next_player_to_act = NextPlayerToAct ( ( player_acting + 1 ) % num_players , folded ) ; if ( num_players_remaining == 1 ) { fprintf ( stderr , " \n " ) ; exit ( -1 ) ; } shared_ptr < Node > bet = CreateMPSubtree ( street , new_bet_size , new_bet_to , num_street_bets + 1 , num_bets + 1 , next_player_to_act , num_players_remaining - 1 , folded , target_player , & new_key , terminal_id ) ; bet_succs -> push_back ( bet ) ; }
We are contemplating adding a bet.
We are contemplating adding a bet .
// New bet must be of size greater than zero // Cannot make a bet that is smaller than the min bet (usually the big blind) // In general, cannot make a bet that is smaller than the previous bet size.  Exception is that // you can always raise all-in // If CloseToAllInFrac is set, eliminate some bet sizes that are too close to an all-in bet. // Shouldn't happen // For bets we pass in the pot size without the pending bet included