- Real dist = state.extra_encompass_infos_[j].extents_[Y_AXIS].distance (y);
- demerit
- += fabs (max (0.0, (state.parameters_.extra_encompass_free_distance_ - dist)))
- / state.parameters_.extra_encompass_free_distance_
- * state.extra_encompass_infos_[j].penalty_;
+ Real dist = 0.0;
+ if (info.type_ == ly_symbol2scm ("around"))
+ dist = info.extents_[Y_AXIS].distance (y);
+
+ /*
+ Have to score too: the curve enumeration is limited in its
+ shape, and may produce curves which collide anyway.
+ */
+ else if (info.type_ == ly_symbol2scm ("inside"))
+ dist = state.dir_ * (y - info.extents_[Y_AXIS][state.dir_]);
+ else
+ programming_error ("unknown avoidance type");
+
+ dist = max (dist, 0.0);
+
+ Real penalty = info.penalty_ * peak_around (0.1 * state.parameters_.extra_encompass_free_distance_,
+ state.parameters_.extra_encompass_free_distance_,
+ dist);
+
+ add_score (penalty, "extra");