Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input/Output calculations being off due to rounding #10

Closed
Leif-The-Head opened this issue Sep 26, 2022 · 4 comments
Closed

Input/Output calculations being off due to rounding #10

Leif-The-Head opened this issue Sep 26, 2022 · 4 comments

Comments

@Leif-The-Head
Copy link

I don't know why you came up with "let's round the value of production cycles per time unit down" (even at all), but it's a huge oversight as it just throws off the numbers completely.
Let me put a brief example:
A refinery making petrol from oil will show up as producing/consuming 0 per minute because the production cycle is 150s, and if you try to divide 60 by 150 and round that down, that is simply 0.
Same is for oil wells, where 60 by 50 would be 1.2, but it's rounded down to 1, so it shows as 50 per minute despite actually being 60.
For both the value shows correctly for 1 hour, because 3600 is nicely divided by both 150 and 50 to clean values of 24 and 72 respectively, which do not need any rounding thus calculate correctly.
Instead take a cracking unit, which has a cycle time of 160s, which would be 22.5 cycles per hour, and it calculates only 22 cycles ...
I think you get the issue, the rounding shouldn't be there at all.

let productionTime = Math.floor(this.time / production.time);

@jimdcunningham jimdcunningham self-assigned this Sep 26, 2022
@Leif-The-Head
Copy link
Author

For rounding the displayed values, you can do so from here, but I'd suggest to only truncate to two decimals:
https://github.com/brandon-ray/foxhole-facility-planner/blob/master/public/menu/components/buildMenu.js#L396

@brandon-ray
Copy link
Owner

Hey thanks, feel free to make a PR

@Leif-The-Head
Copy link
Author

Feel free to keep a planner with wrong calculations, I already pointed out the exact spot where it goes wrong, you have the workspaces set up to literally delete a snippet and push a single button.

@brandon-ray
Copy link
Owner

Actually I think your math is off because of how the game works:
"Instead take a cracking unit, which has a cycle time of 160s, which would be 22.5 cycles per hour, and it calculates only 22 cycles ... I think you get the issue, the rounding shouldn't be there at all."

If there are 22.5 cycles per hour, the .5 is not completed yet so if we added that to the calculation its actual output will not be for another 80 seconds. The amount produced does not increase as the time does, all of the actual "resource creations" happens at the end of the 160s. If it was incremental and made that amount over time that would make sense, but with how the game handles production the math is correct as is.

AlecWhite added a commit to AlecWhite/foxhole-facility-planner that referenced this issue Sep 26, 2022
Hopefully fixes brandon-ray#10 and any other non-1-hour interval for accuracy's sake.
Ideally it would need truncation of display value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants