I am attempting to create a game where there is a universe of two 16-bit addresses ranging from (-32768, -32768) to (32767, 32767), or in hexadecimal, each value can run from $8000 to $FFFF then 0 to $7FFF, although the universe is probably not going to use the whole 4 billion possible addresses.
What I want is for any location, given the two values, to return a value from 0 to around 15 or 20. Where:
- 0 is empty space.
- 1 to 9 are planet technology levels, with a level 1 planet being less developed than 2, which means a level 5 planet can build up to a level 5 hull, warp drive or shield, but to upgrade to level 6 requires going to a level 6 or higher planet, or possibly paying a horribly high price.
- 10 and above are for anomalies, e.g. black holes, suns and other things which have an effect such as random movement or increase in power.
While the most common value will be zero, the universe should have some minimum non-zero locations, e.g. 10% or 20% or some reasonable number of the locations are planets or anomalies.
Note the alignment factors are not random, the value should be calculated so that -60,12 returns the same planetary value any time it's called. I've seen this done in a simple formula amounting to less than 5 lines of code but that was 30 years ago, and I don't have the math to do the calculations myself.
Any help would be appreciated.