                 q2.reach = q.reach;
                        }
                    }
                }
            }
            if (changeCount == 0) {
                break;
            }
        }
    }

    function map_percent_to_range(percent, min, max) {
        percent = clamp(percent, 0, 100);
        return (max - min) * percent / 100. + min;
    }

    function map_value_to_percent(value, min, max) {
        value = clamp(value, min, max);
        return 100 * (value - min) / (max - min);
    }

