Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Anomalous resource rounding effects

3 views
Skip to first unread message

Justin Ho

unread,
Aug 15, 2001, 11:19:08 PM8/15/01
to
Greetings everyone, I was just doing some work on a stars calculatior
project I'm doing (I really love those exponential curves in stars!) and I
wanted to chart out planetary resource development.. so I wanted to just
write a simple program to chart out some numbers for me and then graph it.
Well anyhow, the long and short of the story is, "What does Stars! do with
decimal rounded numbers?" I took numbers out of an old test bed and got some
intuitiavely disagreeing results. I've created a stripped down bmp file out
of windows paint and going clockwise from the top left this is the data I
got:

Calculated resources = Population/Population eff + factories * resources per
factories

Top left: Displayed resources = 211, Calculated resources = 211.5
Top right: Displayed resources = 251, Calculated resources = 250.3
Bottom left: Displayed resources = 151, Calculated resources = 151.2

Population eff = 1000
resources per 10 factories = 14

It appears that there is a slight disagreement with the numbers generated
here from rounding effects:

Top left should have been rounded up to 212
Top right should have been rounded down to 250
Bottom left is rounded down to 151

At first, I thought this error could have been the result of partialy
constructed factories adding extra resources, but this was not the case
because for the data point from the Top left window has exactly 0.5
resources from calculations but it was rounded down. Also the planet with
the 151.2 resources had a 67% complete factory in the queue but if I added
it in, it would have easily brought the number to 152 resources.

I've tried a test in another test bed and it appears that with colonists
only, *no rounding occurs* of resources (however 1 resource/planet seems to
be the minimum). With another race I with a pop eff of 2500 I dropped 24,900
colonists (9.96 resources) and I got a total of 9 resources, when I dropped
100 more colonists down, it went up to 10. Any thoughts?

Justin


Justin Ho

unread,
Aug 15, 2001, 11:23:34 PM8/15/01
to
I forgot to attach the file to my last msg so I wrote a quick response to my
original message with the file but it isn't appearing on the newsgroup. does
this newsgroup allow attachments?

Justin


Xdudimus Maximus

unread,
Aug 15, 2001, 11:41:55 PM8/15/01
to
"Justin Ho" <2...@34.com> wrote in message
news:W0He7.11304$7h.29...@news2.rdc1.bc.home.com...

Nope


James McGuigan

unread,
Aug 16, 2001, 12:21:51 AM8/16/01
to
Justin Ho <2...@34.com> wrote in message
news:W0He7.11304$7h.29...@news2.rdc1.bc.home.com...

You can post attachments to the group but its generally condsidered bad
netiquette to do so (pics = big files = time to download = phone bill). And
typed text would have taken much less bandwidth and would be easier to quote
in a reply.

Though for future reference if you do HAVE to post pictures, consider not
using bmp format and rather using gif or jpeg format. Your bmp (posted
twice) was 32kb + ~1.5x TCP overhead = 47kb, whereas a quick convert to gif
format gives me a 4kb file (+ TCP = ~6kb). For text comparisons, my article
on the guts of tech trading was 10kb, and the entire rgcs FAQ in text format
was about 32kb.

A picture is worth a thousand words, thats why they take so long to download
:-)

> Calculated resources = Population/Population eff + factories * resources
per
> factories
>
> Top left: Displayed resources = 211, Calculated resources = 211.5
> Top right: Displayed resources = 251, Calculated resources = 250.3
> Bottom left: Displayed resources = 151, Calculated resources = 151.2
>
> Population eff = 1000
> resources per 10 factories = 14

As for your question, stars uses alot of integer maths, which basically
means it doesn't store fractions in any of its calculations.

Here's a possability as to whats happening:


Case 1:
65,900 pop = 65.9 = 65 res (always round down)
104 facts * 1.4 = 145.6 = 146 res (always round up)
Total = 211.5 = 211 res

Case 2:
113,100 pop = 113.1 = 113 res (always round down)
98 facts * 1.4 = 137.2 = 138 res (always round up)
Total = 250.3 = 251 res

Case 3:
72,800 pop = 72.8 = 72 res (always round down)
56 facts * 1.4 = 78.4 = 79 res (always round up)
Total = 151.2 = 151 res


Not sure if this is the case in actuallity, but seems to fit the bill.


--
Rules are written for those who lack the ability to truly reason,
But for those who can, the rules become nothing more than guidelines,
And live their lives governed not by rules but by reason.
- James McGuigan

The Stars! FAQ (www.starsfaq.com)


Justin Ho

