Archived

This topic is now archived and is closed to further replies.

Endurion

Reverse RNG? Sentinel style game

Recommended Posts

Hi all, i''m stumbling upon a problem in my game. I''m trying to write a game like "Sentinel" (C64,Amiga,...). I got the game itself up and running, works like a charm. The first problem, seeded landscape generating, is solved. But i would like to take the next step. In the original game the player could enter a level number (0 up to 9999), and after that a 8-digit level-code, which obviously was also the seed for that level. So far no problem yet. What troubles me, is how to calculate which code refers to which level? In other words, for every level there was only one code. Therefor my thought is that the code also somehow could be used to calculate the level number. How could someone determine if the code was the correct one? I don''t want to use a lookup table. It should be calculated straight from the code. The level is generated via a simple pseudo random generator, i would like to use the same generator (if it is done this way) for telling whether the level code was correct. I''d appreciate any help, thoughts or hints! Thanks in advance, Endurion

Share this post


Link to post
Share on other sites
Well, obviously you can't pick 2 distinct number ranges (level numbers and level codes) with different domains and expect them to have a perfect 1 to 1 mapping. One of them has to be deterministically generated from the other. In this case you want the level code to be generated from the level number.

Personally I can't see an easy way to ensure that 99.9% of your level codes are automatically invalid. Perhaps what you need to do is to deterministically generate 2 4-digit numbers from your initial 4 digit number, then combine them into the 8 digit number you need. You can ensure a 1 to 1 mapping this way. I would be tempted to use a lookup table though (and I know you said you didn't want to) because I can't think of any other good mapping beyond something simple like 9999-x, rearranging the digits, or some combination thereof.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

[edited by - Kylotan on December 25, 2002 10:51:55 AM]

Share this post


Link to post
Share on other sites
Kylotan:
the suggestion to split the 8-digit number in two sounds like a good approach. I will look into this further

LilBudyWizer:
I might as well try that, easy to implement. I will have to test the RNG for the different codes to look different enough to each other.

Thanks for the replies!

Endurion

Share this post


Link to post
Share on other sites
Wasn''t your problem trying to determine the level number from the level code? It would be easy if you could just generate a random code based on the level, but how would this help you go backwards? The essence of this problem is using/creating a 1-to-1 RNG, but one where the original seed can be determined given a generated value.

Share this post


Link to post
Share on other sites
quote:
Original post by Zipster
Wasn''t your problem trying to determine the level number from the level code? It would be easy if you could just generate a random code based on the level, but how would this help you go backwards? The essence of this problem is using/creating a 1-to-1 RNG, but one where the original seed can be determined given a generated value.


nope. as the user first enters the level number, and then the code, he can just generate the code from the entered number, and compare to the code the user entered..

(did i got that right?:D)

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites
I implemented LilBudyWizers method, since it meant the least work )

I simply use the level number as seed and the next 8 random numbers make up the level code. They codes look different enough (you cannot tell by looking at one code which range of levels it will end in).

And since i have the user enter the level number comparing is a piece of cake

Thanks again everybody for replying!

Share this post


Link to post
Share on other sites
quote:
nope. as the user first enters the level number, and then the code, he can just generate the code from the entered number, and compare to the code the user entered..

Ahhh, I thought it was one of those password type things where you type in a code to get to a certain level, assuming the code is valid and represents a level at all

Share this post


Link to post
Share on other sites