Population

kirkham7

Warlord
Joined
Dec 22, 2012
Messages
288
Location
Hayward, CA
Hey guys, I've been playing everyday on a single game. Using Darkpanda's wonderful mods, I have been able to play on Emperor by myself. I just got my population over 320 million (or so), and now it reads -190,000. Anyone ever seen this before?
 

Attachments

  • civ_pop.jpg
    civ_pop.jpg
    293.9 KB · Views: 373
I haven't tried this, but I can tell you why it happens :)

Civilization stores the population of your empire as a 16-bit signed integer to which it appends a "0,000" string when displaying (in other words it effectively multiplies this number by 10,000).

16-bit signed integers can take on the values from −32,768 to 32,767. This means your empire can have a maximum population of 32,767 * 10,000 = 327,670,000 at which point the number would overflow and become negative.

Since there is no practical reason why your population should be able to be negative Darkpanda might be able to "postpone" this effect by changing the arithmetic operations on the number from signed to unsigned. This would postpone the problem until a population of 656,360,000 at which point your population reset to 0.

An actual fix of this would be difficult I think as you would need to reserve more memory for the number.
 
In fact, the total population is not stored anywhere in memory as a variable but recomputed every time necessary: citypop*(citypop+1)/2 summed over all cities.

As weevil states, the displayed Civ pop is just a trick, padding the string "0,000" after the 16-bit integer.

Also, since CivDOS is purely a 16-bit game, I don't think it can support unsigned arithmetic...
 
Apologies for animating a year-old thread, but haven't seen this question answered explicitly in this forum. The 16-bit limitation on population only affects the reported number on the demographics page and the civ-summary sheet, right?

What i means is, your civscore on Judgement Day is tallied by a city-by-city summation of citz, not your total civ-wide population. Or no?
 
Top Bottom