unread,
Aug 16, 2001, 1:39:41 AM8/16/01
to
Okay then, sorry about my ignorance, I'll make note of that from now on
then. I think you might be right about the rounding bit. It seems consistent
with the resource calculations.

Justin


Henk ter Maat

unread,
Aug 16, 2001, 4:17:11 AM8/16/01
to
Hi,

Could it be that pop recourses are always rounded down, while factory
recouses are always rounded up.

Not particulairy logical, but it does explain the obtained results

65900 65.9 down 65
104 145.6 up 146
211.5 211

72800 72.8 down 72
56 78.4 up 79
151.2 151


113100 113.1 down 113
98 137.2 up 138
250.3 251

Henk

Justin Ho <2...@34.com> heeft geschreven in bericht ...

Timothy Little

unread,
Aug 16, 2001, 5:34:17 AM8/16/01
to
Justin Ho <2...@34.com> wrote:
>Top left: Displayed resources = 211, Calculated resources = 211.5
>Top right: Displayed resources = 251, Calculated resources = 250.3
>Bottom left: Displayed resources = 151, Calculated resources = 151.2
>
>Population eff = 1000
>resources per 10 factories = 14
>
>It appears that there is a slight disagreement with the numbers generated
>here from rounding effects:

[...]
> Any thoughts?

The internal calculations could be handled in a number of different
ways by the programmers. The simplest would probably be fixed-point
binary, i.e. X/2^n for some n. Another common method is fixed-point
decimal, e.g. X/10^n for some n, used a lot in accounting software
with n=2. Other methods I've seen used include handling the
fractional portion separately from the integer portion, and of course
*many* programs use floating point arithmetic. Each method and
implementation ends up with different round-off characteristics.

Representations might also be changed part-way through a calculation,
or different representations might be used for different sub-
calculations. In fact, that is quite likely here since Stars! was
written to run efficiently on older computers, rather than to be as
precise as possible.

For example, the colonist resources might be calculated via integer
division (rounding down). The factory resources may be calculated by
fixed-point decimal, rounding up, then added to the colonist
resources. i.e.

res = ceil(factories * fact_eff / 10) + floor(pop / pop_divisor)

My brief 20-year test seems to match this pattern precisely. It would
be relatively trivial to trace the code and discover *exactly* what
method is used to do the calculation. But also relatively pointless.


- Tim

O.L....@thecontrols.net.invalid

unread,
Aug 16, 2001, 6:14:37 AM8/16/01
to
On Thu, 16 Aug 2001 05:21:51 +0100, "James McGuigan"
<ja...@starsfaq.com> wrote:

>Justin Ho <2...@34.com> wrote in message
>news:W0He7.11304$7h.29...@news2.rdc1.bc.home.com...
>> I forgot to attach the file to my last msg so I wrote a quick response to
>my
>> original message with the file but it isn't appearing on the newsgroup.
>does
>> this newsgroup allow attachments?
>>
>> Justin
>
>You can post attachments to the group but its generally condsidered bad
>netiquette to do so (pics = big files = time to download = phone bill). And
>typed text would have taken much less bandwidth and would be easier to quote
>in a reply.
>
>Though for future reference if you do HAVE to post pictures, consider not
>using bmp format and rather using gif or jpeg format. Your bmp (posted
>twice) was 32kb + ~1.5x TCP overhead = 47kb, whereas a quick convert to gif
>format gives me a 4kb file (+ TCP = ~6kb). For text comparisons, my article
>on the guts of tech trading was 10kb, and the entire rgcs FAQ in text format
>was about 32kb.
>
>A picture is worth a thousand words, thats why they take so long to download
>:-)
>

<snip>

The conventional way of dealing with binary files for text-only groups
is to post the file to an appropriate binary group - e.g.:


alt.binaries.images for image files;
alt.binaries.games, alt.binaries.ibm-pc.games for game utilities;

and so on.

One simultaneously posts a short text message in the main group
announcing the names of the file and the binary group to which it is
being posted, and outlining the content.

Use a distinctive name for the file - some binary groups get many
thousands of messages daily and "001.jpg" as a title will likely not
be terribly popular or useful.

The advantages are that no-one gets upset and flames or LARTS you;
also, a number of ISPs and news providers filter binaries from
text-only groups, so that messages with attachments propagate poorly
or not at all.

With a few exceptions, if a group does not say "binary" or "binaries"
in the name, it is text-only. If in doubt, ask. You thus avoid being
flamed or having complaints sent to your ISP.

Regards

O.L.Fogey
--
http://www.thehungersite.com
http://www.thelandminesite.com

Dirk Thierbach

unread,
Aug 16, 2001, 2:51:35 PM8/16/01
to
Justin Ho <2...@34.com> wrote:

