{"action":"created","issue":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15775","repository_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA","labels_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15775/labels{/name}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15775/comments","events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15775/events","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/issues/15775","id":140514653,"number":15775,"title":"Fuel consumption","user":{"login":"mugling","id":12238606,"avatar_url":"https://avatars.githubusercontent.com/u/12238606?v=3","gravatar_id":"","url":"https://api.github.com/users/mugling","html_url":"https://github.com/mugling","followers_url":"https://api.github.com/users/mugling/followers","following_url":"https://api.github.com/users/mugling/following{/other_user}","gists_url":"https://api.github.com/users/mugling/gists{/gist_id}","starred_url":"https://api.github.com/users/mugling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mugling/subscriptions","organizations_url":"https://api.github.com/users/mugling/orgs","repos_url":"https://api.github.com/users/mugling/repos","events_url":"https://api.github.com/users/mugling/events{/privacy}","received_events_url":"https://api.github.com/users/mugling/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/labels/Balance","name":"Balance","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-13T18:44:06Z","updated_at":"2016-03-13T20:30:29Z","closed_at":null,"body":"IRL a reasonable **approximation** of fuel consumption would be \r\n* 1000kg vehicle\r\n* 100km/h\r\n* 60L fuel\r\n* 600km\r\n\r\n```\r\nk = 0.1ml/Kg/km\r\nfuel = k * weight * volume\r\n```\r\n\r\nTaking an (outdoor) cataclysm tile as ~100m and presuming the `safe speed` is the most efficient:\r\n\r\n```\r\nk = 0.01ml/Kg/tile\r\n```\r\n\r\n`k` represents engine efficiency and should not differ by more than order of magnitude from the best to worst engine. When rescaled as an integral value:\r\n\r\n| engine                      | k x10⁻³ |\r\n|---------------------------|----------|\r\n| 1-cylinder engine     |  3         |\r\n| V-twin engine           |  9         |\r\n| Inline-4 engine         | 10        |\r\n| V6 engine                | 8          |\r\n| V8 engine                | 6          |\r\n| V12 engine              | 2          |\r\n\r\n\r\nAdding more displacement to an engine increases `safe speed` but doesn't affect efficiency.\r\n\r\nTraveling outside this ideal speed adversely affects fuel efficiency. A normal distribution models this reasonably well (IRL this would be biased against higher speeds).\r\n\r\n![normal_distribution](https://cloud.githubusercontent.com/assets/12238606/13730285/1d7b11ce-e943-11e5-8415-9cde912b261b.png)\r\n\r\nA linear implementation is almost as good and much simpler, taking `v` to be velocity, `s` to be safe speed and `q` to be the proportional efficiency\r\n\r\n```\r\nq = 1 - ( |( v - s )| / s )\r\n```\r\n\r\nAs c++ code\r\n```\r\ndouble q = 1.0 - ( double( std::abs( v - s ) )  / s )\r\n```\r\n\r\nNow lets ignore going under the `safe speed` as most of our vehicles aren't controllable at that speed (and that's a separate issue). We can use the `vehicle::strain()` function...\r\n\r\n```\r\ndouble vehicle::fuel_consumption( double k, int distance ) {\r\n    return k * ( strain() + 1.0 ) * distance * total_mass();\r\n}\r\n```\r\n\r\nNot a perfect system (ignores acceleration, terrain and k-mass) however it does result in sensible fuel consumption and adds the concept of power:weight ratio for engines.\r\n\r\n**tldr; a 1000kg car with a Inline-4 engine and a full tank of fuel can travel a distance of 6000 tiles when driven at the safe speed** "},"comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/comments/196046910","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/issues/15775#issuecomment-196046910","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15775","id":196046910,"user":{"login":"mugling","id":12238606,"avatar_url":"https://avatars.githubusercontent.com/u/12238606?v=3","gravatar_id":"","url":"https://api.github.com/users/mugling","html_url":"https://github.com/mugling","followers_url":"https://api.github.com/users/mugling/followers","following_url":"https://api.github.com/users/mugling/following{/other_user}","gists_url":"https://api.github.com/users/mugling/gists{/gist_id}","starred_url":"https://api.github.com/users/mugling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mugling/subscriptions","organizations_url":"https://api.github.com/users/mugling/orgs","repos_url":"https://api.github.com/users/mugling/repos","events_url":"https://api.github.com/users/mugling/events{/privacy}","received_events_url":"https://api.github.com/users/mugling/received_events","type":"User","site_admin":false},"created_at":"2016-03-13T20:30:29Z","updated_at":"2016-03-13T20:30:29Z","body":"> Displacement doesn't have any downsides\r\n\r\nThis is problematic. The larger displacement engines should at least weigh more and be louder.\r\n\r\n> Something close-to-but-not-linear could be good\r\n\r\nI was struggling with the math. Any suggestions?\r\n\r\n> Optimal speed should probably be much lower.\r\n\r\nChosen as it exists at present. Again open to reasonable suggestions. Possibly half safe speed?\r\n\r\n> a tiny engine pulling a giant truck incredibly slowly shouldn't be able to drain the entire tank in seconds.\r\n\r\nI don't think it can as the algorithm depends on distance and such a vehicle should have incredibly poor (or no velocity) so as to not actually travel any distance"}}