Page 1 of 1

Planet lists on the Wiki

Posted: Sat Mar 24, 2007 6:30 pm
by Uncle Reno
I'm working on a mission OXP in galaxy (see, no capital g :wink: ) 1 and when I use the planet numbers from the Wiki in my scripts I have to subtract 1 from the number listed to get the right planet. Have other people encountered this and is it the same for all of the other galaxies?
If it is the same for all galaxies I will put a note of this requirement on the Wiki.

Posted: Sat Mar 24, 2007 6:35 pm
by LittleBear
Yep!

Always have to substact 1. G 1 = G0 and planet number 1 equal 0.

Previous version of the planet numbers started at 0. The current one does not. No biggy, just have to remember that that "planet_number" for scipting is one less than the number on the Wikki.

Posted: Sat Mar 24, 2007 6:50 pm
by Uncle Reno
OK, I knew about the galaxy number needing to have 1 subtracted from it, and the Wiki does say that, but I thought I would double check about the planets. Thanks! :)

Posted: Mon Mar 26, 2007 10:15 am
by Commander McLane
And the same is true for all the other values: techlevel 0 in the list means techlevel 1 in the game. Things like government-type are usually not visible as numbers, but they are handled in the same way, from 0 to 7.

That's simply because (as the veterans know) in the old days these values were stored in one byte only (or even parts of it only!). One byte can take values from 0..255, not 1..256. For the range 0..7 you actually need three bits only (one byte has eight), so you can store techlevel plus government type in one byte only and still have two bits left that can serve as a flag (on/off) for a certain action or a piece of equipment that you have or have not.

Programming used to be very economically in the old days of Elite. (There was even a TV computer show in german TV, where the presenters used a "thumb up" gesture as a greeting, meaning: You should always have one byte left in your computer's RAM when you have finished your program.)

-----

Thinking about it again it seems more likely that the old Elite generated an array of information about each planet in a galaxy. But the issue is still the same: Internally each computer starts counting with 0, not with 1, and that's what we all had to learn and adapt to when we started our first programming exercises in BASIC. So the first item in the array has the ordinal number 0, not 1. You could of course still have filled the positions 1..256 (instead of 0..255) in the array, but that would have meant wasting valuable RAM, because the array would have been bigger (reaching from 0..256 instead of 0..255) and the empty position 0 would have needed the same amount of RAM as all the filled positions. So you simply started counting from 0, as the machine did.

Posted: Mon Mar 26, 2007 10:47 am
by JensAyton
Commander McLane wrote:
That's simply because (as the veterans know) in the old days these values were stored in one byte only (or even parts of it only!). One byte can take values from 0..255, not 1..256.
Actually, the reason is that the convention in low-level programming languages (and mathematics) is to start counting from zero. :-)