> I've tried a test in another test bed and it appears that with colonists
> only, *no rounding occurs* of resources (however 1 resource/planet seems to
> be the minimum). With another race I with a pop eff of 2500 I dropped 24,900
> colonists (9.96 resources) and I got a total of 9 resources, when I dropped
> 100 more colonists down, it went up to 10. Any thoughts?

I don't know if this helps explaining the ressource rounding, but the
population on a planet has more significant digits than are accessible
in the user interface. I discovered this when tech trading with an
ally with minimum pop (100) on a red planet, and from time to time my
population would die off for no apperent reason. From that time, we
used 200 pop each :-)

So 24,900 cols dropped mean 24,900-24,999 pop, while 25,000 cols
means 25,000-25,099 pop. Does that explain your rounding errors?

- Dirk

Gemmy Tsai

unread,
Aug 16, 2001, 7:22:17 PM8/16/01
to
"James McGuigan" <ja...@starsfaq.com> wrote in message news:<yVHe7.106$0c2....@news2-win.server.ntlworld.com>...

> As for your question, stars uses alot of integer maths, which basically
> means it doesn't store fractions in any of its calculations.
>
> Here's a possability as to whats happening:
<snip>

> Not sure if this is the case in actuallity, but seems to fit the bill.

Sounds right to me, James. I vaguely remember a discussion somewhere
about this before. Your theory is consistent with all pop/resource
calculations I can recall.

Gemmy
------------
check out the Stars! Village
http://starsv.sphosting.com
------------

LEit

unread,
Aug 17, 2001, 9:51:56 AM8/17/01
to
Dirk Thierbach <dthie...@gmx.de> wrote in message news:<9lh4nn$274$2...@sun27.hrz.tu-darmstadt.de>...

> I don't know if this helps explaining the ressource rounding, but the
> population on a planet has more significant digits than are accessible
> in the user interface. I discovered this when tech trading with an
> ally with minimum pop (100) on a red planet, and from time to time my
> population would die off for no apperent reason. From that time, we
> used 200 pop each :-)
>
> So 24,900 cols dropped mean 24,900-24,999 pop, while 25,000 cols
> means 25,000-25,099 pop. Does that explain your rounding errors?

What I've noticed is that pop in freighters is always in even 100
amounts. The only real way to notice this is to see it happen to IS.

Pop on worlds seems to go down to a single being, although you always
see it in even 100s, you can see this by watching growth, it only
works if you keep track of the pop to a finer detail then 100. To
check this you could make a race with 9% growth and colonize a world
with 1100 pop, it should grow to 1199, which I'd guess would be
reported as 1100, the following year it would grow another 99 to 1298
(reported as 1200).

I've also noticed that factories tend to round up, I don't know if
it's absolute, but it's easy to check, make a race with 11/x/x
factories and build 1.

Population rounds down execpt you get a minimum of 1 resource from any
amount of pop.

Yuca Frita

unread,
Aug 17, 2001, 5:44:04 PM8/17/01
to
pro...@hotmail.com (LEit) wrote in message news:<e005e655.01081...@posting.google.com>...

I'm not so much interested in those rounding details because they
don't really affect gameplay. However, I had a specific case which
affected me. I had colonised several red planets with a 1WW JoaT race
in a game, and had saturated them with factories and mines. At one
moment I decided to build some cheap minesweepers and found out that
the small red planet with optimum pop (just at the level to operate
the fact/mines [66000] so as to not overkill colonists) was not
producing what it could in theory (and was displayed on the pane).

I don't remember the numbers right now (I have the backup if needed),
but let's say I had just 200 ressources on this world and the
production window said I could build 25 frigates (appeared in green).
However on the next turn, only 22 were built, one partly built and 2
more in queue. I thought "well, production occurs after pop kill,
that's why", but the Order of events says the contrary. They I checked
if those missing ressources corresponded to the pop lost, but even
with the lesser pop and less mines/fact operated, I was still able to
put 24 frigates in *green* queueing. The miss was far greater than one
year of pop kill. With overpop, the same thing happened.

