So 7th Saga's RNG is manipulatable, and I'll describe why some other time. But today I want to talk about Bizhawk's capabilities to figure this out, because Bizhawk is meant to be a fantastic TASing Emulator, and you would think that'd make this easy, but it's... surprisingly twitchy.
The core thing I need to do is 'Execute a series of commands with a simulated controller and determine if I reach my destination without getting in an encounter.' For example, If I know it's 20 steps south, 8 steps west, and 14 steps south to the next town, I need to do those things and see if I'm in an encounter, for every possible starting randomizer position. Okay. So here's the things we need:
- A list of actions to perform in sequence
- A starting point (state)
- A failure condition
- A success condition
- The ability to load all of these things
- The ability to set the controller inputs based on these things
- The ability to detect the failure condition
- The ability to detect the success condition
The list of actions: so Bizhawk supports a movie format called BK2, as well as a generic thing called a 'mnemonic string' that is a list of all the inputs across all the controllers for a frame. Perfect! I just assemble a sequence of those across all the frames. A bit painful, but fine if done manually. Except... in current versions of Bizhawk, you can't use those to set controller inputs. The developers have an opinion about this: https://github.com/TASVideos/BizHawk/issues/2525 . Why would you use this in the middle of a normal movie? Ugh, okay. So to make this work, I have to record and load a movie and THEN I can set the inputs, and ignore the movie inputs. That's not so bad. If I do more rom hacking I can disable encounters and get clean walk movies.
Okay, a starting point. So you can do savestates, right? This should be a piece of cake. Wait... you can't use any other savestates when a movie is loaded? Hrm. Oh, there's savestate-anchored movies, you can just... wait, they're different types of save states? Alright, fine. So how do I make-- you can't save a memory save state using LUA, the scripting language for Bizhawk, to the file system, without making a movie. So we're back to Movies. If I create a movie with a specific anchor point (manually starting its recording at the right frame), then if I load that movie, and then save that state to memory, then I can load it from memory to repeatedly iterate.
GREAT. Alright, so surely I can load or create a movie in an automated fashion, right? I think you know where this is going: nope! You can do neither. You can detect if a movie is loaded, and query the loaded movie's input data (but not its savestates directly), but you cannot load a movie automatically. Command line parameters? Alright.
This is very weird to me. There are objects you can create but not save (memory save states), objects you can create but not use (mnemonic strings), objects you can load but not use (movie save states), and all of this to... run a for loop over a list of actions. I get this is a volunteer project, but... the story of how this came to be has to be truly, truly fascinating.