void update_regrets()

in csrc/liars_dice/subgame_solving.cc [538:575]


  void update_regrets(int traverser) {
    precompute_reaches(last_strategies, initial_beliefs);
    precompute_all_leaf_values(traverser);

    for (size_t public_node = tree.size(); public_node-- > 0;) {
      const auto& node = tree[public_node];
      if (!node.num_children()) {
        // All leaf values are set by precompute_all_leaf_values.
        continue;
      }
      const auto& state = node.state;
      auto& value = traverser_values[public_node];
      value.assign(value.size(), 0.0);
      if (state.player_id == traverser) {
        for (auto [child_node, action] : ChildrenActionIt(node, game)) {
          const auto& action_value = traverser_values[child_node];
          for (int hand = 0; hand < game.num_hands(); ++hand) {
            regrets[public_node][hand][action] += action_value[hand];
            value[hand] +=
                action_value[hand] * last_strategies[public_node][hand][action];
          }
        }
        for (int hand = 0; hand < game.num_hands(); ++hand) {
          for (auto [child_node, action] : ChildrenActionIt(node, game)) {
            regrets[public_node][hand][action] -= value[hand];
          }
        }
      } else {
        assert(state.player_id == 1 - traverser);
        for (auto child_node : ChildrenIt(node)) {
          const auto& action_value = traverser_values[child_node];
          for (int hand = 0; hand < game.num_hands(); ++hand) {
            value[hand] += action_value[hand];
          }
        }
      }
    }
  }