(physics, bricks, pairs, close_coef=0.1)
return np.average([close, clicked], weights=[close_coef, 1.], axis=0)
Returns a vector of shaping reward components based on pairwise distances.

  Args:
    physics: An `mjcf.Physics` instance.
    bricks: A list of `composer.Entity` instances corresponding to bricks.
    pairs: A list of `(bottom_idx, top_idx)` tuples specifying which pairs of
      bricks should be measured.
    close_coef: Float specfying the relative weight given to the coarse-
      tolerance shaping component for getting the bricks close to one another
      (as opposed to the fine-tolerance component for clicking them together).

  Returns:
    A numpy array of size `len(pairs)` containing values in (0, 1], where
    1 corresponds to a stacked pair of bricks.
Returns a vector of shaping reward components based on pairwise distances.
Returns a vector of shaping reward components based on pairwise distances .
def _get_pairwise_stacking_rewards(physics, bricks, pairs, close_coef=0.1):
  """Returns a vector of shaping reward components based on pairwise distances.

  Args:
    physics: An `mjcf.Physics` instance.
    bricks: A list of `composer.Entity` instances corresponding to bricks.
    pairs: A list of `(bottom_idx, top_idx)` tuples specifying which pairs of
      bricks should be measured.
    close_coef: Float specfying the relative weight given to the coarse-
      tolerance shaping component for getting the bricks close to one another
      (as opposed to the fine-tolerance component for clicking them together).

  Returns:
    A numpy array of size `len(pairs)` containing values in (0, 1], where
    1 corresponds to a stacked pair of bricks.
  """
  distances = []
  for bottom_idx, top_idx in pairs:
    bottom_brick = bricks[bottom_idx]
    top_brick = bricks[top_idx]
    distances.append(
        _min_stud_to_hole_distance(physics, bottom_brick, top_brick))
  distances = np.hstack(distances)

  # Coarse-tolerance component for bringing the holes close to the studs.
  close = rewards.tolerance(
      distances, bounds=(0, _CLOSE_THRESHOLD), margin=(_CLOSE_THRESHOLD * 10))

  # Fine-tolerance component for clicking the bricks together.
  clicked = rewards.tolerance(
      distances, bounds=(0, _CLICK_THRESHOLD), margin=_CLICK_THRESHOLD)

  # Weighted average of coarse and fine components for each pair of bricks.
  return np.average([close, clicked], weights=[close_coef, 1.], axis=0)
def _get_pairwise_stacking_rewards ( physics , bricks , pairs , close_coef = 0.1 ) : distances = [ ] for bottom_idx , top_idx in pairs : bottom_brick = bricks [ bottom_idx ] top_brick = bricks [ top_idx ] distances . append ( _min_stud_to_hole_distance ( physics , bottom_brick , top_brick ) ) distances = np . hstack ( distances ) # Coarse-tolerance component for bringing the holes close to the studs. close = rewards . tolerance ( distances , bounds = ( 0 , _CLOSE_THRESHOLD ) , margin = ( _CLOSE_THRESHOLD * 10 ) ) # Fine-tolerance component for clicking the bricks together. clicked = rewards . tolerance ( distances , bounds = ( 0 , _CLICK_THRESHOLD ) , margin = _CLICK_THRESHOLD ) # Weighted average of coarse and fine components for each pair of bricks. return np . average ( [ close , clicked ] , weights = [ close_coef , 1. ] , axis = 0 )