Giter VIP home page Giter VIP logo

freestars's People

Contributors

vkholodkov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

freestars's Issues

get_resources rounding inconsistency

I am assuming that freestars wants to copy stars! default behaviour as much as possible.

In my testing for our python stars clone I came across the following: (http://starsautohost.org/sahforum2/index.php?t=msg&th=5405&prevloaded=1&rid=1803&start=150#msg_num_4)

To mimic stars! behaviour, I had to set factory resources to round up production. Since stars! seems to round down everywhere, this strikes me as quite odd, and the freestars code (Planet.cpp +888) also just uses integer math, and even seems to round down factory and population production separately.

Test case: start a new game as humanoids but with factory efficiency, produce two factories, end turn. You now have 28.7k pop and 12 factories, which should produce 28.7 + 12_.9 = 39.5 resources, which matches the 39 displayed by stars!
End turn again. You now have 33k pop and 12 factories. This should yield 33 + 12_.9 = 43.8 resources, but stars! reports 44.
So, it seems that pop production is rounded down, but factory production is rounded up.

This is matched on a new planet: If I colonize a new planet (ie no factories), I get 1 resource for pop up to 1900, 2 up to 2900, etc; so it's rounded down with a minimum of 1. If I build a single factory (which should yield .9 resources) I get 2 resources for population up to 1900. With 10k pop and 8 factories, I get 18 resources, while 10+8*.9=17.2.

The relevant Planet.cpp code seems to not capture this:

Res = facts * GetOwner()->FactoryRate() / 10;
Res += pop / GetOwner()->PopEfficiency();

Since res is long, it is rounded down after computing factory resources and again after computing population resources. So, for the 28.7k pop + 12 factories you would get

Res = 12 * 9 / 10 = 10.8 --> 10 (long)
Res += 28700 / 1000 -> Res += 28.7 -> Res = 38 (compared to stars! reporting 39)

So, am I correct that factory production is rounded up (and hence is the freestars implementation inconsistent with stars!?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.