So I just concluded there was some bad rounding error and I assumed
about 10% of the displayed ressources on that red was not real, and
played that way :(

I suppose this has already been pointed out?

YucaF

Sean

unread,
Aug 18, 2001, 12:02:27 PM8/18/01
to
>What I've noticed is that pop in freighters is always in even 100
>amounts. The only real way to notice this is to see it happen to IS.

Hmm, so with the right growth rates, an IS flying orgy might actually grow
BETTER than a 50% world ... ? Maybe as well as a 55% world ... ?

Hmm. This might bear looking-at ...
-- Sean

[This post, and its content, are intended solely for this newsgroup and are
Copyright 2001. Forwarding or access by any other means is unauthorized without
the express prior written permission of the author.]

Loren Pechtel

unread,
Aug 18, 2001, 12:23:24 PM8/18/01
to
On 17 Aug 2001 14:44:04 -0700, yu...@hotmail.com (Yuca Frita) wrote:

>I don't remember the numbers right now (I have the backup if needed),
>but let's say I had just 200 ressources on this world and the
>production window said I could build 25 frigates (appeared in green).
>However on the next turn, only 22 were built, one partly built and 2
>more in queue. I thought "well, production occurs after pop kill,
>that's why", but the Order of events says the contrary. They I checked
>if those missing ressources corresponded to the pop lost, but even
>with the lesser pop and less mines/fact operated, I was still able to
>put 24 frigates in *green* queueing. The miss was far greater than one
>year of pop kill. With overpop, the same thing happened.
>
>So I just concluded there was some bad rounding error and I assumed
>about 10% of the displayed ressources on that red was not real, and
>played that way :(
>
>I suppose this has already been pointed out?

This is a different, known issue. The cost of ships on *YOUR*
screen is displayed as a whole number. This is actually rounded off,
however, and the construction calculation uses the unrounded number.

Yuca Frita

unread,
Aug 19, 2001, 1:10:09 AM8/19/01
to
lorenp...@hotmail.com (Loren Pechtel) wrote in message news:<3b7e9051....@nntp.vegasnet.net>...

OK, I've checked up my backup. The design is a FF+QJ5+gatling gun,
costing 19 ressources on the screen. This is probably the number you
mean is rounded, because miniaturization kicks in and affects as a
percentage. I had weap16, Con16 and Prop 12.

Now I have 281 ressources at the planet and I can put 14 ships in
queue, and they appear in green. This corresponds well to
281/19=14.789 . If I add one ship to the queue, it becomes blue
indicating that the 15th will be build in 2 years. So far, logic.

Next year, I get 12 ships built, and 2 left in queue, indicating that
one is built at 80%. Even with rounding, I should have got 13 ships,
not 12. Or am I misunderstanding something?

Is it possible that the rounding is done on a ship-by-ship basis? What
happens to the ressources? Are they lost?

YucaF

Loren Pechtel

unread,
Aug 19, 2001, 12:07:12 PM8/19/01
to
On 18 Aug 2001 22:10:09 -0700, yu...@hotmail.com (Yuca Frita) wrote:

>OK, I've checked up my backup. The design is a FF+QJ5+gatling gun,
>costing 19 ressources on the screen. This is probably the number you
>mean is rounded, because miniaturization kicks in and affects as a
>percentage. I had weap16, Con16 and Prop 12.
>
>Now I have 281 ressources at the planet and I can put 14 ships in
>queue, and they appear in green. This corresponds well to
>281/19=14.789 . If I add one ship to the queue, it becomes blue
>indicating that the 15th will be build in 2 years. So far, logic.
>
>Next year, I get 12 ships built, and 2 left in queue, indicating that
>one is built at 80%. Even with rounding, I should have got 13 ships,
>not 12. Or am I misunderstanding something?
>
>Is it possible that the rounding is done on a ship-by-ship basis? What
>happens to the ressources? Are they lost?

It's the 19 that I was saying is rounded off. However, this is
really strange as even a 19.9 cost still gives 14 ships produced. I'm
puzzled at this point!

Yuca Frita

unread,
Aug 20, 2001, 2:02:18 AM8/20/01
to
lorenp...@hotmail.com (Loren Pechtel) wrote in message news:<3b7fe384....@nntp.vegasnet.net>...

Yes, and I forgot to mention that I had several planets like that with
exacly the same ressources and the same thing happened on every
planet, turn after turn so it has to do with some internal code not
behaving well. I haven't seen that happening on a green planet however
(beware: I haven't tested that last affirmation).

YucaF

Chris Schack

unread,
Aug 19, 2001, 9:50:23 PM8/19/01
to
In article <20010818120227...@mb-mf.aol.com>,

gm...@aol.comp.com (Sean) wrote:
>>What I've noticed is that pop in freighters is always in even 100
>>amounts. The only real way to notice this is to see it happen to IS.
>
>Hmm, so with the right growth rates, an IS flying orgy might actually grow
>BETTER than a 50% world ... ? Maybe as well as a 55% world ... ?
>
>Hmm. This might bear looking-at ...

Freighter growth is rounded DOWN.

Chris Schack

0 new messages