Question about RNG Manipulation
4 years ago
Nova Scotia, Canada

I've watched a few videos regarding the rng manipulation but am still somewhat lost. Anyone care to explain it? I know its mostly to do with timing of inputs during Opinion Leader creation but that's about all I know.

I'm not the expert Dragondarch but I think I got this. If you look at the RAM while playing the game on an emulator, you'll see a number that very quickly loops from 0 to 255 and back again.

This is the seed and the main source of RNG in the game. Dragondarch's Any% guide describes how to select the Opinion Leader's sex at the exact right time to get seed 75. In his document linked in Getting Started thread (https://docs.google.com/spreadsheets/d/1K4RitjQ3d6rg72qWHLvKdayedIwulyzyyfQxGkMdPPk/edit#gid=826367894) you will see on the Card 2 List (No Dismiss) tab a very impressive Warren Tarot card spread for all 256 possible seeds. (0 is a valid seed.)

The seed also determines what you pull from buried treasures, equipment from liberating temples, how fights go, what Tarot you pull from liberation...many things. Like if the hit rate is 50% for a low AGI character, maybe seed 0 to 127 would be a miss and 128 to 255 a hit. My guess for Tarot pull is the game does seed%21 and the remainder from 0 to 21 determines the card.

Fortunately, the seed stops cycling when you are selecting where to move a unit with the flag. So what matters here is selecting the same exact ending location so the unit stops moving on the same seed each time. Since the seed is cycling while deploying units, you have to be very fast or pause for a very specific amount of time to preserve the luck manipulation track that you are on. It's probably impossible for a human to manipulate more than the first 3 treasure/item drops due to the cycling in between stages on the world map. You see that Dragondarch makes no attempt at manipulating the seed after Warren's Castle and this is why.

Also note that viewing the RAM while speedrunning is illegal. Got to practice when not going for a real record.

United States

Something to note - seed manipulation is possible later in the game, but it almost requires the use of versions with in map saves (Nintendo Power kiosk SNES version, PS1, Saturn) and would take considerable time to setup. There's at least one specific item in the game that might make it worth it, but I'm doubtful it's faster than current routes.

Edited by the author 3 years ago
United States

Seed manipulation is technically possible, but the game uses other values to determine the actual RNG you get. Having 2 different save files at different points in the game and loading them on the same seed will yield different RNG results, which is easily observed by pulling jokers from the army management screen immediately after loading. My guess is that's probably using some character stats, maybe number of units, goth, or some other nonsense to slightly change what RNG we're actually getting after the seed is determined.

The other issue is that enemy units on the map call the RNG to determine their movement, and they call it fairly frequently. You'd have to be absolutely perfect in your movements to get the same result even if you could get everything else to line up.

NewSchoolBoxer and Krayzar like this
United States

I have some theories as to what that "other factor" (or factors) is but these take a lot of time to test. Specifically what I'm trying to achieve is a drop off an enemy unit which introduces a lot of factors to eliminate. I have some parts of a setup working, but not to the level where I understand what's happening or how to manipulate things the way I'd need.

My current solution to enemy RNG for this - not moving at all! =P

Edited by the author 3 years ago

Thanks Dragondarch for the valuable info! I have a decent understanding of assembly language but I never could figure out an SNES debugger enough to examine the code frame by frame. Do you know if saving then loading the game file resets the seed or do we have to reset the console?

So to manipulate RNG for an item from a defeated enemy unit, my choices would be a Trade Ticket or Royal Crown. I've pulled a Trade Ticket, an Undead Staff and Undead Ring this way in a normal playthrough, so I doubt the Crown is excluded.

United States

I have literally no coding knowledge, actually. All of my findings have come from sheer testing, sometimes via brute force lol

Resetting does put the seed back to it's initial state (otherwise I would have had to power cycle in between every attempt), but I don't know how loading a save file affects that. There could easily be factors that could shift the seed around (possibly pulling data from the save files themselves).

It could theoretically possible in real time to do the manip on Castle of Warren, save and reload, then try and manip Sharom from there, since the save file (should in theory) be identical every single time.

NewSchoolBoxer and Krayzar like this
United States

I can confirm that a soft reset on SNES (L+R+START+SELECT) seems to take the seed value from the initial frames at the starting screen for the save. I do not remember if the value continues to count up on the save screen itself. It's been a while unfortunately.

@NewSchoolBoxer My own idea is Trade Ticket manipulation, but I don't deny that an early crown could be extremely useful as well!

Problem is, I'm not sure if there are item tables per stage, globally, or selections based on other values. I believe item drops from enemies are at the very least the most "global" and may be the only way for Trade Tickets to spawn, but that other factor @Dragondarch mentioned is the stumbling block. I can manipulate a drop happening, but haven't quite figured out how to choose what item I get yet.

Edited by the author 3 years ago
NewSchoolBoxer likes this

Thanks @Krayzar, so if we knew all the sources of RNG then each stage has the potential to use a save + reset strat to start with a manipulatable seed.

I'm quite certain drops are global: a) I've made a Lich as early as Slums of Zenobia b) The Japanese TAS on YouTube pulls a Notos at Warren's Castle and Sharom: c) This ROM map suggests drops are global: https://finnshore.webs.com/rom-map.txt

Needless to say, space was tight on SNES games, with 4 MB being on the high end. The most size efficient way to generate random equipment and items while excluding key story ones is to place the obtainable ones in the same block of memory. Generate "random" number from 0 to (possible drops -1) then add to the starting address. That's the drop.

Fair to say these equips are impossible to get as buried treasure: 1=Sonic Blade - STR+13 2=Durandal - STR+12 3=Bizen Sword - STR+11 4=Zepyulos - STR+15,INT+3 5=Fafhniel - STR+20,INT+4 6=Zanzibar - STR+18 7=Brunhild - STR+20

I read on the hardtype mod site that Nue's Shield at 0x64 cannot be found as a treasure on SNES due to a bug, leaving 92 possibilities. Also suggests zombero knows how the algorithm works.

Ginger Cake at 0x65, the first item, certainly would be excluded, as would the Mystic Treasures and Zodiac Stones at the end. I assume Glass Pumpkin too. Excluding story items leaves the items obtainable from defeating a unit between 0x97 Stone of Dragos and 0xB6 Crystal Ball, inclusive, for 32 possibilities. So Trade Ticket at 1 in 32 is easier to manipulate than the Notos. Or harder if defeated unit drop chance is 1 in 10?

Krayzar likes this
United States

I've been looking for that ROM map for a while actually! Thanks for that.

There's a bunch of info for the PS1 version that can be found as well that could be helpful on SNES, assuming the system didn't change, but that ROM map should be the end all be all for this.

I agree, that certainly looks like things are global in the stages, the way things are grouped. Knowing what is in the table will help rule out factors for the drops.

Zombero's work on that hardtype mod is pretty awesome actually. Can't believe I missed that.

I have to find my TAS now. This might be all that's needed to crack it, but at least there's folks we could possibly reach out to if we get stuck!

NewSchoolBoxer likes this

Yeah sure! PS1 and SS versions could also have glitches not in SNES. Easy to notice that Petrify always misses on PS1. I appreciate the PS1 improving spell animations, preserving special character sprite palette on class change and hitting the square button to queue multiple move commands on the same unit! Balanced against loading one boss battle per stage, it could be faster than SNES.

I see resources on how to use Geiger's debugger. If I can figure that out, I can move on to bsnes_plus debugger. Notable that Bizhawk has a way to mark data from code in the ROM by playing enough of the game.

Krayzar likes this