Posted: 18th September 2007 01:01
|
|
![]() Posts: 100 Joined: 19/8/2007 Awards: ![]() ![]() ![]() |
I was playing FFVI on an emulator yesterday, and noticed something a little weird...
I was fooling around at Kefka's Tower and was getting annoyed having my under-leved killed by Great Behemoths and the like over and over to the point where I was pissed off enough to resort to save states. I decided to save every step, and then load the previous save state whenever I encountered something. I step on to a square, started a battle, BOOM reload save state. I stepped onto the square, and the battle started again, with the same enemy formation. I did this a couple times with the same results. I tried again in various places throughout the tower and other places such as the world map, with same results. But I also found that going back and forth over any two tiles over and over will initiate a random battle. So my guess is that there is a random battle encounter rate, but there are also tiles with battles on them littered throughout the landscape. -------------------- "So imagine Kefka swearing and yelling that he'll take revenge, but doing so in a way that's... somehow... polite and feminine." |
Post #157331
|
Posted: 18th September 2007 02:34
|
|
![]() Posts: 2,350 Joined: 19/9/2004 Awards: ![]() ![]() |
There is no such thing as a random number. No algorithm exists to generate a perfectly random number, much less within the world of computing. So games have to simulate random numbers.
The way the SNES usually does it (games are responsible for their own implementation of this) is to create a big table of 256 "random" numbers, embed it into the ROM, and point the game off at the first entry. Whenever the game needs to generate a random number, the game moves to the next entry and reads the value there. Once it reaches the final entry, it loops back to the first one. Some games have a timer-based method of handling this. Others, like FFVI, don't. Therefore, in a nutshell, so long as you don't do anything that may call for a random value (and thus, move the index to a different entry in the table,) the next random value pulled by the game will be the exact same everytime when you reload a saved state. Note that FFVI has a couple of different indexes into its random number table, so not every "random" action will affect the outcome of another "random" action. Long story short, I can assure you there are no "random encounter" tiles (although stepping on a tile can trigger a scenario event which may lead to a battle, but obviously we're not talking about that.) It's all handled by the above random number generator. Try using a healing item or spell, reload, and use the same item again on the same people. Bam - same numbers. ![]() This post has been edited by Silverlance on 18th September 2007 02:38 -------------------- "Judge not a man by his thoughts and words, but by the quality and quantity of liquor in his possession and the likelyhood of him sharing." |
Post #157336
|
Posted: 18th September 2007 15:34
|
|
![]() Posts: 734 Joined: 8/7/2004 Awards: ![]() ![]() ![]() |
Ummm could you translate that into laymans trems?
-------------------- Don't fear the reaper! Wonderful system this "Democracy" is no mechanism to break a tie -Dinobot- It's spelled Raymond Luxray Yatch but it's pronounced Throat Wobbler Mangrove. Vi Veri Veniversum Vivus Vici Sic Semper Tyrannis bush. |
Post #157352
|
Posted: 18th September 2007 16:59
|
|
![]() Posts: 869 Joined: 28/9/2002 Awards: ![]() ![]() ![]() ![]() ![]() |
He basically said that just reloading a save state and walking again won't change the encounter you're going to get because of the way the random number generator works you need to do something different before hand, like using a potion on a character that you didn't before. Seems pretty summed up in that last statement he made, really.
-------------------- This one time I punched a bear in the forehead TO DEATH! I still have the scars on my chest. I am the manliest man that ever did man. League: Z3roHawk Steam: Zero_Hawk Wii U: Zero_Hawk FF14 - Goblin - Zero Hawk <Fiend> |
Post #157355
|
Posted: 18th September 2007 22:18
|
|
![]() Posts: 2,350 Joined: 19/9/2004 Awards: ![]() ![]() |
Quote (Zero_Hawk @ 18th September 2007 11:59) He basically said that just reloading a save state and walking again won't change the encounter you're going to get because of the way the random number generator works you need to do something different before hand, like using a potion on a character that you didn't before. Seems pretty summed up in that last statement he made, really. That's pretty much it. In game terms, it basically looks like this... Picture this: you have a bunch of dice, say 4. You roll them all and line them up side by side. Whenever you want a random number, you take the first dice from the left (and remove it from the line afterwards.) Until then, you don't touch them. Ever. Here are the dice: 1 6 4 3 If you save-state, you also save-state that row of dice exactly like it was before. This is important. Now you take a step. Let's suppose rolling a number under 2 gives an encounter. So anyway, we take the first dice (1.) It's under 2. The game gives us a random encounter. Here are the dice now: 6 4 3 (the "1" is missing because we used it up.) We reload our saved state. Now the line of dice is back the way it was (1 6 4 3.) If we take a step, we'll pick the first dice (1) again, and still get a random encounter. No matter how often we reload. This time, let's reload our saved state (the dice are back the way they were, ie 1, 6, 4, 3...) and cast cure, which restores a somewhat random number of health. We take a dice (1) from the line. Here are the dice now: 6 4 3 (the "1" is missing because we used it up for our cure spell.) NOW we take a step without reloading. Again, we take the first dice from the left from the remaining ones: 6. It's above 2, so there's no random encounter this step. I'm not sure if this made any more sense. Zero_Hawk summed it up pretty well, though. The game does things ALMOST exactly like the above, only it uses numbers from 0-255 instead of 1-6 and there are 256 "dice." This post has been edited by Silverlance on 18th September 2007 22:20 -------------------- "Judge not a man by his thoughts and words, but by the quality and quantity of liquor in his possession and the likelyhood of him sharing." |
Post #157365
|
Posted: 21st September 2007 19:32
|
|
![]() Posts: 759 Joined: 3/12/2006 Awards: ![]() ![]() ![]() |
I wanna roll 256 bi-cento-bi-deca-hex-ihedrons. (It's probably the wrong words, but the meaning is there
![]() So here's my question about it, when does the game "roll" these dice? On startup? or is it pre-determined rom patterns? Laymans terms for anyone who wants it: Will the numbers I load one time, be the same as the numbers I load a second time? -------------------- If internal struggles were as enjoyable and glamorous as the self conflicted wars within video game characters, we would all be statues, reveling in perpetual self war. -Me Play me on Rock Band 2, GH-WT, or any other Xbox GH! Xbox Gamertag-MeanJerry |
Post #157461
|
Posted: 21st September 2007 23:23
|
|
![]() Posts: 2,350 Joined: 19/9/2004 Awards: ![]() ![]() |
The game never rolls any "dice." There's actually no such thing as a true means of generating a random number (try to work it out on paper; it's the exact same thing when programming, only with instructions instead of signs and operators.) Instead, the game has a predefined list of "rolls" built into the ROM. This list never changes, being hardcoded into the game while it was being programmed.
In other words, the programmers rolled the dice ahead of time and packaged them with the game. It's always the same list. However, because you don't actually see the numbers and because random numbers are called for very frequently, this is not a problem. The set of values is large enough to give the illusion that fresh random numbers are constantly being generated, so it all works out fine. -------------------- "Judge not a man by his thoughts and words, but by the quality and quantity of liquor in his possession and the likelyhood of him sharing." |
Post #157474
|
Posted: 27th September 2007 17:21
|
|
![]() Posts: 139 Joined: 25/1/2004 Awards: ![]() ![]() ![]() |
And as Silverlance was saying, it also uses different indexes into the random number table for different purposes. So, while one function (say spell animation) may add 1 to reach the next "random" number in the table, another function, (say, the take-a-step function) may use a different index, and add 13 to itself. Since 13 will not divide evenly into 256, this will generate effectively a different list of random numbers. The two are independent, even though based on the same table.
-------------------- Food is like magic in my ears. - Djibriel Ogopogo lives. |
Post #157669
|
Posted: 28th September 2007 17:31
|
|
![]() Posts: 113 Joined: 9/12/2003 Awards: ![]() ![]() ![]() |
Those are pretty good explanations actually. I like the dice analogy, it makes it easier to understand.
![]() On a side note my car's MP3 player has a horrible system of "random" playback. I could swear that I heard the exact same "random" selection of the songs on a disc during different listening sessions. I guess the MP3 player only has a handful of formulas it uses to create a "random" play order. The best bet to get different results seems to be to hit the random button while I'm on a different track than the first one. ![]() -------------------- The FF6*10 webring celebrates FF6's tenth anniversary with fanart (japanese). |
Post #157692
|
Posted: 28th September 2007 18:09
|
|
![]() Posts: 759 Joined: 3/12/2006 Awards: ![]() ![]() ![]() |
Quote (Silverlance @ 21st September 2007 17:23) In other words, the programmers rolled the dice ahead of time and packaged them with the game. It's always the same list. This is actually the very answer I was hoping to get. Very cool. Thank you. That format would be really interesting for a tabletop RPG. Make a bar of D6s, and just move up and down depending on what modifier you're trying to determine. Quote And as Silverlance was saying, it also uses different indexes into the random number table for different purposes. So, while one function (say spell animation) may add 1 to reach the next "random" number in the table, another function, (say, the take-a-step function) may use a different index, and add 13 to itself. Since 13 will not divide evenly into 256, this will generate effectively a different list of random numbers. The two are independent, even though based on the same table. This also, is a great explanation. But with good explanations, build further questions. ![]() Do most games build their decision of how far to jump off of prime numbers, or is the simulated randomness random enough to allow for any values for jumping? -------------------- If internal struggles were as enjoyable and glamorous as the self conflicted wars within video game characters, we would all be statues, reveling in perpetual self war. -Me Play me on Rock Band 2, GH-WT, or any other Xbox GH! Xbox Gamertag-MeanJerry |
Post #157694
|
Posted: 29th September 2007 01:06
|
|
![]() Posts: 2,350 Joined: 19/9/2004 Awards: ![]() ![]() |
The simulated randomness is random enough. There's no definit way to generate random numbers, but the above method (which is used in most FFs) is one of the more common ones.
On PC, the RNG algorithm (rand() in C/C++ for those wondering; I'm 99% certain VB and other languages fall back on the same mechanism) is different. First it takes a number as a starting point (usually how long your PC has been running for since that's fairly unpredictable by a person - GetTickCount() in the Win32 API for those wondering, again) and makes some crazy multiplication using that number that's certain to be bigger than 32 bits (the biggest number your PC can handle, unless you write code to simulate bigger numbers yourself.) It then takes the lower 16 bits, gives you that value as a random number, and next time a random value is called for it will reuse the value from the last call. In layman's terms, it's like if you took a number, multiplied it by some huge number (say, a very big prime,) and only kept the last 2-3 digits. They're likely to look VERY random - just try it with a calculator. 509 (starting value) x 65519 (prime) = 33349171. Our random value here is 171. 171 x 65519 = 11203749. Now our next random value is 749. 749 x 65519 = 49073731. It's 731 now. 731 x 65519 = 47894389. It's 389 now. 389 x 65519 = 25486891. It's 891 now. 891 x 65519 = 58377429. It's 429 this time. So forth... This is not an ideal RNG, but it works fine. There are many other RNGs in existance, most of them far better than this one. Wikipedia's entry on RNGs is a good starting point. A quick note on reliability. Chaos theory basically says there are no actual random processes. Rather, there are a quasi-infinit number of factors affecting the outcome of something like, say, a dice roll that make predicting it impossible for a person. If we had a hyper-powerful computer that could look at ABSOLUTELY every factor (how hard the dice was throw, the angle and speed of rotation, how high it falls, the density of the surface it hits, even tiny things like the barometric pressure, the temperature...) there is no reason why we wouldn't be able to predict the outcome of this so-called random process. Some magical fairy doesn't pop into existance to make the dice magically react (ie, roll over on a given face) without any verifiable action. But we have no way of doing such calculations right now, nor is there much of a point. ![]() So what's random? Anything you are incapable of predicting, and not necessarily something that's unpredictable. A dice isn't really random; there's no magic involved. But to the observer, you just can't guess what the dice will come up as, so it appears completely random. How's this relate to RNGs? Well, even though they're very simple and very non-random algorithms, we can neither see the lookup table (ie, the list of dice) nor can we instantly calculate the outcome of the 386th rand() calculation even if we knew the exact algorithm used. So they're unpredictable, despite being absolutely un-random. In other words, even if something isn't random, so long as you have no reliable way of guessing it, it's going to look as random to you as if some magical fairy popped into existance and wrote a true random number on a sheet of paper for you. ![]() -------------------- "Judge not a man by his thoughts and words, but by the quality and quantity of liquor in his possession and the likelyhood of him sharing." |
Post #157707
|