This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Ticket #4356: ticket4356.patch

File ticket4356.patch, 4.0 KB (added by mimo, 8 years ago)

patch for the diminishingReturns (in comment 6 and rate1.png, 0.95 should be in fact 0.90)

  • binaries/data/mods/public/simulation/components/ResourceSupply.js

     
    1919        "<data type='nonNegativeInteger'/>" +
    2020    "</element>" +
    2121    "<optional>" +
    22         "<element name='DiminishingReturns' a:help='The rate at which adding more gatherers decreases overall efficiency. Lower numbers = faster dropoff. Leave the element out for no diminishing returns.'>" +
     22        "<element name='DiminishingReturns' a:help='The relative rate of any new gatherer compared to the previous one (geometric progression). Should be between 0 and 1 exclusives. Leave the element out for no diminishing returns.'>" +
    2323            "<ref name='positiveDecimal'/>" +
    2424        "</element>" +
    2525    "</optional>";
     
    8181    return this.gatherers.reduce((a, b) => a + b.length, 0);
    8282};
    8383
    84 /** Note to people looking to change <DiminishingReturns> in a template: This is a bit complicated. Basically, the lower that number is
    85  * the steeper diminishing returns will be. I suggest playing around with Wolfram Alpha or a graphing calculator a bit.
    86  * In each of the following links, replace 0.65 with the gather rate of your worker for the resource with diminishing returns and
    87  * 14 with the constant you wish to use to control the diminishing returns.
    88  * (In this case 0.65 is the women farming rate, in resources/second, and 14 is a good constant for farming.)
    89  * This is the gather rate in resources/second of each individual worker as the total number of workers goes up:
    90  * http://www.wolframalpha.com/input/?i=plot+%281%2F2+cos%28%28x-1%29*pi%2F14%29+%2B+1%2F2%29+*+0.65+from+1+to+5
    91  * This is the total output of the resource in resources/second:
    92  * http://www.wolframalpha.com/input/?i=plot+x%281%2F2+cos%28%28x-1%29*pi%2F14%29+%2B+1%2F2%29+*+0.65+from+1+to+5
    93  * This is the fraction of a worker each new worker is worth (the 5th worker in this example is only producing about half as much as the first one):
    94  * http://www.wolframalpha.com/input/?i=plot+x%281%2F2+cos%28%28x-1%29*pi%2F14%29+%2B+1%2F2%29+-++%28x-1%29%281%2F2+cos%28%28x-2%29*pi%2F14%29+%2B+1%2F2%29+from+x%3D1+to+5+and+y%3D0+to+1
    95  * Here's how this technically works:
    96  * The cosine function is an oscillating curve, normally between -1 and 1. Multiplying by 0.5 squishes that down to
    97  * between -0.5 and 0.5. Adding 0.5 to that changes the range to 0 to 1. The diminishingReturns constant
    98  * adjusts the period of the curve.
    99  */
     84/* The rate of each additionnal gatherer rate follow a geometric sequence, with diminishingReturns as common ratio. */
    10085ResourceSupply.prototype.GetDiminishingReturns = function()
    10186{
    10287    if ("DiminishingReturns" in this.template)
     
    10388    {
    10489        let diminishingReturns = ApplyValueModificationsToEntity("ResourceSupply/DiminishingReturns", +this.template.DiminishingReturns, this.entity);
    10590        if (diminishingReturns)
    106             return (0.5 * Math.cos((this.GetNumGatherers() - 1) * Math.PI / diminishingReturns) + 0.5);
     91        {
     92            let numGatherers = this.GetNumGatherers();
     93            if (numGatherers > 1)
     94                return (1. - Math.pow(diminishingReturns, numGatherers)) / (1. - diminishingReturns) / numGatherers;
     95        }
    10796    }
    10897    return null;
    10998};
  • binaries/data/mods/public/simulation/templates/template_structure_resource_field.xml

     
    4949    <Amount>Infinity</Amount>
    5050    <Type>food.grain</Type>
    5151    <MaxGatherers>5</MaxGatherers>
    52     <!--
    53          See the comment of the function GetTargetGatherRate
    54          of the ResourceGatherer component.
    55     -->
    56     <DiminishingReturns>14</DiminishingReturns>
     52    <DiminishingReturns>0.90</DiminishingReturns>
    5753  </ResourceSupply>
    5854  <Sound>
    5955    <SoundGroups>