about the RNG in this game
4 years ago
Germany

So, a while back I was thinking about how I could motivate myself to actually start running any% glitchless again (I made a few improvements that could theoretically save 2-3 minutes with near-perfect RNG) but then again, it's kinda frustrating having to reset over and over again due to enemies not dropping stuff. So I came to wonder about how the RNG in this game works and if there is a way to actually manipulate it.

But then again, Sonny is a flash game and chances are that it doesn't even have a standalone RNG and just uses the browser's/script language's one. In that case, there'd probably be no way to manipulate the RNG in a way that works identically on all systems.

Still ... I wonder if someone here knows how to break games open and actually check for such things. Because I definitely can't do that. :D

CreepyGar likes this
Belgium

I think what would suck the most about this RNG thing is that if you can't manipulate the RNG then most of the unlikely stuff is located in zone 3. Because (relatively speaking of course), it's not that big of a runkiller to just ask your run to get the rifle/sword (idk which one you get in glitchless), which is a 1/2 chance, and at least one of the two Moon Struck-Horrors that you can get before the fight with the 3 ZPCI's, which is around a 2/33 chance (1/33 each), meaning you would get one run of this every 33 attempts you wouldn't reset to anything else but this. But yea from what I've seen the required amount of luck in zone 3 to get like perfect gear as early on as possible is pretty insane so it would be cool if you could manipulate the RNG in a certain way because that would be even more usefull in any% and 100%. Sadly I don't know much about coding and that kind of stuff but maybe you could ask someone from another community that has these kinds of things (like Pokémon and Super Mario Bros 3 for example) and ask them if they know how to do it

Germany

yeah, the early stuff is not the problem. getting the sword is 1/2 and also only 3 minutes into the run, so that is fine. Moon-Struck Horrors should be ~25% if you do 1 training fight in zone 2 and you can also get a backup weapon in tribal blade which performs almost equally well. But the main issue is indeed Zone 3 where you basically have to not only get specific encounters but also have them drop specific items - on top of the randomness, many of the later battles already include (baron anyone?).

While I'm generally not a big fan of RNG mainpulation, having it for certain things would definitely improve quality of life.

South Holland, Netherlands

I've been thinking about the same thing. However, RNG manipulation is easier or harder, depending on how the game works. There are a couple of steps required: Step 1 would be to emulate the game to allow frame-advance and save-states, so we can look at the game frame by frame. Step 2 would be to try a couple of things to find out how the RNG works. If the game is entirely deterministic, given a set seed, or if the seed changes, based on imputs or time or anything else. I doubt that the game factors in imputs, but time could be a real factor, and may be the only one. In this case, we're in luck, since we could RNG manip by just waiting for the right times (theoretically). Step 3 would be to see exactly when RNG gets called, so for example, when doing a training fight in Zone 2, if that fight drops MSH, is that because you perfectly timed the final attack, all the attacks, or the entry into the fight. Before every fight there is a fade-in, and after every fight there is a fade-out. In both places RNG could be called. During the fight there is a very small blink between your turn and the enemies turn, meaning that RNG could theoretically be called during that time, and this might also happen, as you can see with Veradux' behaviour. His moves seems to depend on how much health you have, but that also might be a simple if-clause. However, this is something we can already attempt to manipulate, by using stuns generously, in an attempt to get him to use re-energize. Since programmers are lazy, there is a good chance that all actions get determined before the fight starts, and the small blink is used to check the if-clause for Veradux' move, and that this is also where item drops are determined. Step 4 would then be to attempt this on multiple PCs. If the initial seed is determined based on time, we could just return the PC to that exact time, something like people do for RNG manip in Pokemon D/P/P speedruns, but if the seed is based on other factors, this will probably not work.

We're currently stuck on step 1, because PC games have almost no emulators, and flash games have none, and even then, games that use the mouse have none. Emulating Sonny is something that's currently impossible to do. We could try to ignore that issue, and just perfectly time runs, in an attempt to get some data, but this is very slow. However, we do have some videos of good runs, with exact timing, since videos do allow frame-advance. This would be an ok place to start. And this is something I might even start doing soon. For example, I have a recorded run in which I get MSH twice, and I could figure out the exact second that run started, since that's how OBS formats the video titles. And from frame advance I might be able to time the exact frame it started. I could also do that with the Any% and 100% WR, but that's because the clock is visible on screen. It would be great to get more evidence of double MSH runs to figure it out, which means grinding. :)

TLDR: We can probably only figure out how RNG works with more data, since we can't emulate the game. So if you want MSH, show up with games in which you got MSH, and work from there. But you can still try to manipulate Veradux' behaviour, because it follows a relatively obvious pattern.

Edited by the author 4 years ago
IschmarVI likes this
South Holland, Netherlands

Something I forgot about the game. There is an FPS tracker in the top-left of the screen. And it's not constant, not even close. It fluctuates around 30 FPS, but it feels like it changes almost every frame. Most RNG systems use the exact amount of frames to determine RNG, meaning that if you know the exact number of frames in between RNG calls, you can determine the exact result. However, the amount of frames in a second seems to be somewhat random in this game, so even if we assumed 30 FPS, and we know the exact time down to 1/100th of a second, we could only estimate the amount of frames. And 2 frames next to eachother could mean something completely different, so we can't be off by a single frame for RNG manip. This might not be the case, but it's a reasonable chance. Therefore I conclude that we basically cannot manipulate item drops.

TLDR: The final sentence.

IschmarVI likes this
Germany

regarding Dux' AI. I am almost 100% positive that it's an if clause. Based on what's standing on the wiki, it appears, that the game distinguishes between "defensive" moves and, well .. "non-defensive" moves I guess. Then, for every AI-controlled unit in the game, there are 2 percentage-HP-thresholds. If the current percentage health of a potential target for a defensive ability is below the first threshold but above the second one, there is a 50% base chance that the AI chooses a defensive ability (so basically a coin flip). If the HP percentage is below both thresholds, there is a 100% base chance that the AI chooses a defensive ability.

I say "base" chance because for enemies there appears to be a modified that varies from stage to stage that also influences the odds of using a defensive ability. For most stages with one opponent (but for some multi-foe stages as well) that modifier is 100% or 1 but for most stages with more than opponent it is below 1, thus reducing the chance for defensive abilities. When it comes to the players party, I assume that that multiplier is either 1 or isn't used at all. But then again, there are also a few AI bugs (which might also be the reason why dux sometimes simply refuses to heal?). Unfortunately I wasn't able to find anything about Dux's HP-threshold values (should be 3 sets, one for each stance).

Besides that, the game apparently creates a set of "possible skills" and randomly chooses one of them. I assume that the game first rolls whether the ability is "defensive" or not and then randomly chooses one ability within that set that is not on cooldown. The target is probably determined after move selection with defensive abilities always being used on the target with the lowest percentage(?) health (or sometimes on the user due to a strange bug) while for non-defensive abilities, the AI has a unit-dependent chance to automatically target the foe with the lowest absolute effective health (health + shield strength). Otherwise, a target is picked at random. But then again, this is mostly based on Wiki-stuff and observation, so it's not 100% guaranteed to work exactly like this.

Back to RNG manip, what you said pretty much sums up my assumption. Yet again, I lack the technical knowledge to actually do RNG research myself but for Sonny, there is a high chance, that there won't be many ways to actually manipulate the RNG in a reliable fashion.

That means, back to grinding for any% glitchless I guess ... well, once I find the time for it.

Sowwhats likes this