namespace BlueLaminate.Core.Tradeups; /// /// The exact float arithmetic of a CS2 tradeup. Kept pure and dependency-free so it /// can be unit-tested in isolation and reused verbatim by any frontend. /// /// The contract: each input float is normalised to its own skin's range FIRST, those /// fractions are averaged, and the average is mapped onto the OUTPUT skin's range. The /// output float depends only on the average input fraction — a single scalar — which /// is what makes the search tractable (see the engine design notes). /// /// public static class TradeupMath { /// /// Normalises an input float to the fraction of its own skin's wear range: /// (value − min) / (max − min), clamped to [0,1]. A zero-width range /// (min == max) has no meaningful fraction and yields 0. /// public static decimal NormalizedFraction(decimal floatValue, decimal skinFloatMin, decimal skinFloatMax) { var span = skinFloatMax - skinFloatMin; if (span <= 0m) { return 0m; } var fraction = (floatValue - skinFloatMin) / span; return Math.Clamp(fraction, 0m, 1m); } /// /// Maps an average input fraction onto an output skin's wear range to get the exact /// float the tradeup would produce: avgFraction × (max − min) + min. /// public static decimal OutputFloat(decimal averageFraction, decimal outputFloatMin, decimal outputFloatMax) => averageFraction * (outputFloatMax - outputFloatMin) + outputFloatMin; }