src/assemble_subgames.cpp
// When we get to the target street, read the entire base strategy for
// this subtree into merged sumprobs.  Then go through and override parts
// with the subgame strategy.
When we get to the target street, read the entire base strategy for
this subtree into merged sumprobs.  Then go through and override parts
with the subgame strategy.
When we get to the target street read the entire base strategy for this subtree into merged sumprobs . Then go through and override parts with the subgame strategy .
void Assembler::WalkTrunk(Node *base_node, Node *subgame_node, const string &action_sequence,
			  int last_st) {
  if (base_node->Terminal()) return;
  int st = base_node->Street();
  if (st == solve_street_) {
    int num_boards = BoardTree::NumBoards(st);
    int base_subtree_nt = base_node->NonterminalID();
    fprintf(stderr, "Base subtree NT: %i lbt %i\n", base_subtree_nt, base_node->LastBetTo());
    unique_ptr<BettingTrees> subtrees(new BettingTrees(subgame_node));
#if 0
    int max_street = Game::MaxStreet();
    unique_ptr<bool []> subgame_streets(new bool[max_street + 1]);
    for (int st = 0; st <= max_street; ++st) subgame_streets[st] = st >= solve_street_;
    unique_ptr<bool []> subgame_compressed_streets(new bool[max_street + 1]);
    for (int st = 0; st <= max_street; ++st) subgame_compressed_streets[st] = false;
    const vector<int> &ecsv = subgame_cc_.CompressedStreets();
    int num_ecsv = ecsv.size();
    for (int i = 0; i < num_ecsv; ++i) {
      int st = ecsv[i];
      subgame_compressed_streets[st] = true;
    }
#endif
    for (int gbd = 0; gbd < num_boards; ++gbd) {
      unique_ptr<CFRValues> subgame_sumprobs =
	ReadSubgame(action_sequence, subtrees.get(), gbd, base_ca_, subgame_ca_, base_ba_,
		    subgame_ba_, base_cc_, subgame_cc_, *subgame_buckets_.get(), method_, st, gbd,
		    -1);
      merged_sumprobs_->MergeInto(*subgame_sumprobs.get(), gbd, subgame_node, subtrees->Root(),
				  *subgame_buckets_, Game::MaxStreet());
    }
    return;
  }
  int num_succs = base_node->NumSuccs();
  for (int s = 0; s < num_succs; ++s) {
    string action = base_node->ActionName(s);
    WalkTrunk(base_node->IthSucc(s), subgame_node->IthSucc(s), action_sequence + action, st);
  }
}
void Assembler :: WalkTrunk ( Node * base_node , Node * subgame_node , const string & action_sequence , int last_st ) { if ( base_node -> Terminal ( ) ) return ; int st = base_node -> Street ( ) ; if ( st == solve_street_ ) { int num_boards = BoardTree :: NumBoards ( st ) ; int base_subtree_nt = base_node -> NonterminalID ( ) ; fprintf ( stderr , " \n " , base_subtree_nt , base_node -> LastBetTo ( ) ) ; unique_ptr < BettingTrees > subtrees ( new BettingTrees ( subgame_node ) ) ; #if 0 int max_street = Game :: MaxStreet ( ) ; unique_ptr < bool [ ] > subgame_streets ( new bool [ max_street + 1 ] ) ; for ( int st = 0 ; st <= max_street ; ++ st ) subgame_streets [ st ] = st >= solve_street_ ; unique_ptr < bool [ ] > subgame_compressed_streets ( new bool [ max_street + 1 ] ) ; for ( int st = 0 ; st <= max_street ; ++ st ) subgame_compressed_streets [ st ] = false ; const vector < int > & ecsv = subgame_cc_ . CompressedStreets ( ) ; int num_ecsv = ecsv . size ( ) ; for ( int i = 0 ; i < num_ecsv ; ++ i ) { int st = ecsv [ i ] ; subgame_compressed_streets [ st ] = true ; } #endif for ( int gbd = 0 ; gbd < num_boards ; ++ gbd ) { unique_ptr < CFRValues > subgame_sumprobs = ReadSubgame ( action_sequence , subtrees . get ( ) , gbd , base_ca_ , subgame_ca_ , base_ba_ , subgame_ba_ , base_cc_ , subgame_cc_ , * subgame_buckets_ . get ( ) , method_ , st , gbd , -1 ) ; merged_sumprobs_ -> MergeInto ( * subgame_sumprobs . get ( ) , gbd , subgame_node , subtrees -> Root ( ) , * subgame_buckets_ , Game :: MaxStreet ( ) ) ; } return ; } int num_succs = base_node -> NumSuccs ( ) ; for ( int s = 0 ; s < num_succs ; ++ s ) { string action = base_node -> ActionName ( s ) ; WalkTrunk ( base_node -> IthSucc ( s ) , subgame_node -> IthSucc ( s ) , action_sequence + action , st ) ; } }
When we get to the target street, read the entire base strategy for
this subtree into merged sumprobs.
When we get to the target street read the entire base strategy for this subtree into merged sumprobs .