vkholodkov / freestars Goto Github PK
View Code? Open in Web Editor NEWNext step in FreeStars, a Stars! clone project
License: GNU General Public License v2.0
Next step in FreeStars, a Stars! clone project
License: GNU General Public License v2.0
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!?)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.