well, this blog post will be about RNG manipulation, specifically the recently found ( well about 2-3 months erstwhile as of this mail ) appetizer handling in Pokemon Colosseum and Pokemon XD : Gale of Darkness by……me ! I will talk in detail how a manipulation and luck works in cosmopolitan before explaining how convolute manipulating both of these games has been and how in my opinion, this is one of the most insane manip ( RNG handling ) in accession that the fact it is even potential is nothing short of incredible .
But beginning a little refresher on what is RNG.
What actually is RNG and how does it work in practice?
If you are familiar with any speedrunning community, you surely have heard people throwing the terminus “ RNG ” around in casual conversation and when they refer to it, they largely refer to it as “ luck ”. This is…..mostly true, but there ’ s a fortune of hidden mean behind this condition that makes it much more than luck so let me address that first before we proceed because it ’ s going to be identical crucial former on .
RNG means Random Number Generator and it ’ s actually just a way for a calculator, console table, toaster…..whatever thing that has a CPU to SIMULATE randomness by generating a sequence of numbers that SEEMS random, but is actually thus deterministic, you could predict every numbers in the sequence if you know the term in the sequence you are in ( called the “ sow ” ) and you know how the RNG works. Because of this, calling it “ random ” international relations and security network ’ deoxythymidine monophosphate actually correct, it ’ second more mention to as a PSEUDO random phone number generator : it gives the IMPRESSION of randomness, but the reality is there ’ randomness nothing random about it inherently .
To show you what I mean here ’ s the VERY dim-witted RNG algorithm in both Pokemon Colosseum and XD, it ’ s a very simpleton recipe :
seed(next) = seed(current) * 214013 + 2531011;
Yes, the source of ALL randomness in both of these games is a mere multiplication followed by an addition, you can ’ metric ton be more bare than that ! It truly shows you how nothing is random about this, but if you actually plugged a issue in this, the solution will seem not related at all to the number you put in and if you keep running this in chain with the results you get on each step and note the resultant role, this is where the randomness starts to go in : they don ’ thyroxine seem related AT ALL .
In fact, this is evening worse because this detail convention combined with the GameCube arrangement stores the source in a rate somewhere in RAM that has 2^32 potential values and a numerical proof tells you it GUARANTEES that this formula it will go through all the 2^32 ( about 4 billions ) possible values when you call it in chain before repeating itself ! For those mathematics freaks that are concern in the subject, I recommend you read more about the LCG which is the mention of this RNG algorithm, it won ’ triiodothyronine be necessity to understand the manip, but it can be fascinating to learn why this works so well while being that simpleton. To show you how random they seem, here ’ s the first gear 100 seeds of this LCG starting from 0 as the initial seed :
2531011 505908858 3539360597 159719620 2727824503 773150046 548247209 2115878600 2832368235 2006221698 2531105853 3989110284 2222380191 2165923046 1345953809 1043415696 586225427 3870123402 2343900709 3109564500 3522190791 2090033518 3566711417 3845303128 3357146299 2234209426 4040255757 146855836 2784856047 4262888182 2307812833 2186156320 2202588003 1218146458 3255514357 1391793124 1547432727 2974409086 816345673 2204347368 4082973451 2598295970 3997112797 1172243756 2070757183 1349033222 2947833777 4186407856 2644169651 3265965994 500021189 1927072628 2952203367 3032601998 3745830425 763478136 808009051 470291122 152809133 1262519996 3596810895 3073944342 3912267137 2219737664 3566475267 550773434 1594990229 1825593092 366913975 3770957214 923917801 3013470472 2454389675 1094713282 1000089469 1044798540 180074975 3941575974 4039618385 1179915472 3240206419 2354104778 774629733 3687888532 15715079 274340270 183798201 1896424856 2345635323 677355730 3493168205 1402045916 1049918767 758555446 3850308897 914963296 2188405923 2610537690 3954284597 840886820
The point I am trying to make is this is what RNG is : a sequence of apparently random numbers or seeds generated by a deterministic ( does the like thing no matter what ) algorithm which is called on the seed to get the next one. The randomness is only there because in practice, you normally never know either the current seed or the number of times this algorithm has been ran so the only thing you can guarantee is that the current seed is a number…..that ’ randomness ALL. This is by design because it makes everything for you, as a player completely unpredictable .
As for how does a mere count influence stuff like critical hits or drop curtain rates in RPG like Pokemon, it ’ randomness because they use arbitrary criteria on the seed they get after calling RNG ( this is why RNG is only called when something requires randomness, it ’ s to not have patterns in the outcomes ). For example, if you want a 50 % sink rate, you could barely check if the seed is even or odd because a far as you are concerned, the seed can be any number so there ’ s an even gamble here. You could use even more mathematics formula if you wanted a more complicated rate like 29 % or something, but the point is, the seed is ALL you need to do anything you want with randomness .
So you probably can connect the dots on what an RNG manip is : it simply involves to have a way to know the stream seed AND the phone number of prison term the algorithm has been ran. In early words, you TRACK the source. And if you track this, you can predict EVERY result in the game because you will know when the seed will meet the criteria of the consequence you want. Basically, you are in control of everything so you can start to laugh in hysteria 😀
all right that was all the boring hypothesis so immediately let ’ s get down to talk about both of these Pokemon games and why we would want a manip .
Reset, reset, reset…
Pokemon speedruns at least from what I noticed seems to have one thing in coarse : the route relies on the starter ( s ) having good stats ( material like IV, natures….other complicated Pokemon things ) because they expect the starters to have becoming chances to survive through the run. I mean it ’ s a speedrun, you don ’ metric ton want to spend an hour grinding cause your flat is low .
Pokemon Colosseum and XD are no exception which is a problem because the stats like other games are random and the desire stats are stern enough that getting a melt past the 20 minutes mark is, in hypothesis, 3-5 % ! This is so fabulously low it was common for runners to spend hours and hours of resets without even attempting the hardest parts ! In fact, most runs never got past the starter and some of them would get past it, but both of these games needs a junior-grade Pokemon in the route that besides has nonindulgent stats so it would frequently die there besides .
sol the concern of having a manip is obvious here : if you could at least manipulate the stats of the newcomer of each game, it would raise the probability to adenine high gear as 30 % to have a run past the secondary pokemon !
Which is where I came in as I have pretty good experience in invert engineering ( RE ) GameCube games so I started to check if it was even possible in the inaugural place and…..it was already a awful start because of 2 obstacles : the organization clock and the naming screen door in each bet on .
The system clock, biggest wall in this entire project
I never thought I would hate a clock this much in my animation, but here we are, I REALLY hate this clock .
thus after some promptly RE, I determined that the initial seed is the lower half rate of the clock ( the least significant contribution ). It just takes it from the system quite early when the bet on is booted and that ’ s your initial seed. therefore, if we could find our semen on boot, we should be good .
The first thought would be “ lol precisely set the clock and boot the game skeletal system perfect ”, but NOPE, this clock is INCREDIBLY accurate, so much the citation of a frame ( which is the length of time inputs are polled, normally 1/30th or 1/60th of a second gear ) is meaningless. The organization clock accelerate is 1/12 of the CPU ’ s own clock speed which, if you do some mathematics, gives you one check every 22 nanoseconds ! To put this in perspective, a frame in the GameCube menu is about 0.017 seconds ( so the 1/60th of a irregular ), 22 nanosecond is 0.000000022 seconds ! ! ! This is then precise the disk spin in the system is WAY besides much variation !
therefore that ’ s not happening meaning no matter what, you are never going to know your seed on boot which is a huge float to the possibilities of a manip .
The naming screen, why did you have to use random animations?
Let ’ s say through insanity ( which is what this manip is ), you get past the clock and you ARE mindful of your seed, well you could be able to get to start the new game, but then you come to the problem of the name shield where you enter your flight simulator name and confirm it before the game starts. Quick RE reveals that the starter for both games is generated AFTER this riddle and for the carry, it ’ mho compulsory to pass through it so no matter what, you HAVE to be able to track the seed through this filmdom .
The appellative screen is a huge problem because it calls RNG constantly ! Each frames, it calls RNG and this is due to the short pokeballs spawning in the background in Colosseum for exemplar, some random properties are determined with RNG like size, position or clock to be on the filmdom. Since we assume you would know your seed by this point, this is normally not a problem because you just continue to track it, except that this screen REQUIRES user remark which are variable and thus, screws up the manip because it makes it frame perfect and potentially impossible .
HOWEVER, I done some hours of RE to determine that fortunately, there ’ s hope here because the number of calls the RNG does is wholly skeletal system pendent. Each frames where the identify blind is rendered, it calls RNG once to determine a 10 % opportunity that if it pass, it will call RNG 4 more times. This happens very systematically each frame and what this means is that since you would know your source by this point, you can predict when the 10 % passes or fails every time and as for the total of frames….well obviously you don ’ triiodothyronine know that, but you know what is going to happen for a given come of frames .
So you could merely predict the starter for a bunch of frames come, present it to the runner and the runner will be able to pick the total of frames that gives the stats they want. This is possible because there ’ s only one input signal that matters : the very last one spend on that riddle which is confirming the name, even if the runner does extra inputs, it doesn ’ thyroxine change the consistency of the RNG. In other words, through complete luck in how the game works, this obstacle merely makes the manip frame perfective, but not impossible !
….except there ’ s a small child exception and that is on Colosseum. Although both games allows to enter a customs list, if you do so on Colosseum, every frame the keyboard is rendered, more RNG calls happens per ensnare and for whatever reasons, this international relations and security network ’ t the casing for XD. The rationality this is bad is because it breaks the consistency we want : that each frames calls RNG 1 or 5 times, nowadays it depends if it ’ s a frame where the keyboard is rendered or not. By the goal, you wouldn ’ triiodothyronine know how many frames lasted while the keyboard was rendered or not, the alone way you would know this is if you did BOTH the “ newfangled name ” choice AND the name confirmation frame arrant. Since ONE human body perfect input is already 1/60th of a second…..2 of them in a quarrel is simply not happening .
This unfortunately incurs a 3-4 seconds time passing in the run because naming yourself “ A ” rather of “ WES ” does make a deviation when the text scrolls. A worthy monetary value to pay however considering how a lot more probable it would be to get the starter the runner want .
basically, most of the challenge of doing a manip in this bet on has to do with that clock : we need a room to find our seed AFTER boot and once it is found, track the seed until reaching the new game option and we ’ ra done !
This sounds impossible, but actually, a japanese programmer had a brilliant idea .
The Battle Now/Quick battle menu
Both games have something I will refer as random quick battle which is a neat fiddling feature : it allows you to struggle against the CPU, but your team and theirs is randomly generated from bias sets. This was in the first place supposed to merely be a room to do a identical promptly battle, but for our purposes, it turned out to be our savior .
You see, in both games, before you actually start the battle, there ’ s a confirmation immediate that not only asks you to make certain you want to start the struggle, but it besides displays information of what conflict apparatus was generated. The information varies for each game, but if you take colosseum for model, you get to know your trainer name ( which is random among 3 ) and you get to know your team ( which is random among 8 ) .
now, I want to remind you that the end product you see on-screen is DIRECTLY related to a mathematics leave performed on the seed to determine them. What this means is that whatever the semen was at the consequence you chose to see that confirmation screen, it HAD to have generated the information you see on the screen to be the right seed .
A japanese programmer by the name of “ ginzaru ” had a bright idea : what if we run simulation on all or a scope of the ~4 billions possible seeds and put it in a re-engineered interpretation of the team genesis process and drop the seeds that doesn ’ thyroxine match the information the runner see on the blind ? In fact, this can be done multiple prison term in a row, you could back out the ratification screen and go back to it, it just thus happens the main menu of both games don ’ thyroxine predict RNG much .
finally, you would be left with merely one potential seed which HAS to be the current one and because we were in the main menu this hale time which doesn ’ metric ton call RNG, we can track it to the naming screen and BOOM, it would be done ! You could even attempt to regenerate extra teams after finding your seed in case you don ’ deoxythymidine monophosphate like the predictions you would get for the identify screen so basically, it will allow you to pick and choose the prediction you want !
….unfortunately, life has to be complicated sometimes and we were actually very far away from it being practically done. The program the japanese person did is fabulously ineffective, not because of the language barrier ( which forced me to read like 10 Bulpapedia pages of japanese Pokemon names ), but it ’ mho because I could tell very promptly that the algorithm was just not optimized at all .
It ’ south made in a high level linguistic process called C # using the .NET framework which is normally full for most cases, but it ’ s truly not the best if you want the best performance for a tax adenine intensive as doing billions of mathematics on numbers quickly ( besides, you can ’ metric ton let the stolon wait more than 1-2 minutes or it won ’ metric ton be worth it/make them identical sad ). The early problem is the performance it claims to be able to do was identical poor compared to some mock-ups I made in C++, basically, it should not take that long. Plus, it only accepts to search in a particular range of source you have to enter manually….which is identical odd and very unfriendly for the exploiter .
barely to make this more concern, the programmer has not released the reference code of the plan and I unfortunately don ’ thymine speak Japanese so asking them to have it would have been complicated. This is a huge blow because the platform actually implemented all the RNG calls until the team generation which is all you need to do a reliable source finder .
basically, my first goal in this project is to prove that it is computationally possible to do this method. If it is possible for most computers to do this, we have a manip .
The journey starts: the proof of concept
I want you to realise first what we are dealing with here. The clock shuffles the initial seed then on boot, it could be anything from 2^32 or about 4 billions values. After boot, through the magic trick of a RAM search and dolphin, we can see that the seed advances a lot before even reaching the first struggle confirmation. In fact, barely before reaching the title screen, thousands of RNG calls already happened ! There ’ sulfur besides some thousands happening when entering the battle menu, and ultimately, a pair of thousands when generating the actual team. The number of calls is variable because of many reasons, but I realized that the japanese broadcast was kind enough to put the number of calls that happened in each hardening before the struggle ratification ( it ’ s the numbers you see before the sow at the end ). Therefore that broadcast must have been accurate in its implementation .
The consequence here is we are at around 5-6 thousands RNG calls PER SEED which are variables and we have about 4 billions of them, that ’ s a LOT of mathematics for your poor little CPU ! In fact, if you take a search at the RNG convention, you will see there is an integer multiplications which is normally easy peasy for a CPU to do, but it ’ s not complimentary and doing several billions of them in a row is REALLY showing that. In fact, when I reached the point where I had a work room to test this, evening with the aid of using in full my 4 cores on my CPU, it would complete the first filter in 10-20 minutes ! This is so slow, it ’ s unacceptable, we are trying to make this under 2 minutes, how the heck can we do a 1000 % performance improvements ?
This trouble is what ended up making this manip amazing because it sounds impossible, but to be honest, I love challenges like this. This is one of the independent reasons I love programming therefore a lot : I love to think hours upon hours upon a trouble like this to ultimately find a solution and feel accomplished I did ; one of the best feel always .
After realizing the raw work flow is not going to work, it ’ mho clear I had to find a way to reduce it. And then I realized something : the clock is editable, why not use that to my advantage ?
Using the clock
Okay then I mentioned that the clock makes it impossible to know our seed on boot, but possibly it can tell a range of values where it ’ s in most probably. Imagine the following scenario : the smuggler sets the clock to the prize of 0 and boots the plot adenine fast as possible. immediately obviously, we don ’ metric ton know the value of the seeded player, but booting the game doesn ’ t even take 30 seconds, it ’ s a short time and the initial seed would very likely fall into a compass of say 5-10 seconds of time depending on how the stars aligned on that clock the night the GameCube was booted or something .
There ’ s actually ways to optimize this because Dolphin is so good that it actually emulates pretty well the GameCube and Wii menu and it tied has reasonably beneficial emulation of the clock so I can test farce and do some TAS to find the least possible sum of frames to boot the game. I can evening test the dependability of my solution because Dolphin supports booting the bet on from the organization menu .
Although here ’ s a playfulness morsel : in my tests, I discovered 2 issues ( this one and this one ) refer to the clock with the copycat and I had to submit fixes so I could test things ( the first base one specially is identical funny because it basically meant the Wii clock ’ s rate at 0 in Dolphin was wrong for many years and no one noticed it ! ) .
After what seemed like days of tests, I found out that both on hardware and on Dolphin that we can safely assume the seed will be in a 5 seconds range which gives us about 200 millions seeds. That ’ s A LOT better than the 4 billions we had, but is it good enough ?
well at this stagecoach of growth, I had no implementations of the game ’ s RNG calls and I didn ’ t want to do them until I am very indisputable this is potential so what I did is I merely put the RNG formula and simulated a workload of 6 thousands RNG calls 200 millions times which is truly a worst case scenario. The results were MUCH better, but it wasn ’ deoxythymidine monophosphate quite there yet, it would take a couple of minutes, but this is promising !
However…..I had another trick : precalculation .
I mentioned earlier there ’ s a draw of calls happening even before the team generation process, but these batches of calls only needs to be ran before the first trickle action and if you have a predefined range of seeds ( which we do because we do a trick with the clock ), the lists of seeds before the first base pass will constantly be the same. So I had a apt idea : I would run the calls before the beginning team generation alone once and output the seeds into a file. That direction, when we do the first elapse, the course of study already has the seeds ready to actually go through the team generation thus optimizing the process significantly. The file takes a while to generate and can be quite big, but it can be kept for every far findings so it ’ randomness worth it in the end .
Again, I had to do simulation for this to give me an estimate, but this time, I had importantly fewer calls per seed, about 2-3 thousands. The results this time were perplex : on my computer, it took 10 seconds ! This was fast enough that even if you had a double core low-end CPU, it would have taken 20 seconds still which is absolutely acceptable !
The manip was proven to be possible yay ! ! ! ! !
The fun part: actually programming everything the game does
OKAY WE HAVE A MEANINGFUL PROJECT WOOOOOOOO ! ! !
thus, immediately I can program stuff without worrying it would be for nothing, it ’ s time to RE the heck out of the crippled ! I started with Colosseum because I actually done identical fiddling work on XD so I would have been more comfortable to platform an RNG backend on Colosseum first. The finish is elementary to understand : read the compose code of the bet on when it calls RNG, re-engineer that code in C++ and make indisputable it behaves precisely as the game ( so the seed between my execution and Dolphin matches ) .
The RNG re-engineering backend
This was very fun to do for me because it combines RE and programming with clayey debugging process along the way. It ’ randomness probably one of the plan I had the most playfulness doing specially knowing many speedrunners would benefit from this .
There ’ s a set of stuff that happened during the process like being dumb and doing a err and realized it was stupid after an hour of diagnosis, you know stuff like that, but finally, I got to the team generation. There ’ s actually a long ton about the inner mechanics of Pokemon I learned along the way like how was the shininess determined or how does the personality ID ( PID ) works and a bunch of other stuff that I never thought I would ever touch, but I guess I did 🙂 To give you an idea of how complex it gets, here ’ s a snip about shininess from Bulpapedia :
00000000 00000000 00000000 00000000
From Generation III forth, whether a Pokémon is Shiny depends on its master Trainer ‘ s Trainer ID number and secret ID number and on the Pokémon ’ s personality value. The high half of p ( highlighted in bolshevik above ) is referred to as p 1 below, while the low half ( highlighted in blue ) is referred to as p 2. mathematically, p 1 can be derived by calculating
p / 65536and rounding down the resultant role, while p 2 can be derived by calculating
p % 65536.
S = IDTrainer ⊕ IDSecret ⊕ p1 ⊕ p2
A bitwise exclusive or operation ( or “ ⊕ ” ) on inputs a and b, written as a ⊕ b = c, outputs c such that, if a one ( bit i of a ) and b i are different, then c i is 1 ; otherwise it is 0. For example, 11002 ⊕ 10102 = 01102. When exclusive or is applied to multiple inputs, as in the calculation for Shininess above, it may be more easily understand as, “ If an leftover count of bits ( at position i ) are 1, output 1″. This operation is commutative .
From Generation III to V, if S < 8, the Pokémon is Shiny .
One of these adventures is then curious it ’ sulfur worth to share. The plot kept a feature called assertions in the retail interpretation which is a common feature in software development that allows developers to inserts conditions in the code that if it fails, it will literally crash the platform with a custom message set by the programmer. The idea is to find bugs that causes something that is theoretically possible, but in drill should NEVER EVER happen under ANY circumstances .
For safety reasons, this is normally only used in growth and precisely disabled in the release translation of the program….however, this international relations and security network ’ t the case for colosseum ! In fact, in the team generation officiate, I stumbled across these assertions and this is what the log of Dolphin shows me when I try to trigger one manually ( you can ’ t trip one without hacking or using the Dolphin debugger like I did ) :
After these logs appeared, a crash followed a few seconds late with a very annoying tone constantly playing as sound recording. The concern bit here is this is a especial type of logs not generated by Dolphin, but by the plot and Dolphin can show me these logs. here, it seems to be REALLY mad that a certain man of text international relations and security network ’ metric ton of an appropriate length and then it prints me first gear flat debug information about the country of the system. This is interesting how a feature that shouldn ’ t have been enabled in the retail interpretation is in and the funny story separate is these actually helped me to reverse engineer the code !
The team generation re-engineering was a huge challenge because there ’ s a bunch that happens there. basically, when the game generates a team, there ’ s different criteria the game wants when it generates the Pokemon. For exercise, it may want a certain sex or nature or not being shiny ( hence the need to understand the above snip ), stuff like that, but the problem is to get these, the game has to endlessly generate until it finds what it wants. This made me necessitate to implement the genesis algorithm AND to take note of the different criteria the game wants and god it was just a fix of stuff that the game needed to properly track the seed. There ’ sulfur therefore much I had to fill the code with comments 🙂 Oh besides, this is why the team generation is very building complex to re-engineer, it wastes a bunch of call to generate the Pokemon since it drops most of them .
After what seemed to be 2 weeks of hard work, the beginning seed has been correctly found with the finder, this was the most hype moment of the plan, I even skipped sleep that day because I was this ballyhoo about that moment, it actually happened at 4 AM that day 🙂
soon adequate, I had a sour program on instruction course to find the seed. I released the program along with a YouTube video explaining how to perform tests on this .
People tested it and it was a success, people were able to find their seeds under an acceptable length of time and they seem to be okay with the process angstrom convoluted as it is !
The RNG predictor
After this reassurance people would be okay with the most complicated function of the manip, I now focused on the predictor because the list screen door forces me to present the different stats for the number of frames it would have elapsed. Although, I took only a sidereal day to realize the algorithm of the naming screen was very simpleton to re-engineer, the hardest part was the skeletal system heuristics .
You see, I had to TAS this screen heavy because there ’ s some edge cases to take into consideration. First is that I had to TAS to see the minimal come of frames it would take to confirm the name so this is where I had to start my predictions. then I realized before the first RNG human body, it for some reasons calls the supply routine which has the RNG call 500 times, credibly to have an initial background so I had to take care of these. then after, I had to besides include the frames AFTER the name has been confirmed because the screen is introduce for some seconds before fading out. finally, I reached the holy place grail : the starter generation, but because I plan to output all the concern things like IV or nature, I had to program a function to handle this .
I put all that in a cringle and integrated this in my little command line course of study and now I had a finder + predictor all in one to test !
After the initial tests on Dolphin, I moved over to hardware to test it and at the prison term, the only timer to properly meter an stimulation like this was the eon timer which only works on Windows so I had to use a virtual car as I am on an Arch Linux OS. This gave an interest screen apparatus, I don ’ thyroxine think I got this convoluted of a setup to test my program 🙂
After some adjustments were done, I last had the predictor to be authentic so this was a huge milestone : I had a GUI-less work interpretation of the manip and it was convincing, it WOULD be able to manip and it would take 1-2 minutes per try ( you hush have to time an input signal frame arrant, but that ’ s in truth all the arduous depart to it ). Colosseum was decidedly done ampere far as the backend was concerned so I merely needed to implement XD before implementing the graphic interface .
Moving on to XD or laughing face 😀
now as I expected, XD was…..mostly uninteresting because it behave identical similarly to Colosseum, many of the code have the like semantic or at least, they are very close. It was identical quick to get the pokemon generation where it became much more complicate .
The battle ratification screen of XD is very different, alternatively of showing a flight simulator name and a team, you know BOTH your team and the musician ’ mho team ( though, each are among 5, they are for some reasons different depending if it ’ south you or the computer ) deoxyadenosine monophosphate well as the HP stats and genders of the pokemon. besides, you see every pokemon involved as it is merely a 2 volt 2 which means there ’ s much less pokemon being generated than Colosseum which is promising because it indicates the seed finder can go through the calls faster .
unfortunately, it would have been then fast if it wasn ’ t for the fact the game besides generates the EV ( feat value, 1/4 of a stats decimal point at level 100 ) at random and the algorithm to do so…..is very complicated .
It actually is simple in concept : it tries a bunch together to aim for a full summarize of EV, but if it fails, it manually adjust, but still, this was a annoyance to go through the roll up code to re-engineer it 😦 The rationality this makes the procedure dull is because well there ’ s a fortune of calls introduced with this as it normally doesn ’ t pass good EVs promptly. Another thing that made it difficult is I had to basically calculate the HP stats which meant I had to store some properties of the predefined pokemon such as the base HP stat .
however, and to my satisfaction, if you enter the HP and the teams, it is placid decently faster than Colosseum and it besides takes twice arsenic less passes because the HP makes the narrowing down process much quick .
After getting through the pain, the rest was very easy because the naming riddle behaved very similarly and lapp goes for the crank generation. So actually, except the team generation which was kinda hard to do, it just was very similar to what I had done ahead so it was kinda easy .
however, I finally have a predictor and a semen finder for both games. After an hour of intensifier tests, I was convinced I can FINALLY move on to flush more playfulness stuff : the graphic interface ( GUI ) !
Putting some graphics in the interface
I like command credit line, it ’ sulfur minimalist and from a programmer, it ’ randomness fabulously easy to control what ’ s going on, but it ’ s very not good drug user knowing because it ’ randomness very hostile so I need to do a commodious interface for anyone to use without much fuss .
It sounds everyday for me as I already have pretty good know with the Qt model to do GUI, but this one was challenging because as you may have realized by now, nothing has been simple in the backend ! 😀 pretty much everything has been complicated or convoluted and required several clever manipulations to get what I wanted and I have to put a graphic interface that makes it simple. It ’ s decidedly not easily .
The biggest challenge was again, it ’ s the source finder, this finder alone I swear I think I spent 70 % of the integral project on it because it in truth has been the major point of difficulty because of that mean clock 😦 ( did I mentioned I hate that clock ? )
The seed finder with a wizard!
So the estimate I had is when I look at the steps the exploiter has to perform to do the manip is it ’ sulfur very a lot like a cook recipes where you do the instructions precisely as argue and it the correct holy order. One of the step, entering the information displayed on the screen, repeats itself indefinitely until we are done. So I can ’ triiodothyronine actually have one screen layout, it good would be eldritch and seem excessively imposing for the poor user so that made me think of a series of dialogue with a linear way in them and each of them having one measure of the “ recipes ” …..WAIT this is precisely what is sorcerer is !
This is more common on Mac OS or Windows, but have you ever downloaded a plan and when you came to run its installer, the first thing you saw was “ Welcome to the installation of the thing, this ace will guide you through the initiation process ” or something like that with a future release that people kept mashing without reading ? Well that ’ s a ace and it ’ s supposed to help the drug user to do a normally complicated, but orderly march, you know, like a cook recipes .
This seems to perfectly match the manip process ! There ’ sulfur one catch however : wizards aren ’ thymine normally done to repeat themselves, they fair go from one dialogue to the adjacent so this was going to be a spot complicated to do. In fact, I reasonably much had to workaround respective things that the Wizard Qt offered JUST to implement a recur steps, some of which I am not in truth gallant of, but it works thus yay !
I besides learned by the room how to perform asynchronous tasks with Qt because particularly on the first happen, it is a long process and if you merely run your code, the GUI will have no board to breath so it will barely freeze completely without apparently doing anything, but it ’ s precisely waiting for a long run task to complete. This sucks because I want to show a progress bar that updates, but thankfully, learning how to run the tax asynchronously meant the GUI wouldn ’ thyroxine freeze and it can hush receive updates, but my long running task can do its thing .
After a farseeing time of fiddling with the charming automobile mechanic and working around it, I was last able to get a truly nice looking charming accomplished with wide instructions. This was one thing I truly needed to do as a precedence by the way : have the program explain itself and not have to refer to say a television or a manual to use it, the instructions are right there in the ace. I wanted to do this because I noticed way excessively many times on specialized tools like this one where the author expects you to read much more software documentation than you should because it could have been made obvious in the broadcast itself. particularly for a complicated, but dim-witted to follow march like this one, I think it benefited much more from the ace and the pain to make it was worth it .
Okay this was the hardest separate so prison term to move on to the predictor, but besides the settings system as I ’ ll explain why settings are necessary in this program .
The starter predictor, now with colors!
indeed, there ’ s one thing that I mentioned at the beginning about the runners wanting to have specific criteria of the stats with the starters, but the trouble is only a little share are considered acceptable for runs. This means I can ’ t good present the list as is and have the runner do a scavenger hunt for them. I mean they can flush decide that none of the predictions are good and generate an extra team to have fresh ones .
What can I do with this trouble ? Well I can do fun things with Qt and I never messed with INI settings before, but I had the theme of just storing the criteria the smuggler wants in an INI settings file or something and use color coding to indicate in the prediction if the standard is met ( green ) or not ( red ). This would allow people to save coarse criteria and besides to very cursorily visualize which predictions is good and if not, why it isn ’ t. Having settings is besides useful for other things like the margin of error of the clock or the soap distance the runner is fix to waste waiting on the diagnose filmdom .
The function with the colors was quite boring to do ( it ’ s a batch of boring conditions that are insistent to type ), but I learned that INI settings were identical dim-witted to do with Qt and I very liked doing them. They were boring however because there ’ s a fortune of them and they are identical insistent ( there ’ south 6 unlike IVs, there ’ s 25 natures and it just goes on and it ’ s just annoyance, but not hard to do ). however at the end of the day, I ultimately got a nice looking settings riddle deoxyadenosine monophosphate well as a truly cool looking forecaster, I remember I showed screenshots of early adaptation and people seemed to love it 🙂
After that, I had to do assorted stuff like a confirmation box to hide all the red ones, a reroll button to signal the program that you generated an extra team etc…. and soon enough, I finally ended up with a feature of speech dispatch platform WEEEEEEEEE ! ! !
Final tests and release
thus finally, I felt very confident in that I put all the basic features it would need for a first gear beta and so began the very last tests before free, this is extremely important because the project had about 4000 lines of codes at this point so it better shape when I release it because as a undertaking grows, debugging becomes much harder .
therefore I had to use so far another convolute test frame-up, but this clock, I was to sit for 2 hours straight of JUST testing the finder and the predictor, I had to go all in here because it HAD to be reproducible. To alleviate how boring the process would be, I put the Kirby Air Ride OST on my earphone loudspeaker while I was doing the tests 🙂
Colosseum initially passed everything, but the tests detected an away by 8 frames errors in the predictor of XD making me actually feel commodity I decided to do this much test. After this fix, it passed so I FINALLY RELEASED THE FIRST BETA FULL VERSION OF THE PROGRAM ! ! ! !
June 24 2018 is the go steady where RNG handling became a thing for these games 🙂 The undertaking and its code is fully available on Github .
After the first version
now this was a beta version so I expected to have some breakage…and of course it happened, but fortunately, it didn ’ thymine affect directly the manip, it would still work, just that it needed some adjustment, but it did had a not major crash. To be honest, I expected this release to go WAY worse so I was a bit relieved it was quite commodity 🙂 People did started to use it in political campaign attempts so that was a fantastic start .
I got some minor feature request, but to me, this plan was far from over because one think that haunted me throughout the stallion visualize is the fact this manip relies on a heuristics by that freaking clock ( I hate it…. ). You could placid have failed the manip if you didn ’ deoxythymidine monophosphate boot the game fast enough, the magnetic disk may have taken excessively hanker, oh and I forgot to mention, but doing this on a Wii was very annoyance and even slower for the finder ( the Wii ’ mho clock is 1.5 times faster making it take longer to narrow it down ). Although to be fair, people would still have done the manip because it helped THAT much, but I hate this when it feels I am forced to do a very messy way of handling this trouble and when I have this feel, I constantly try to think to make it better .
Detaching us from the clock (because I hate it)
I truly got brainsick in ideas. From improving the precalculation phase to many other things and I tied ended up seriously considering using the graphics poster to do all the mathematics ( because a graphics card is actually a animal for parallelism work flow like this one ) using OpenCL. honestly, it was an harebrained idea, but what was done was SO INSANE I consider it miracle of folly .
After the release of the platform and the first bugs were fixed, Thurler, a extremity of the pokemon speedrun ( PSR ) community contacted me about a way to optimize the precalculation so far again, but it would be much better. It was a complicate mess of cagey use of data structure that would have increased the file size by a batch because it involved storing all the seeds AFTER the first pass so you could skip the overhead, but have a in my opinion negligible improvements compared to the huge file size ( it was gigabytes I believe ). I was honestly very chancy on the idea sol I suggested to experiment more with it before I can take a decision .
then they handled the code to Dabomstew, another penis of PSR who besides made another instrument for this game called the stat predictor. Dabonstew experimented with this method acting when they noticed something incredible : after the beginning travel by on ALL the ~4 billions seeds for ALL possible team combination in Colosseum, only a couple of hundreds of millions remained ! WHAT ? HOW IS THAT POSSIBLE ?
It turns out there ’ s something we have been overlooking this whole time : convergence. You see, the crippled does call RNG a variable measure, yes, but if you started with all the seeds, because the total of calls varies per seed, they will get mix astir and since there ’ s so many different seeds, a batch will end up being the same in the number. In fact, I was aware of this because I even got this duplicate problem early in the project so I had to do some codes to remove the duplicates, it ’ second just we never imagined it would converge then much that if you take a team combination individually, you end up with less than 10 millions seeds all the time ! This is for ANY computer, nothing to go through, in fact, it even feels blink of an eye !
But the best depart about this ? We can yet again offload this to generate an external boastfully file that contains all the converged seed ( we can make sure to know which team combination the lists are related to ) and after that, once the drug user enter the data on the first gear pass, we just load the appropriate list in RAM and there we go ! But you know what ’ south even more amazing ? This file would have been generated from ALL possible seeds in hypothesis and only keep the one that matters meaning… .
THE CLOCK CAN BE FULLY SKIPPED ! ! ! !
Yes, and that ’ second because we already have our list of seeds that matters and any calculator can go through them well, we no longer need the help of the clock because we already narrowed down the list to the point where you can operate on the fully range of seeds FROM THE START !
If it sounds excessively good to be truthful, well there IS some catches, but they don ’ thymine actually matter ! The biggest one is well the file generation process is….a huge animal. Like I am not kidding here the file takes with my 4 cores CPU 2-3 HOURS to generate ! This is because it has to go through all the seeds of the ~4 billions available, digit out the team combination it belongs and add it. finally, duplicates are checked and removed and you have to do this for all the seeds before last storing the file. The other caveat is the file end up being very boastfully : ~725MB for Colosseum and ~400MB for XD .
However….none of these caveats matters because since we are generating from the same consortium of seeds ( so all of them ), the file is THE EXACT SAME NO MATTER THE CONFIGURATION ! So I can just be courteous and generate the files myself, distribute it along with the release of the platform and have people do no employment for their CPU and just have the files ready to be used. now, I DID ended up leaving the file generation function in the program for good measure, but this is so harebrained, I about consider it a good CPU benchmark affair because it is brainsick how much of a animal this is, I actually still can ’ t believe the complexity of this routine 0_o
The resultant role : everything is then quick between passes you barely have time to see the build up bar ! All of this is done while skipping the clock which to me is just harebrained, because this is probably one of the ONLY GameCube manip you are going to hear chiefly due to that clock. One thing I should mention about XD : because the HP stats would increase the number of combination by a short ton and increase the complexity and size of the file by a HUGE margin, I decided to skip them on the beginning pass. And THAT is why the current interpretation of the program says on the first pass that “ You will enter the Pokémon HP starting from the following pass ” .
There ’ s some things however that I need to address since this project cursorily influenced the runs of the games .
After the fact: what happened?
so both before and after the publish of the platform, I watched a set of streams of speedrunner running each games, specially after manip because, look it ’ s fun to see people use your program hot 😀 Because I done this, I can more clearly see as a viewer if the manip truly did anything a far as running the game goes .
The inaugural obvious thing I noticed is the number of attempts. It was clear that this helped a short ton, we went from having no runs in a day to be common or possibly 1 or more to you can actually expect to have 2-3 attempts per day ( though the RNG can still hate you and not give you the secondary coil pokemon, more on that subsequently ). As a spectator, this was a lot better because you get to see quicker the concern and more challenge parts of the run…..and besides their death, but at least it died to other reasons than you couldn ’ triiodothyronine even attempt to do much because of the appetizer which is very early .
One less obvious thing that I started to notice is the altitude towards having good stats has changed. alternatively of taking any that was “ commodity enough ”, runners started to be much rigorous and even made routes based on specific farce like the type of the hidden ability attack. This was done because it became then easy to get the starter you wanted that people figured you can sacrifice some aggravator with having to reroll more frequently or sometime reset because the nearest good prediction was besides far all this to get better stuff. Better stats and routes became more accessible which incurred easily time saves and besides increased the rate of the run to go on far because your stats are good .
last and to be honest I didn ’ deoxythymidine monophosphate quite expected this to happen, but people I never seen done a ladder of these games started to want to run the games now. In fact, it even happened that some pokemon speedrunners I was watching got back to this game because the resets wasn ’ metric ton a nightmare anymore, it ’ second still an annoyance, but means more manageable .
In the end, noticing all these plus changes, I am very glad with how the program turned out. I feel accomplished when I ultimately release a visualize I worked unvoiced with, but the best feeling is knowing that the program I did helped many early people, in fact, when I am doing a visualize, this is in itself a huge motivation for me .
There ’ randomness one stopping point thing I need to bring up and that is the secondary pokemon used in each game ’ south run .
Possibilities of manipulating the secondaries
not only each game ’ s run uses a crank pokemon, they besides get another one later on ( Croconaw on Colosseum and Teddiursa on XD ). It would be interesting to manipulate those, unfortunately, I promptly realized it was not possible. On Colosseum, adenine soon as you enter gameplay phase, the RNG keeps rolling per human body make every input signal skeleton arrant if you wanted to track the seed. even if you wanted to save, the nearest save is in a pokemon kernel quite army for the liberation of rwanda from the trigger to the Croconaw conflict so we have the like problem. For XD, lapp softwood, but even if XD has a keep open anywhere have, it ’ s still not possible because to trigger the Teddiursa battle, you need to do 1-2 inputs frame perfect to track the seed. Considering the smuggler has done one 10-15 minutes ago, it would be excessively much to add .
basically, it won ’ triiodothyronine happen, but hey, it ’ mho already insane the starter can be manipped so it has to stop somewhere 🙂
This RNG manip is a animal and there ’ s 2 chief reasons why it ’ randomness probably one of the most concern that exist in speedrunning in cosmopolitan .
The first is the platform, the GameCube and Wii ’ randomness clock are very accurate, but when I mentioned that Colosseum and XD used the clock as their initial seed, I forgot to mention it ’ randomness EXTREMELY common for this chopine at all. This is likely because this was credibly a standard way of doing this by the SDK so most games followed it ( and to be honest, it ’ south besides a omnipresent way to do it in general like I wouldn ’ triiodothyronine be surprised if most modern games ends up doing it ). What this means is pretty much most games you can think of on these consoles has this clock trouble so to have a manip, you need to do like this manip one and have a way to narrow down to one seed AFTER booting the bet on and that ’ s assuming a calculator can do it ! I am certain some games are dense and don ’ thymine use the clock, but hush they should be uncommon and again, having one that exist WITH the limitation is rare and credibly won ’ deoxythymidine monophosphate happen in a long time .
The second rationality is how complicated the procedure is, but even can be made indeed childlike to the user. The platform is considered by many runners to be easy to use, but the reality is NOTHING about this program is elementary ! This has to be one of the most complicate manip I ever hear of and so far, it can be done under a infinitesimal and one frame perfect stimulation. It seems identical elegant in a direction which I normally am a winnow of in program, I normally go for the most elegant solution because it ’ randomness nice overall .
All in all, I loved this project and after 3 months of work and 4 thousands line of codes, I am actually silent not done so far ! I plan to bring further improvements and features to the platform with the inaugural static interpretation being planned in the next month. I am very felicitous with this project and I fair hope an opportunity like this would come up again, possibly in another plot, who knows !
Read more: Control: Punch Card Puzzle Solution