1. Welcome to Smogon Forums! Please take a minute to read the rules.
  2. New to the forums? Check out our Mentorship Program!
    Our mentors will answer your questions and help you become a part of the community!
  3. Welcome to Wi-Fi! Please remember to read the rules and do NOT create a new thread for simple trades or Friend Safari codes.

RNG Manipulation in FireRed/LeafGreen: Wild Pokémon Supported in RNG Reporter 9.93

Discussion in 'Wi-Fi' started by Arseus, Oct 11, 2009.

Thread Status:
Not open for further replies.
  1. Arseus

    Arseus
    refuses to accept Contributor

    Joined:
    Oct 13, 2006
    Messages:
    869
    Table of Contents
    • [JUMP=#preliminary_information]Preliminary Information[/JUMP]
    • [JUMP=#method_1]Method 1 Pokémon[/JUMP]
    • [JUMP=#method_h]Wild Pokémon: Method H[/JUMP]
    • [JUMP=#practical]Practical Applications[/JUMP]
    • [JUMP=#tid_sid]Trainer ID and Secret ID Generation[/JUMP]
    • [JUMP=#faq]"Frequently Asked" Questions[/JUMP]
    • [JUMP=#research_questions]Research Questions[/JUMP]
    • [JUMP=#helpful_links]Helpful Links[/JUMP]
      • [JUMP=#general_resources]General Resources[/JUMP]
      • [JUMP=#applications]Applications[/JUMP]
    • [JUMP=#credits]Credits[/JUMP]

    12/20/11 Update: RNG Reporter now supports Method H, the method of Wild Pokémon generation supported in FireRed and LeafGreen.
    09/14/11 Update: The technically inclined may see Bond697's latest posts on Method Determination and GBA Video Functions.

    [A]#preliminary_information[/A]
    Preliminary Information
    Abusing the Random Number Generator of FireRed and LeafGreen is very difficult in comparison to games such as Emerald or Diamond and Pearl. Many users have found success thanks to save states from emulators, though the goal of this topic is to facilitate this process for those using actual game paks.

    One of the most important pieces of knowledge in the puzzle of RNG abuse is the "seed". A "seed" is a number that is initially plugged into the formula used to generate strings of pseudo-random numbers. If we know the seed, it is possible to determine the sequence of pseudo-random numbers it creates. In Emerald, we always know the seed, as it is 0 each time the game starts up. In Diamond and Pearl, we can manipulate the seed by starting the game at a certain time, and hitting a certain delay.

    FireRed and LeafGreen operate in a different fashion than the abovementioned games, but they share certain similarities with all of them. They still make use of a seed, which generates a set of frames—simply put, a frame is the spot when the RNG generates a certain PID (a nature and IVs for Pokémon). User flovv has looked into the game's code and discovered the specifics of seeding for FireRed and LeafGreen:

    Seed Creation (open)
    Researcher Kaphotics has also noted that the current seed information is stored in memory location 0x03005000.


    Frequent contributor mattj has summarized much information concerning seeding and the advancement of frames as follows:

    It is important to note that "button mashing" is undesirable due to its effects on seed groupings. It is much better to be deliberate with button presses whenever you are booting up the game.

    User NeoSyrex also has information concerning the FireRed/LeafGreen RNG, which he famously applied to capture a Zapdos for use in the Video Game Championsips. The information provided by NeoSyrex is as follows:

    This seed may be found manually by program FR/LG Seed Finder, which is attached to this post. NeoSyrex, the author of this program, says the following:

    As mentioned earlier, it is possible to generate a list of upcoming spreads using mingot's RNG Reporter program. This is more reactive RNG manipulation than proactive, but this is the best we have at the moment.

    From here, it is possible to aim for a spread that you want by hitting its frame. Frames advance in realtime in a similar vein to Emerald, albeit with a catch. In a "quiet" area, such as outside Mt. Moon, the RNG advances at approximately 60 frames per second. However, this does not apply to all locations in the game. In certain locations, the RNG advances somewhat differently.

    The RNG runs in an altered state in certain areas (many of which seem to be interior), cycling through either odd frames, or even frames. For example, if the game chooses odd frames, it will only cycle through frames 1, 3, 7, 9, 11, and so on. This creates the illusion that the RNG is advancing at 120 frames per second, when it is actually skipping over one type of frame. However, you can change whether the RNG will cycle through even or odd frames. This is achieved through opening up the menu, saving your game, and possibly other actions that have yet to be documented. This will cause the frames to switch to the opposite types; if the game was cycling through odd frames, it will now cycle through even frames, and vice versa. The specifics of quiet and noisy frame advancement are not yet known.

    It would also seem that noisy and quiet areas are not necessarily consistent; noisy areas can be silenced through a technique described by flovv:
    At the moment, you would look through the list of spreads generated by your recurring seeds until you found one you wanted.

    [A]#method_1[/A]
    Method 1 Pokémon

    Much like Emerald, FireRed and LeafGreen

    Bulbasaur, Charmander, Squirtle, Clefairy¹, Abra¹, Hypno², Voltorb³, Electrode³, Hitmonlee, Hitmonchan, Scyther¹, Pinsir¹, Magikarp⁴, Lapras, Eevee, Porygon, Omanyte, Kabuto, Aerodactyl, Snorlax, Articuno, Zapdos, Moltres, Dratini¹, Mewtwo, Togepi, Lugia, Ho-Oh, and Deoxys

    ¹Only Clefairy, Abra, Scyther, Pinsir, and Dratini bought at the Game Corner are consistently generated by method 1. Scyther is exclusive to FireRed, whereas Pinsir can only be found in LeafGreen.
    ²Only the Hypno encountered by Lostelle in the Berry Forest is consistently generated by method 1.
    ³Only Voltorb and Electrode disguised as Poké Balls are consistently generated by method 1.
    ⁴Only Magikarp bought from the salesman in the Pokémon Center on Route 3 are consistently generated by method 1.

    Note that as in Emerald, a Pokémon's spread is not necessarily selected at the precise moment you press A next to its overworld sprite. Rather, the RNG keeps cycling right up until the battle starts (or in the case of gift Pokémon, it is received), unless "spread selected" is indicated in the place of "last input". A list of where to save and the last inputs for each Pokémon is as follows:

    Bulbasaur/Charmander/Squirtle: Save in front of the Poké Ball containing the starter of your choice. Spread selected upon pressing the A button after the message "This POKéMON is really quite energetic!" appears.
    Abra/Clefairy/Dratini/Scyther/Pinsir/Porygon: Save in front of the Game Corner Prize Corner desk. Spread selected after pressing A when the message "So, you want the [ABRA/CLEFAIRY/DRATINI/SCYTHER/PINSIR/PORYGON]?" appears.
    Hypno: Save in front of Lostelle in the Berry Forest. Last input is a press of the A button after Lostelle wails "Waaaaaaah! I want my daddy!"
    Hitmonlee/Hitmonchan: Save in front of the Poké Ball which contains the Pokémon of your choice. Spread selected after pressing A when the message "You want the hard-kicking HITMONLEE?" or "You want the piston-punching HITMONCHAN?" appears.
    Magikarp: Save in front of the salesman in the Route 3 Pokémon Center. Last input is a press of the A button after he asks "So you’ll buy it, am I right?"
    Lapras: Save in front of the Silph employee nearest to your rival. Spread selected with a press of the A button after he says "I want you to have this POKéMON for saving us."
    Omanyte/Kabuto/Aerodactyl: Save in front of the important doctor who revives Pokémon fossils. Spread selected after pressing A when he says "Your fossil is back to life! It was [OMANYTE/KABUTO/AERODACTYL] like I think!"
    Snorlax: Save in front of the sleeping Snorlax. Last input is a press of the A button when the message "It attacked in a grumpy rage!" is displayed.
    Articuno/Zapdos/Moltres: Save in front of the legendary bird. Last input is a press of the A button after it cries "Gyaoo!"
    Mewtwo: Save in front of the Genetic Pokémon. Last input is a press of the A button when it says "Mew!"
    Togepi: Save in front of the man in Five Island's Water Labyrinth. Spread selected upon pressing A when he says "Please, I'd like you to have this."
    Ho-Oh: Save on the first space of the peak of the cliff. Last input is pressing up on the directional pad to place yourself on the second space of the cliff.
    Other: Save directly in front of the Pokémon’s overworld sprite. Last input is a press of the A button to "activate" the battle. In the case of Deoxys, the red-hot rock serves as the overworld sprite. In the case of Eevee, the Poké Ball that houses it counts as its overworld sprite, and no battle is required.

    Note that freezing or changing certain values in an emulator can alter a Pokémon's generation and lead to an illegal result. Due to a phenomenon known as vBlank (detailed in Bond697's posts on GBA Video Functions), "Method 1" Pokémon can also be generated through methods 2 and 4, but this is not the default behaviour; know if you get an abnormal spread for a method 1 Pokémon, this is the factor at work.


    [A]#method_h[/A]
    Wild Pokémon: Method H

    FireRed and LeafGreen use a method known as Method H (which comes before the "Method J" and "Method K" with which you may be familiar if you have done RNG manipulation in the fourth generation) to generate their wild and Pokémon. This is the same method used in Ruby and Sapphire, and is now supported in the latest version of RNG Reporter (9.93). More technical information is available below in HIDE tags. What you need to know is that all wild Pokémon are generated using Method H, but with a bias towards the Method 2 variant.

    Old Technical Information (open)

    As for the encounter slots of FireRed and LeafGreen, Zari states that they appear to (for the most part) conform to the same twelve-slot format as the fourth generation games. In other words, for all areas with twelve Pokémon listed, the slots should correspond to the following:

    20% / 20% / 10% / 10% / 10% / 10% / 5% / 5% / 4% / 4% / 1% / 1%

    This information has been corroborated by a separate study conducted by Kaphotics in the RNG Research thread, as seen below (post edited to remove R/S/E information):

    The encounter slots seem to differ when using each Fishing Rod, which Kaphotics has also addressed below:

    Code:
    Old Rod
    Slot 0: 0-69 
    Slot 1: 70-99 
    
    Good Rod
    Slot 0: 0-59
    Slot 1: 60-79
    Slot 2: 80-99
    
    Super Rod 
    Slot 0: 0-39
    Slot 1: 40-79
    Slot 2: 80-94
    Slot 3: 95-98
    Slot 4: 99
    For a comprehensive list of encounter slots for each game, please refer to this post.

    For those interested in the technical side of PID generation, Kaphotics has laid out a simplified version of the process as follows:

    Setup of everything before PID:
    Code:
    0 - Initial
    1 - Battle Decision,		 pretty long thing		 = Battle
    2 - Encounter Slot Value (0-99), via Upper16 %100		 = Slot
    3 - Encounter Level (from Slot), via Upper16 %(High-Low+1) + Low = Level
    4 - Encounter Nature, 		 via Upper16 %25		 = Nature
    Now to generate a PID.
    Code:
    set n = 0
    loop until break to get a PID%25 = Nature
    5+n - Temp  Low16PID
    6+n - Temp High16PID
    
    	if High16PID_Low16PID % 25 = Nature
    		set as the PID, break
    	    else n=n+2
    		repeat loop
    	end
    
    end
    Then comes the IVs, which depend on the Method of Generation.
    Not sure if this is that calc at frame 1, the rejection of IV bits, or something else.
    Code:
    	if Method 1
    		a = 0 
    		b = 0
    	elseif Method 2
    		a = 1
    		b = 0
    	elseif Method 4
    		a = 0
    		b = 1
    	end
    
    7+n + a   - IVSet1
    8+n + a+b - IVSet2
    


    [A]#practical[/A]
    Practical Applications

    As for the practical side of RNG manipulation, in light of recent (12/20/11) Method H information, OmegaDonut has proposed a method of manipulating gift and wild Pokémon that is simpler than ever. Read his post here for a quick breakdown:



    In the event that you wish to have the luxury of recalibration, NixHex's original method can be found below:

    User Zari has taken the information we have right now and created a method of RNG manipulation that makes RNG manipulation in FireRed/LeafGreen more accessible to the average user, even if it is not entirely possible to manipulate the seed at will. As NixHex has put it, try thinking of this method as a variant of Emerald, albeit one with more options from which to choose. Zari's post below describes his method:

    Note that triggering the advance to the start screen at the right instant will yield better results than mashing buttons either to a beat or as quickly as possible. Zari notes that three button presses are needed to execute the skipping method.

    Zari has also kindly compiled a list of the different seeds found:

    Code:
    By groupings:
    
    9eXX [02 - 2d]
    
    9e02 * 2
    9e03
    9e0a * 2
    9e0b * 4
    9e0c * 2
    9e0d
    9e0f * 4
    9e13 * 8
    9e14 * 10
    9e18
    9e1c
    9e1d * 2
    9e29 * 2
    9e2d
    
    54XX [c2 - f3]
    
    54c2 * 2
    54c3
    54ca * 2
    54cb * 6
    54cf * 2
    54d2 * 2
    54d3 * 3
    54d4 * 10
    54d7
    54d8
    54db
    54de * 2
    54e0
    54ed * 2
    54f3
    
    30XXv1 [82 - a8]
    
    3082
    3083
    308a
    308b * 5
    308e
    3093
    3098
    309c
    30a0
    30a8
    
    30XXv2 [3d - 5a]
    
    303d
    3045 * 2
    3046 * 2
    3047
    3048
    304b
    304c * 5
    304d * 2
    304f * 2
    3050
    3056 * 2
    305a
    
    e7XX [42 - 72]
    
    e742
    e749
    e747
    e74b * 9
    e74f * 5
    e753
    e758 * 3
    e75c * 2
    e75d * 3
    e769
    e771
    e772 * 3
    Here is Zari's success story in which he details how he caught his Mewtwo in Kanto:


    [A]#tid_sid[/A]
    Trainer ID and Secret ID Generation

    The RNG is constantly running during Professor Oak's introduction to the player, and the point at which the player's ID, or visible Trainer ID is created has been found, as well as the moment when the invisible Secret ID is generated. Our knowledge of the TID/SID generation process will hopefully allow manipulators to obtain custom ID combinations for use in the capture of shiny Pokémon, or general aesthetic purposes.

    [A]#faq[/A]
    "Frequently Asked" Questions
    As implied by the quotation marks in the header, not all of these questions are frequently asked. However, I do anticipate them coming up, so I'll try to provide some help here:

    Q: How are Eggs/shiny Eggs generated?
    A: Information on the generation of Eggs can be found in this post of the RNG Research thread. Similarly, Egg availability and generation is elaborated upon in a subsequent post in the thread. In both cases, the information has been provided by Kaphotics.

    Q: There were two runs of FireRed/LeafGreen cartridges. Does the RNG work the same on both?
    A: As far as we are aware, there are no differences between the runs of the games as far as the RNG is concerned.

    Q: Do these findings apply to other games, such as Ruby/Sapphire, or just FireRed/LeafGreen?
    A: As mentioned above, all Pokémon handheld games share some similarities as far as RNG mechanics go, but they also have their own nuances. This thread is made specifically dealing with FireRed/LeafGreen mechanics. Ruby and Sapphire share wild Pokémon generation Method H, so that research may be applied there.
    [A]#research_questions[/A]
    Research Questions

    As you have likely gathered, we do not have enough information to create a streamlined RNG manipulation experience in FireRed/LeafGreen at this time. This is why your help is needed. Here is a list of all the things that need researching at the moment (that I can think of):

    • What areas have a "quiet" RNG, and what areas are "noisy"?
      • It is unclear at the moment just where (and when) the RNG goes into the "noisy" pseudo-120 FPS mode. We need users to test in different areas to see where the RNG is "noisy" and where it is not. Bear in mind that the RNG can be silenced, as described by flovv earlier in the post.
    • What actions cause the RNG to switch from even to odd?
      • It is known that opening the menu and saving both cause the RNG to switch to the opposite type of frame. However, the full range of actions which cause this switch are not known as of yet.
    [A]#helpful_links[/A]
    Helpful Links
    [A]#general_resources[/A]
    General Resources
    [A]#applications[/A]
    Applications
    *PokéRNG does not provide accurate seeds for FR/LG at this time.
    [A]#credits[/A]
    Credits

    I would be remiss to not give credit to the various users that have made this information available. Of course, where the RNG is concerned, loadingNOW and X-Act did the pioneering research that has made all RNG manipulation possible. =Jonny=, Syberia, Equinox, and Negator contributed to early tests and research concerning the FireRed/LeafGreen random number generator, and the program used to find FireRed and LeafGreen seeds was crafted by NeoSyrex. Additionally, user NixHex has made several significant contributions, including a series of updates. Similarly, Kaphotics and Bond 697's work in the RNG Research thread has proven useful in illuminating some of the outstanding technical aspects of the RNG, and they have posted many new developments in this thread. Many other users such as chrish, mattj, flovv, andZari made consistent or large contributions. Many other users have contributed to this cause.

    Attached Files:

  2. chrish

    chrish

    Joined:
    Aug 1, 2008
    Messages:
    14
    Data on Zapdos in the power plant

    In light of the above information, my findings might not be useful, but here they are.

    My data only applies to Zapdos in FireRed. I saved in the power plant directly in front of him before I started.

    My theory [before I saw this information] was that if I soft reset the game and duplicated every possible interesting time interval each time I soft reset, that I would see 1 or more duplicate instances. I assumed that I could accomplish the necessary uniformity by pressing the A button once every time interval instead of trying to "race" through the screens to get to the encounter. So I did the following:

    1) soft reset in sync with a trusted metronome

    2) pressed the A button on every beat of the metronome (every 1/2 second) while I advanced through the credits, the title screen, the continue screen, and the 4 "Previously on your quest_x" messages.

    3) recorded the number of beats at two spots:
    a) the point at which I pressed A in front of Zapdos
    b) the point at which I pressed A after Zapdos says "Gyaoo!"

    I only had two distinct result types for 3a/3b above:
    28/31 presses
    29/32 presses

    After generating about 35 of each type (3a and 3b), I never got a duplicate, even though I had multiple instances of the same nature. Admittedly this is not a very large sample, but since I had the same nature several times, I was surprised that I never got a duplicate.

    I can't see how my saved data couldn't be the same each time (since I saved in front of Zapdos and did soft resets thereafter). I did consider the possibility that a hard reset could be different than a soft reset, but I just don't see how that is possible. I may try that as well though if it is true that I fail to produce a duplicate through soft resetting after a larger number of repetitions.

    As a die hard software developer I like to test the simplest case first; I thought Zapdos in the Power Plant would be one of those but now I am having doubts...

    I am eager to help; I would happily look at the game's coding, but I have no idea how to get my hands on it. Can anyone tell me?

    I have many copies of FR/LG (all of them untouched by foreign hardware!) so I can easily reproduce many of the interesting scenarios.

    Let me know how best I can help - it seems as though different people each investigating a different aspect of the question would be the most efficient approach.
  3. Arseus

    Arseus
    refuses to accept Contributor

    Joined:
    Oct 13, 2006
    Messages:
    869
    Hello chrish!

    First of all, I can see that this is your second post here (though your join date indicates you may be a "lurker"), so I would like to formally welcome you to Smogon. I am sure that you will enjoy your stay here, as you seem to be very enthusiastic and helpful. It is great to see users such as yourself stepping up to help out; I saw that your other post was similar to this one, albeit without a specific experiment. I am glad that you have taken the time to help out!

    Now, to address your post for content. I am glad to see that you are attempting to use an actual game cartridge, and this will definitely come in handy, given that our goal is to be able to abuse the RNG on cartridges. I am a little worried that this may be a bit of an uphill battle for us at this point though, as cartridges have different limitations than emulators. This brings me to my next point:

    In order to look into the game's code, I do believe that you will need the game in a form that can be played on an emulator. However, that is all I can tell you without infringing upon forum rules. I hope that you understand.

    This is a decent theory, at least going by what we know at this moment. As I mentioned in the original post, loadingNOW has commented on the FR/LG RNG in the past, but the information we have from him is somewhat cryptic. As you may be aware, loadingNOW is a very intelligent user, but I do not believe that his first language is English (it is actually German, I believe). So while he may have provided a good explanation of the RNG, I am not sure how to interpret it. He has said (again, as mentioned above) that FireRed and LeafGreen seed through the time spent in the title screen, but also that the seed is stored in the save file, and is changed through number of steps. So we do not have anything conclusive.

    However, returning to your above experiment, there is a rather unfortunate flaw. Assuming that the RNG is rather sensitive to the time spent in the title screen (I do not believe this is a bad assumption, considering that the RNG is wont to run at about 60 frames per second), it would have been very difficult to get the same seed each time. And even if you did get the same seed, the RNG continues to run at 60 frames per second (or a pseudo-120 frames per second, which is likely the case in the Power Plant), as described in the original post. This is a limitation that we cartridge players are going to be faced with. So at this point, I do not believe that the experiment you have carried out is the best way of doing things at this point, unless I have somehow misinterpreted it (feel free to correct me if I have). I do believe that if you modify your experiment slightly, you can indeed help us out.

    From my understanding, what you are trying to do at the moment is seeing if you can obtain the same frame. As I have mentioned, this is not easy at all this point; what you would be better off doing is trying to see if you can obtain the same seed. If you recall from the first post, it is possible to find your seed and generate a list of spreads using mingot's RNG Reporter. To do this, use Sweet Scent to engage a Pokémon in battle, then subsequently check its IVs (or I suppose you could also catch Zapdos, since you likely do not have any intention of saving afterwards). Along with the seed you find from this Pokémon, it might be helpful if you could record a time, or I suppose the beats of the metronome along with it. If you are able to get the same seed, then we have made progress in that we know the game does indeed seed from the time in the title screen. If not, then I am afraid that we will be in the same place we are now; not knowing how the game seeds at all.

    Of course, this would be easier if you could actually look into the code, as I have touched upon above. I am not sure if it is the best use of your time to conduct the above experiment or not; it will be worthwhile if we can advance our understanding of the seed, but if not, it will have done little. If you are interested in more immediate results, you may want to look into one the following research question:

    I do not know if you have the ability to look at a game's save file (I am guessing not), so you may have to try a couple times to get a Pokémon that has only one possibility for its method of creation. I must also request that you record the location that you catch this Pokémon in (the more specific, the better, though not so specific as the exact patch of grass!), which may help us out when combined with our knowledge on what areas are "quiet" and which are "noisy". It would likely be best if you caught a number of Pokémon within a single area, to see if all or many Pokémon within the same area are generated by the same method. If you can, it may be useful to note the seed that generated that Pokémon as well. However, this is admittedly not as much of a priority, as RNG manipulation of wild Pokémon in FireRed and LeafGreen is going to be impractical to say the least.

    It is ultimately up to you as to how you want to help. You may choose to try the revised experiment as I advised above. Bear in mind that none of the players using an emulator have managed to get the same seed twice, though I am unsure of what methods they were trying. At best, we can discover through this test that the game does indeed seed through time spent in the title screen; at worst, we remain unsure of how the game seeds. On the other hand, if you opt to help gather a list of wild Pokémon methods, we will most likely be able to use this knowledge in some way. However, it is unlikely we will be able to apply it very well, as our focus will be more on the legendaries, which will be hard enough to manipulate as it is.

    Ironically, what would be most helpful to us right now is the ability to look at the game's actual code and conduct tests using an emulator. The extra options afforded by such a process is ultimately what will help us advance our understanding to the point where the knowledge can be applied to cartridge players. I am confident that negator has told me what he knows, but from this point on, I am hoping to have RNG research be a more transparent process; I request that if any users using emulators are reading, you post here with any findings you have that may help us.

    I hope you do not feel as though I am devaluing your contribution, chrish, since given the fact that you are so willing to help out, this is the exact opposite of how you should feel. We are simply at an early stage in the research; one where the advantages of an emulator will likely be what sheds light on most of the mysteries we have at the moment. You will certainly be a vital asset to us once we are at a stage where we can better conduct tests on cartridges, or at least in a situation where an emulator is not so heavily relied upon. Think of yourself as a brick-layer. We certainly need you to build the house, but right now you may not have the tools required to help us finish the foundation, through no fault of your own. Nonetheless, it is with your help that we will eventually construct our glorious [Pokémon] mansion.

    I certainly hope you are not discouraged, as you show much promise in your attitude and logic. I feel as though I cannot emphasize this enough: how you proceed is reliant upon how you feel your time will be best spent. I feel that I have provided you with adequate information to make this judgement call for yourself, which is the environment that I feel will be most productive for our research. Feel free to post which path you decide to travel down, though to the best of my knowledge, you will be the only user conducting research in either of those fields at the moment, at least in affiliation with this topic.

    Just to make sure my messages did not get lost amidst this sea of words: welcome to Smogon, and thank you for your enthusiasm concerning this project.
  4. chrish

    chrish

    Joined:
    Aug 1, 2008
    Messages:
    14
    The road(s) chosen

    Thanks for the welcome.

    I have indeed been a lurker (I have spent countless hours browsing all the interesting information on the Smogon web site).

    No worries, I am not discouraged. I have spend perhaps > 120 hours in the last couple of months breeding exact Gender/Nature/Ability/IVs using the spreads for Emerald, at times wondering how I managed to hit 965 all the time while I actually was hoping for 965S!

    I am in the process of investigating the use of an emulator.

    In the meantime I will try and help out with What dictates the method of a wild Pokémon?
  5. Gwabatim

    Gwabatim

    Joined:
    May 7, 2009
    Messages:
    60
    Can you rng shinies in FR/LG?
  6. Equinox

    Equinox

    Joined:
    May 22, 2008
    Messages:
    1,185
    Alright, well I have done a good amount of research on it, I have noticed that the method changes when you catch a pokemon. I save stated and sweet scented and got method 1 and everytime after that I would get either 1 or 4. Ive done it multiple times, I have only successfully abused wilds twice (7 times if you count my five failures, where I hit the frame but got the wrong method or Pokemon) and it looks like you can lock into method 1 or method 2 as long as you dont catch a pokemon. This means that you need save states to check your current method. (you need them anyway to abuse, since we dont know the seeding) However, while you know if you are going to hit methods 1 or methods 2, there seems to always be the possibility of hitting method 4.

    The thing I wish we could figure out as of right now is the seeding, I tried to figure it out if it works like delays in DPPt, and so far, I have no leads, most of the time I get my frames to start in the hundred millions or billions, but I have had instances in lower frames.


    Method 3

    Im not sure exactly how it is generated, but there have been a few points to where I have hit method 3 spreads, and they are usually encountered when i was trying to hit a method 2 spread, ill continue to take a look at that.



    I feel that this thread should include Ruby / Sapphire abuse as well, or another thread. Ruby and Sapphire seems to be exactly the same as fire red, but the methods are the same as emerald, in my experience. One thing I had weird happen in Ruby was that I hit a method 2 Latias, the spread is 31/18/31/30/31/30, in method 2 it is timid (the nature I got) but in method 1 it should be Hardy. Although, I think that is just a problem with my VBA, since I have had another problem with it anyway.

    I also cannot figure out the seeding in Ruby and Sapphire, either.



    Also, if you would like, I can link to some of Syberia's videos on how to abuse with VBA, for people who want to do some research and help out.
  7. Arseus

    Arseus
    refuses to accept Contributor

    Joined:
    Oct 13, 2006
    Messages:
    869
    Hello Equinox! I am glad to see that you found this thread, as negator mentioned your name a couple times concerning FireRed and LeafGreen RNG research. I have addressed your post below, in addition to chrish's latest post, and Gwabatim's question. chrish, forgive me, but my address to you is somewhat sandwiched in with my replies to Equinox, but that is only because there is some overlap. Let me begin with you, Gwabatim:

    Well, "yes and no". At the moment, we cannot control the seed, so we lack control over the spreads that are generated. The only way to get a shiny at the moment is to hope that one is generated within a reasonable range of the initial seed that you get, and aim for it like any other spread. Of course, this is exponentially easier on an emulator than it is on an actual game pak. However, at the moment, we cannot actively abuse for any given spread; as I mentioned earlier, we are at the stage where our "abuse" is reactive rather than proactive.

    Fortunately, unless something goes awry (such as if the seed is horribly impractical to manipulate), we should be able to abuse for shinies in the same manner that we will abuse for a typical Pokémon once we get a better grasp of the RNG. However, at the point where we are now, we cannot really set out to get a good shiny, even if you know all the possible shiny spreads for your ID and SID. Likewise, we cannot set out to get any given spread. I hope this answers your question.

    Please allow me to see if I completely comprehend. I turn on my game, and the first thing I do is Sweet Scent to encounter a Pokémon. This Pokémon will be either method 1 or method 2, depending on an unknown factor, on account of the fact that it was the first that I encountered. However, any subsequent Pokémon will be either the same method as the previous one, or method 4? Of course, we do have another monkey wrench:

    This is particularly fascinating, on account of the fact that there has been a bit of an enigma surrounding method 3. I suppose further testing is required.

    chrish, I am unsure of how much research you have done as of right now, but you should look at this new information by Equinox. I do not think what you have done is irrelevant; on the contrary, it will likely confirm Equinox's findings. However, you will want to keep Equinox's findings in mind when assessing your findings, and possibly adjust your methods accordingly. From this point on, I think it would also be helpful to note the order in which you encounter the Pokémon you capture, and organize by playthrough (as different seeds may affect the methods used to generate Pokémon).

    I agree with you that we need to figure out how the games seed; in my opinion, this is the single most important thing we could learn at the moment. If anyone here has the ability to look at the code and figure out how FireRed and LeafGreen post, I must ask you to post here!

    In all due respect, I would rather keep this thread exclusive to FireRed and LeafGreen. We are at an early stage as far as manipulation is concerned, and I don't really want to divert any resources away from FR and LG for the time being (I know many fourth generation abusers are wrapped up in HeartGold and SoulSilver, though). Additionally, since Ruby and Sapphire apparently function in a manner similar to Emerald once their internal batteries run dry, Ruby and Sapphire abuse in its purest form would only last as long as the battery in any given cartridge. As such, I do not see the sense in devoting much time to it.

    Regardless of our difference in opinion concerning this matter, I must thank you for taking the time to post in this thread. I would appreciate it if you could confirm (or correct) my interpretation of what you have mentioned concerning wild Pokémon, and post any other information you may have that could possibly help our research.

    If you are referring to SRing on VBA Part 1 and SRing on VBA Part 2, I suppose that there is no harm linking to them for now, since we are at a stage in the research process where use of an emulator is very helpful. I will revise the first post with these links in addition to the information you have posted come Saturday; I am short on time at the moment, and do not wish to hastily shove them in the original post.

    On that note, please allow me to say the following to everyone who may read this thread. I am very busy with school at the moment, which unfortunately takes precedence over Pokémon. As such, please do not be offended if I do not reply to you right away, and do not feel as though I am uncommitted to this research thread. I will update and respond as I have the chance, but please do not feel neglected if you have to wait a day or two for a detailed reply.
  8. Equinox

    Equinox

    Joined:
    May 22, 2008
    Messages:
    1,185
    Are you using a cart or VBA?

    If you are using a cart, I would reccomend trying to record the time from when you capture your pokemon until you turn your game off, this way you can find out your current frame (Use Wichu's app to find your actual frame [Emerald Frame] and RNGreporter to find the method), the problem is, without a save state it is impossible to know what method you can get whether it be method 1 or 2, because it seems that as soon as you catch a pokemon, the method changes, so I would reccomend skipping the method part with mingot's program and just try to hit any random spread, and just hope you get lucky with the method.

    If you are using VBA, I would start off by save stating while the cursor is on "Sweet Scent" and then catching a pokemon, checking to find the frame and the method and then loading the save state and then go from there to hit your spread.

    Wilds are also a lot harder because you dont have Synchronize, so if you dont get the pokemon you want on the frame that you want, you cannot get it in that location.


    Yeah, the only thing I would reccomend right now, is everytime you hit a method 3 spread, record all the info, just so we have something as a possible start off.


    I agree with you on this, because until we can figure out the seeding, it seems like it would be nearly impossible, if not impossible to abuse in FR/LG at all. (Without save states)





    Whatever you feel is best, I feel that it is pretty essential for research, until we can figure out the seeding.
  9. yayece

    yayece

    Joined:
    Sep 14, 2005
    Messages:
    90
    This is an interesting project... If one were to "look at the code," how would you even get started? Does VBA allow you to look at the assembly level code? Do we know for certain if the PRNG is the same as Emerald? i.e., the initial seed may start you somewhere in the middle of the series, but will the progression of the series be the same? If yes, then maybe searching through the code for "0x41C64E6D" would be a good starting point, no?
  10. Equinox

    Equinox

    Joined:
    May 22, 2008
    Messages:
    1,185
    Im not sure what you mean by "progression of the series" if you mean frame advancement, it is still 60fps, and I really dont know how any coding works, to be honest.
  11. yayece

    yayece

    Joined:
    Sep 14, 2005
    Messages:
    90
    When I say "progression of the series" I'm wondering if the <i>order</i> of the frames is the same. If yes, then it means that the equation to produce the next random number is the same as the other games. That would be an easy starting point since this equation is known. If the order of the frames is different in FR/LG, then the PRNG equation is different and I wouldn't know where to even start looking.

    In any case, I guess this would be trivial for me to check myself with an emulator. Just wondering if anyone knew offhand.
  12. Arseus

    Arseus
    refuses to accept Contributor

    Joined:
    Oct 13, 2006
    Messages:
    869
    I am purely a cartridge player, so this would be the process I would use. However, I do not know if I will have the time to personally reset for a wild Pokémon in the foreseeable future. On the other hand, this should be useful for users working on wild Pokémon research, such as chrish!

    Hello yayece, and thank you for expressing your interest in this project!

    To the best of my knowledge, all games except for Colosseum and XD use the same formula for the random number generator (seed × 41C64E6D + 6073). This is the process X-Act has listed in his article on PID generation, and I believe that loadingNOW has mentioned it prior to that. So I do believe that this equation, and by extension, the order of the frames, should be the same in all the handheld games. The initial seed generation is the only difference (besides frame advancement); for example, Emerald is always 0, Diamond, Pearl, and Platinum seed from the clock, and so on. As such, I believe "all" are looking for is the formula that generates the seed.

    However, let it be known that I am no expert on code. My only "programming experience" has been with a simple "Hello world" application two years ago, and I have no knowledge of random number generators and such beyond what I have been told by X-Act, mingot, and so on. As such, when I say "look at the code", I have said all that I can; I do not know the specifics. I apologize if I have not answered your question. On a more interesting note, I have been poring over old research concerning the RNGs, and I found an interesting tidbit posted loadingNOW, which may prove vital to understanding the seeding process:

    I have bolded the above, as it seems quite important. For one, it mentions the time spent in the menu once again. However, it also mentions the time in-game; this could change as you save the game (if you save on a different minute). Could this be the reason loadingNOW suggested earlier to save your game often in FireRed and LeafGreen? Also worth noting is the existence of a "time id". I have no idea what he is referring to here, but it seems quite possible that the seeding process involves an interplay between the three variables that loadingNOW mentioned above.

    Of course, this is just my speculation, but it is a piece of the puzzle that I did not notice before. Hopefully it leads us in the right direction in figuring out the seeding process of FireRed and LeafGreen.
  13. Negator

    Negator

    Joined:
    Aug 29, 2007
    Messages:
    4,662
    Just two cents:
    Method3:
    I had possible method3, but never encountered a SINGLE, therefore true method 3 spread.

    Method2:
    I've encountered some of those, but JUST as the very first catchable spread, generated from a new save state:
    This means that so far, those spreads should just be some "wrong" ones, generated by the emulation errors.
    Infact I'm sure that this is the only possible explanation, since so far I've never had a single wild pkm, which had a method 2 generated PID (infact checking just with x-act pid leaves the possibility of certain pid to be different methods, but the ones I checked so far, they were always method 4 or 1).
  14. Arseus

    Arseus
    refuses to accept Contributor

    Joined:
    Oct 13, 2006
    Messages:
    869
    To the best of my knowledge, Equinox's method 3 Pokémon are the first instances of method 3 Pokémon to date. There were accounts of method 3 Pokémon in earlier topics, but the definition of method 3 has shifted since then; what was known as method 3 back then has been redefined as method 4.

    I'm inclined to disagree. As listed in my list of wild Pokémon, I caught a wild Mankey with the PID of 7A293695. This PID is a result of its IVs and Nature (Lonely, 20/25/27/26/10/28), and according to X-Act's applet, it is only possible with method 2. This Mankey was caught on a legitimate cartridge (I do not recall if it was the first I caught), so it was certainly not an emulation error. I think it would be more likely that method 3 is the emulation error than method 2, if only because of its rarity. Regardless, more testing needs to be done before anything conclusive can be said.

    On another note, I have updated the first post as promised. Equinox's information has been incorporated, in addition to the "new" quote from loadingNOW, and a new section has been added containing helpful links. This update will likely not mean much to those who have been following the topic since its inception (almost a week ago), but I feel it is important to keep the original post up-to-date with the discoveries in the thread.
  15. Equinox

    Equinox

    Joined:
    May 22, 2008
    Messages:
    1,185
    Later today I plan on trying to hit the same seed twice, the only problem is it is hard to know if you actually hit it, because unlike DPPtHGSS the frame continues to advance, so you dont hit the same frame everytime. Should I just focus on the spreads being within a certain number of frames close to eachother? Like maybe 10,000 or thereabout? Im really not sure how I should go about that...
  16. yayece

    yayece

    Joined:
    Sep 14, 2005
    Messages:
    90
    10,000 seems like too much... Assuming 60 frames/second, ~500ish should be a lot better if you keep your timing consistent. If you do this, it might be a good idea to do it ~100ish times and record the frame you get each time. If any of them are close, then you can guess that those had the same seed.
  17. Newts

    Newts

    Joined:
    Sep 12, 2009
    Messages:
    477
    Not really yayece, 10,000 frames is only 2:45secs at 60 frames, and unless he knows whether or not his area falls into the 'noisy' category it could be even half that time. Just picking a comfortable number is going to the easiest way to go at these early stages.

    I've recently restarted my LG game for the sole purpose of finding a way to get a nice spread on a shiny modest Moltres. So i got rather excited when i saw this thread as i now have others to help point me in the correct direction. If there is any way i can be of help beside just the random trial and error i'm already doing let me know.
  18. Equinox

    Equinox

    Joined:
    May 22, 2008
    Messages:
    1,185

    Well, right now, its still nearly impossible to abuse without save states, and if you get a good spread, it will be hard to get a seed close enough to the spread. I would probably wait till more research is done but its all up to you, really...just throwing in my two cents.
  19. yayece

    yayece

    Joined:
    Sep 14, 2005
    Messages:
    90
    Obviously, the point is to see if you can get the same seed twice. It's pretty much common sense that you'd try to minimize the variation on the number of frames that pass by. Therefore, the smart thing to do would be just to just sweet scent a pokemon ASAP after each reset. There's no sense in throwing in additional variation (by waiting upwards of ~2 minutes) to the experiment.
  20. Newts

    Newts

    Joined:
    Sep 12, 2009
    Messages:
    477

    I'm not sure if you would call i success but I've had some luck with saving infront of Mewtwo. What I've been doing is starting emloop on some crazy high frame number as I SR, sweet scenting as soon as I enter the game to find my initial seed using Wichus RNG program, then using RNG reporter to find which frame i actually scented, then searching from shiny frames available on that seed, at a point further than im already at on emloop. (Hope that made sense)

    Alot of big flaws though, your not guaranteed a decent spread on the seed you've hit, plus you only have the one chance to hit your frame before restarting the whole process. Although if you have the patience it is still more reliable than SRing for a random nature and IVs.

    I disagree, button mashing is full of undesired variables, using a program such as emloop minimizes the inconsistencies as you have a visual and audible aid for when to scent. So setting it to a number such as 10,000 is quite comfortable and not rushed in any way. Although a lower number is quite usable if your giving yourself enough time to not rush yourself and make forced errors.
  21. Arseus

    Arseus
    refuses to accept Contributor

    Joined:
    Oct 13, 2006
    Messages:
    869
    Hello Newts_Ute! I am glad that you were excited to find the thread, and that you also have an interest in helping. I have outlined all the research questions that I can think of (at the moment) in the first post, but much of our progress hinges upon figuring out how the game seeds. I echo Equinox in advising you to hold of on soft resetting until we figure this out; most "reactive" abuse is currently executed by those using emulators.

    I think I understand your general procedure, but I am admittedly a tad confused by the Emloop bit. I get the rest of your procedure; finding your seed, then the frame, and finding available shiny spreads. You say that you put Emloop on some "crazy high frame number" when you soft reset, then search for shiny frames "at a point further than [you're] already at on Emloop". What exactly is the correlation between hitting your frame and the use of Emloop? I'm sorry if the explanation is terribly obvious, but it's just not clicking in my head for whatever reason.

    Indeed; you have pretty much hit the nail on the head as far as issues resetting on cartridges are concerned. Even once we have discovered how to hit a certain seed, we will still have to actually hit that seed each time, in addition to hitting the desired frame.

    As for Equinox's same-seed adventures, I believe that I can see where both yayece and Newts_Ute are coming from. What yayece is saying is that you would want to get the seed as quickly as possible, in order to minimize the amount of frames that pass by. Newts_Ute advises to wait for a time to reset for, in an attempt to obtain more consistent results. I would personally say that their advice is best used in conjunction; try Sweet Scenting at the same time each attempt, but choose a low time to aim for. This is pretty much how I outlined the "calibration phase" in the RNG Manipulation of Wild Pokémon section of the Emerald RNG Abuse Guide; while the situation is somewhat different here, as we have the seed as another variable, I believe that the overall approach should be sound.
  22. Negator

    Negator

    Joined:
    Aug 29, 2007
    Messages:
    4,662
    some test result:
    That "fast mode" as we call it showed up also on a sevii island, it would really be helpfull if some real cartrigde owner can figure out if it appears even there:
    The how to shoule be very easy, since the tester should just get their seed, aim for a 10/15 minutes far spread, and at the supposed time, check if their outcome is close at the aimed target, or if it's far away (double the time far).
    This should be done after changing location, for example, starting the game outside cerulean cave, going inside, and only then do the scenting.
    Anyway, so far, I've also had a "bad" experience twice:
    While being in fast mode, I went for a target spread, but I end up with nothing, because instead of my target I got the even spread right after it... which just makes no sense...
    This as I said before, happened twice, I should list the said spread just for the record later.
    I've no clue of why this happened...
    It's like the jolly spread I've recently abused on different pkm:
    While it shows up as method 1 with scenting, while fishing it ends up being replaced by its method4 split, and not only in one location, but in diffirent ones, and from different save states.
  23. NeoSyrex

    NeoSyrex

    Joined:
    Jun 28, 2009
    Messages:
    17
    Ugh, first of all I'm sorry to everyone who has been waiting for me to post info on FR/LG's RNG, I've been really busy (plus I got pretty burned out on the game after Worlds). Anyway, I didn't read everything that was posted so I'll just say everything I know about it (I bolded the parts that I felt were crucial for figuring out how to abuse the RNG):

    Basically the way to abuse FR/LG's RNG is to catch a pokémon (for example Zapdos), check its IVs, and get the seed. Then go backwards through the RNG (using the reverse RNG formula on the seed) until you find your starting seed. I never figured out how the game creates it, but the starting seed is always going to be a 2 byte number so it doesn't really matter since the RNG rarely comes up with numbers that small (and when it does the offset is usually a giveaway as to whether its the starting seed or not). I made a program that can do this, its a simple DOS program I quickly made that I haven't had a chance to make look nice. If you guys want me to post it anyway, I can.

    Continue doing this until you find a seed you land on often. Once you find a particular seed that seems to work for you, use RNGReporter to check if there are any spreads for the seed that you want. Finally, you need to correctly time the frame you enter the battle to match the corresponding spread.

    This seems similar to the other RNGs (aside that the starting seed is harder to figure out), but there is one key factor that seperates it from the other RNGs: button presses on the title screen seem to influence the starting seed. So to get the seed you want you have to make sure that not only are you on the title screen for the correct amount of time, but you also press the A/start buttons the correct amount of times as well. And on top of that you need to enter the battle on the correct frame. Needless to say its quite tough.
  24. Arseus

    Arseus
    refuses to accept Contributor

    Joined:
    Oct 13, 2006
    Messages:
    869
    Why hello there, NeoSyrex!

    I will make no attempt to hide the fact that I was quite excited to see your username as the latest poster in this thread! I thought that you had disappeared from Smogon for good; your last login was a day or so after you had promised to reveal your information, so forgive me for being a bit skeptical. I am glad that you have decided to reveal your information; it is new to us, or at least nobody has brought it to my attention. I will integrate it into the first post immediately. Also, no worries about being busy; I have been quite busy myself, so I know how it feels to be swamped with work to do.

    I had rather hoped that you had actually discovered how the games seed, but at least we have something new to work with. Now, let's see everything that we know of that could possibly affect the seed:

    • Time in title screen
    • Button presses in title screen
    • Time in-game
    • "Time ID"
    However, it is important to note that you are the first user to hit the same seed twice. Have you been able to hit the same seed across multiple savegames? In other words, has the "seed you land on often" been the same even after saving, and doing it again? If so, then "time in-game" may not be a factor after all. However, I suppose further testing is still required. I still have no idea as to what time ID is supposed to be, or if it's even a factor; it could have meant the PID received at a certain time for all I know. I suppose we're still waiting for someone who can look into the code of the game to clear this up, but at least we seem to be getting closer!

    As for your program NeoSyrex, I suppose it could not hurt to post it here for the time being, and I will add it to the list of helpful links in the first post. At the very least, it could be a nice starting point for mingot, who will hopefully be able to incorporate FireRed/LeafGreen features into RNG Reporter (once we know more about the RNG that is).

    Now, negator, I don't think anybody is currently researching "noisy" and "quiet" areas, but I'll add your specific question to the main post so that whoever does decide to pick up that type of research will not miss it. Also, I'm not quite sure as to what to say concerning your oddities with wild Pokémon. Is it possible that while aiming for your target spread, some unknown action that you took caused the RNG to switch from even to odd? I can't really see how this would make sense if you just stood there and used Sweet Scent though... This whole RNG thing is quite confusing, it really is.
  25. chrish

    chrish

    Joined:
    Aug 1, 2008
    Messages:
    14
    Exact duplicate Mewtwo

    We got an exact duplicate Mewtwo (nature, IVs, seed, PID, SID, Methods) in 14 tries using the following approach:

    NOTES:
    We saved the game directly in front of Mewtwo (before starting test)
    We used a metronome set to 2 beats/second
    We always started with a hard reset
    TIME: 23:07 (from the CONTINUE screen, i.e. game play time)

    We executed the following button presses at the following beat counts (we always made sure that we allowed enough beats so that we were never rushed to trigger the next step in the sequence)

    Beat Count (cumulative) at each step (game event)
    ------------------------------------------------
    0 Switched the game on in sync with the metronome
    70 Pressed the Start button on the title screen
    80 Pressed A on the Continue screen
    160 Pressed A in front of Mewtwo
    170 Pressed A after "Mew" is displayed
    190 Pressed A after "Wild MEWTWO appeared!" is displayed

    Data on the duplicate Mewtwo (we also have information on the 12 non matching data points):

    Nature: Careful
    IVs: 29/0/26/16/4/12

    We got these 3 results from RNG Reporter 7.10 (IVs to PID/Seed dialog)

    Method: 1
    Seed: F135D0B
    PID: C7C68E22
    SID: 18912

    Method: 2
    Seed: 7302B09B
    PID: EBECBCD6
    SID: 22328

    Method: 4
    Seed: CFD60409
    PID: 46651B50
    SID: 23856

    We intend to refine our results as follows (please feel free to suggest superior alternatives or to help out!)
    1) We will repeat our initial experiment a significant number of times (50-100) and see how many duplicates we get and record our results.
    2) We will verify that a soft reset behaves the same as a hard reset
    3) We will vary each interval in turn in order to try and determine which intervals are relevant.
Thread Status:
Not open for further replies.

Users Viewing Thread (Users: 0, Guests: 1)