A game so long the time was negative - Is the following correct to calculate the time

Greebley

Deity
Supporter
Joined
Mar 28, 2002
Messages
9,756
Location
Boston Area, MA
We just finished up a 362x362 size map with 31 civs going for a conquest win in C3C. The time reported for playing the game was about -491 hours.

A link for anyone curious

I was wondering if it was possible to calculate the real time it took to play. I looked at back saves and the time seemed to go to around 600 hours or so.

Using the logic below I get a total time of 673 hours 42 minutes and 39 seconds

Can anyone confirm or deny that the following is correct. I was thinking maybe the HOF milkers might know :)

I know civ seems to like strange powers of two. For example:
2^5 = 32 civs including barbarians
2^9 = 512 cities maximum
2^13 = 8192 ( or 2^12 = 4096 pre-PTW) units maximum (is this correct?)
362*362 - the largest square map possible - is just a little bit less than 2^17 making me think that 2^17 is the maximum number of tiles possible.

From this, I calculated what power of two was close to 600 hours. It turns out that 2^21 seconds = 582 hours 32 minutes and 32 seconds.

My guess therefore is that this is the time that it wraps around to -582:32:32 hours when it reaches 582:32:32 hours.

Our game had a time of -491 hours -22 minutes and -25 seconds.

So the total time is 582:32:32 + (582:32:32 - 491:22:25) which is the number above.

A game with a positive time of greater than 582:32:32 or that went negative before this would prove me wrong.

A game close to this, or someone else who was curious and investigated could confirm.
 
let's see how many hours we need to figure this out.. :) hope it won't be a negative number again.
 
Your speculation here makes a lot of sense. Powers of 2 are inherently common numbers in the underlying nature of modern computers because the computers are binary. Binary means on/off and that's 2 states. Multiple binary switches result in combinations which enumerate to powers of two.

I think one small adjustment to your theory is likely. Powers of two which are themselves powers of two are even more likely to become evident in computer program algorithms. For subtle reasons, powers of 2 - 1, with the - 1 being applied before or after the power operation, are next most likely. And powers of 2 + 1 are also likely numbers after some maintenance has happened in the code.

Given that, I think it is very likely that what is happening is actually that the time is being internally recorded in milliseconds, and that the limit would be 2^31 milliseconds (a very likely limit, being 2^(2^5-1) and being close to the 2^21 you've guessed modified by another 2^10) before the time gets reported as negative.

If your SG team still have an assortment of save games available then it might be possible to determine the exact limit before the time goes negative by loading various saves and then retiring them. A fairly exact limit might allow us to deduce the underlying storage values and limit :)
 
In the past I have worked on the microcode for ALU's (arithmetic logic unit), the most significant bit usually denotes polarity (1=minus, 0=plus).

In the case of the timer it could just be indicating register overflow.

Seems odd, because it is usually it would be a hardware limitation, similar to what you would find on a calculator. With software they should have been able to make the register elastic, there should be no need for a time limit. They must have just set up a software register with a fixed number of bits.
 
Sir Pleb,
Excellent point on the milliseconds. I was wondering why anyone would have a 22 digit signed number. A 32 digit signed number being a standard in code makes infinitely more sense.
I am fairly convinced you are correct. I may look for a closer save. The closest one I have downloaded was some 70+ hours to short.

The correct time would therefore be: 2 giga-milliseconds (2^31) which is

596 Hours
31 Minutes
23 seconds
648 milliseconds

or

596:31:23.648

Edit: Pounder I suspect the limitation comes from saving the number in the file and storing it in the program. They would store it in 32 bits as a signed integer in software. It is this value that wraps around to negative.
 
Wow. Using a signed long for something that is inherently *positive*? :crazyeye:

I wanna program for Firaxis! :lol:
 
For additional confirmation I have a 1535AD save at 595+ hours and the 1540 save is -594 and a bit

The turn over is definitely around the right time so we can consider the case solved

I agree using an unsigned would have been better. The programmer probably thought, "Who would be crazy enough to play for 600 hours? It just won't happen." :lol:
 
They actually use signed values all the way through the program. Its probably just easier for them to remember them and work with them if they are all the same consistent data type.

And its makes it much easier for us vb-types to muck-around with the save format if all the longs are signed. ;)
 
Greebley said:
We just finished up a 362x362 size map with 31 civs going for a conquest win in C3C. The time reported for playing the game was about -491 hours...Using the logic below I get a total time of 673 hours 42 minutes and 39 seconds ...

I guess there are a lot of people here that are more fanatic than I am...
 
I guess they never counted on a game running that long. I'll move it to the bug reports forum.
 
Top Bottom