NationStates Jolt Archive


a question about the phsyical code of ns

21-10-2003, 16:22
i was thinking about the populations of the nations in ns, and a question occured to me. how big can a nation grow? basically it is limited by the size of the variable used.

so my question is how big is the variable? two bytes (approx 65,500 million), four bytes (approx 4.3 X10^9 million), etc., or is it a string with some code attached?
Trixia
21-10-2003, 16:26
If the letter 'H' was my head.

The answer to your question would be about.


Here




H



Which means, yes you've guessed it, it's way over my head.

Trix
Making NS a better place for everyone, i hope.
And my name is a mans name!!!!
Tactical Grace
21-10-2003, 16:59
As far as I know, this game is written in Perl, so I do not know the answer to your question, but I believe you are thinking of fairly low-level languages. In a high-level language such as C, for example, using the right class of variable would allow for incremental growth which can be considered infinite as far as national populations in this game are concerned. It is likely that the coding for this game too, could theoretically allow populations in the trillions or even hundreds of trillions without running into problems.

Tactical Grace
Forum Moderator
21-10-2003, 17:10
It is likely that the coding for this game too, could theoretically allow populations in the trillions or even hundreds of trillions without running into problems.

using the perl equivalent of a 4 byte unsigned integer nets you a population of approximately 4.3 million trillion.

but i recall it somewhere being said that ns was not intended to be played for a very long time. so i'm just wondering if/when we will be seeing any effects of variable size on populations.
Juxtapositions
21-10-2003, 17:23
As a card carrying geek I can't let this slide by without some type of comment.

l
In a high-level language such as C, for example, using the right class of variable would allow for incremental growth which can be considered infinite as far as national populations in this game are concerned.

C has no classes although C++ does. There are no variables in the C language which allow infinite growth of a number and no classes I've run up against in C++ which will do that although I could conceive of a class that would. The code is written in a modified version of PHP (or so I think I remember reading although TG is saying it's in PERL) and PHP does automatically adjust it's variables so the limitation would not be PHP.


It is likely that the coding for this game too, could theoretically allow populations in the trillions or even hundreds of trillions without running into problems.

I would guess that the lmitation would be in the database rather than in the representation of the population by variable type in the code. It is most likely (Assuming mysql type database) a VARCHAR(?) where the question mark is the variable that needs to be filled in by Violet to get to the bottom of this.


FREE ARCHITEUTHIS!
SalusaSecondus
21-10-2003, 17:42
Perhaps I can answer? The main program is written in Perl and I believe that population is stored as a standard cardinal value. What the limit of that is in Perl? I don't know (4 bytes would grant populations between -2147483648 million and 2147483647 millon). As this will take (by my rough estimations) in excess of 500,000 years, I don't think that it should be an issue.


http://www.weirdozone.0catch.com/projects/nationstates/salusasecondus/salusasecondus2.jpg
SalusaSecondus
Tech Modling
PGP: 0x0604DF3E
Ballotonia
21-10-2003, 19:42
Even if the maximum population were a paltry 32767 (signed two-bit integer) million, that still equates to about 16 years gametime, not counting the consequences of the population bug. So... please do remind us of this issue 10 years from now :D

Ballotonia
Cogitation
21-10-2003, 21:15
Perhaps I can answer? The main program is written in Perl and I believe that population is stored as a standard cardinal value. What the limit of that is in Perl? I don't know (4 bytes would grant populations between -2147483648 million and 2147483647 millon). As this will take (by my rough estimations) in excess of 500,000 years, I don't think that it should be an issue.

Are you sure NationStates isn't going to last that long? :?

...

/me snickers.

--The Jovial States of Cogitation
"Laugh about it for a moment."
NationStates Self-Proclaimed Court Jester