public void ShouldScaleAndOffsetCorrectlyWithYRange()
        {
            var myFunction = new SigmoidFunction(new SigmoidFunctionConfig
            {
                offset = 1f,
                range  = 10f,
                yRange = 3f
            });

            var expectedValueTable = new Dictionary <float, float>
            {
                { 0f, 0.997527376843365225f * 3 },

                { 2f, 0.982013790037908442f * 3 },

                { 4f, 0.880797077977882444f * 3 },

                { 6f, 0.5f * 3 },
                { 7f, 0.268941421369995120f * 3 },


                { 10f, 0.01798620996209156f * 3 },
            };

            foreach (var expectedPair in expectedValueTable)
            {
                Assert.AreEqual(expectedPair.Value, myFunction.GetValueAtPoint(expectedPair.Key), 1e-5);
            }
        }
Example #2
0
        private void SetupSelfForResource(ResourceType resource)
        {
            currentResource = resource;

            var color             = ResourceConfiguration.resourceColoring[currentResource];
            var inventoryCapacity = (market._inventory as ISpaceFillingInventoryAccess <ResourceType>)?.GetInventoryCapacity() ?? maxTargetValueDefaultWhenInfiniteCapacity;

            var priceFunctionConfig = market.GetSellPriceFunctions()[currentResource];
            var priceFunction       = new SigmoidFunction(priceFunctionConfig);

            var functionAdapter = new PlottableFunctionToSeriesAdapter(
                x => priceFunction.GetValueAtPoint(x),
                new PlottableFunctionConfig
            {
                start = 0,
                end   = inventoryCapacity,
                steps = inventoryCapacity
            },
                new PlottableConfig
            {
                dotColor  = default,