/// <summary> /// Find the resource with the highest sell price per utility of that resource. Can be used to find /// a resource with either very low incremental utility or very high sell price /// </summary> /// <param name="increment">The increment to which the value functions are evaluated</param> /// <returns></returns> private Resource GetHighestSellableValuePerUtility(float increment, Self simSelf, Other simOther) { var resourceObject = tradeableResources .Where(resource => exchange.CanSell(resource, simSelf, simOther)) .Select(resource => new { resource, valuePerUtility = exchange.Sell(resource, increment, simSelf, simOther).info.cost / -utilityFunctions.GetIncrementalUtility(resource, simSelf, -increment) }) .OrderBy(resource => resource.valuePerUtility) .LastOrDefault(); if (resourceObject == default) { return(default(Resource)); } return(resourceObject.resource); }