Final Fantasy by TheAxeMan

  • ROM: Final Fantasy (U)
  • Abuses glitches
  • Manipulates luck (a lot)
  • Uses power cycles
After much hard work I proudly present this highly optimized run through the US version of the original Final Fantasy. This run beats the current record by exactly 9800 frames. That's 2 minutes, 43 1/3 seconds.
The overall plan is about the same as before. However this time I analyzed the game's internal algorithms. I used this information to create and use an extensive amount of optimization scripting. There are also a few other odds and ends, but most of the improvement comes from the optimization scripts. I also used ffhackster and the fceu memory watch feature a lot, so many thanks to everyone who contributed to those. Maximus' tas editor was useful early on but failed me later as it doesn't support power cycles.
I wrote three different scripts to optimize different aspects of the run. The most important was an overall pathfinding script that would tell me what enemy groups I would encounter given a route through the game. The next most useful was a run analyzer that figured out the optimal manipulation for running from a series of battles. I also had a battle analyzer to optimize battles, but this was only used in the first few battles. The algorithm controlling which battles come up is pretty much separate from the battle randomization for hits, damage, running, etc. so it made sense to analyze these separately.
The pathfinding script used a little runset that listed how many steps I would take through each area. It could take some regression options, analyze all the permutations then report the best result according to a cost function. The cost function took into account the time taken to walk around, run from battles and fight if necessary. Of course the most useful aspect of this was to avoid fights with the dreaded "can't run" flag. The secondary benefit was fewer fights in general. Finally, extra pacing steps are almost completely eliminated. In order to use this, I needed to analyze and plan out every step through every area ahead of time. But the results were well worth it: I eliminated all "can't run" fights except for two in the final dungeon. Additionally, the total number of random battles is reduced from 184 to 173. So basically most of the improvement comes from this.
The run script figured out how to manipulate running from each battle. The highlights of this are controlling the number of enemies that show up; fewer enemies are easier to manipulate and there is an extra frame of loading for each enemy. You might notice throughout the run that the enemy groups are a little smaller than you normally see throughout the game. Another big factor is preemptive battles. It seems that the little "preemptive attack" message comes up quickly, but it actually causes 29 frames of delay. Sometimes it's worthwhile, but often it's just a waste. Generally, it's more useful early on when it increases the probability of running from very low to 100%. The last preemptive is in Ice Cave. These running issues might seem like a pretty minor thing, but it adds up to about 15-20 seconds over the course of the run.
The battle analyzer was really just useful on Garland and the pirates. I also ran it on the wizards, but it just confirmed that my old method was optimal. Once down to one guy it was easy to do the battles by hand.
I did some extra research to find situations where I could walk without triggering an increment of the encounter mechanism. FFHackster was very useful here. In fact, I used it to create a hacked rom that identified these "free" squares for me. In particular, this showed me which squares around Coneria were free. This is why you see me walk a bit out of the way. Other free steps are the first step into or out of the canoe or ship. To take advantage of this, I get in and out of the canoe as much as I can. Of course, the ship docks are all free spaces. Interestingly, the shadow of Mirage tower and the spaces next to the Temple of Fiends are also free. Finally, in dungeons, the squares around doors and the south wall of rooms are usually free. I also used my knowledge to create another hacked rom with no random encounters that was very useful for testing. This was nice as I needed to analyze everything ahead of time to set up the pathfinding script. I actually created this run with the mark-up hack and then hexed the checksum in. Here's a screenshot. The white marks show free squares.
The main way I manipulate which battles I run into is by saving my game and cycling the power. Of course in this game I can only do it in the outer world and I need to obtain tents, cabins and houses (all three are used!). The main purpose of the pathfinding script was to tell me where to use these. But I needed to coordinate this plan with obtaining the items. In the end, it worked out very well; I cycle power five times to manipulate encounters compared to just once in the old run. Luckily, I'm able to pick up the items I need from chests until I get to Gaia where I walk right by item shop on my way to the fairy's spring.
Since there are essentially only 256 different outcomes for a given set of battle commands, I was able to plan the battles in the TOF in the planning phase. So the healing items used beforehand was planned for earlier.
It's well known that Final Fantasy has a number of glitches. However, none of them really break the game to allow for a really crazy TAS. In fact most of them are generally more harmful than good. There are two that come into play here. First, dark status actually has no effect. Second, it's only possible to get one levelup per battle. This first affects me after beating Astos. Since I got rid of the "can't run" battles, I actually have a heldover levelup through most of the game. You might think this is a disadvantage because the extra stats would be nice to have. But it ends up being a blessing by allowing me to use the bane sword against phantom and also manipulate two zombie Ds in the following battle. This is the case because a levelup pulls some random numbers out to determine stats. The phantom only gives 1 exp, so it's sort of unlikely to get a levelup here any other way. This is why I had to slug it out with him in the old run.

Specific changes:

  • The fight with Garland is about the same length as before, but I manipulate luck from the levelup. This adds some extra time here (about 2 seconds), but it's an investment that pays off quickly in manipulating running from battles throughout the game. The battle plan was generated by my battle analyzer script.
  • The pirate fight was improved by several seconds using the battle analysis script.
  • Walking carefully around Coneria and on the Elfland dock helps me avoid the extra sailing that I did in the old run and cuts down the number of fights.
  • Instead of buying a silver sword I pick up the dragon sword from the Dwarf Cave treasure room. This is convenient because there are a couple savegame items that I need from there. It was actually a pretty close decision between coral sword and dragon sword, but after a lot of analysis I am pretty sure the dragon sword was the right choice. Anyway, not getting the silver sword lets me walk around Elfland town and I also don't need to fight a battle to get enough gold. The dragon sword isn't quite as powerful as silver sword. The only place it really makes a difference against Lich, where I need 5 rounds instead of 4.
  • On the way to Melmond I do some extra sailing. This cuts out a fight later on due to how the encounter mechanics work. This is the only time I add extra steps for this reason. Other times I use slack steps to save time. For example, walking around elfland or sailing all the way into the dock.
  • The first power cycle happens right before entering Earth Cave the second time. This lets me avoid the nonrunnable wizard battles. The old run dealt with two of these.
  • The second power cycle happens on the way to Crescent Lake.
  • After getting the canoe, I use it to reduce my step count by getting in and out of it as I walk back to the ship.
  • In Ice Cave I pick up a tent in addition to the gold. The tent gets used right after exiting for the third power cycle. Since I was walking right by that chest it was better to get this and do my shopping in Gaia rather than Crescent Lake.
  • In Gaia I buy one house and three cabins. Some of these will be used for luck manipulation. The rest go to restoring some hp for battle in the final dungeon.
  • Once again it seemed to be a better deal to do the Sea Shrine before the waterfall. This time I can run from every battle, saving time over the last run where I needed to take out a couple ghosts.
  • Despite being on a lower level, Kraken still takes 10 rounds. This time it happens that he successfully gets me with his ink and I can demonstrate the dark status glitch.
  • In the waterfall robot room I avoid the forced battle square altogether by getting the robot to walk onto it. I didn't think it was possible before.
  • The fourth power cycle happens after the waterfall, almost at the same spot as the only one used in the old run. This gets rid of the zombull no-run fights near Lefein.
  • I also get luckier on Dr. Unne, making him walk to toward me a bit more than last time.
  • The fifth and final power cycle happens right before entering Mirage Tower. Compared to the old run this leads to fewer fights here on out, especially in Sky Palace. But I end up getting two two-enemy fights in the final dungeon instead of one 2-enemy fight and one with 1 enemy.
  • Unfortunately I don't run into WarMech on Sky Palace 5F. Interestingly though, Sky Palace 5F has a much higher encounter rate than anywhere else in the game. It's 24/256 vs 10/256 in the outer world, 3/256 for the ship and 8/256 for all dungeons except the last floors of the final dungeon.
  • This time through Gurgu I take extra steps on lava to cut down the number of encounters.
  • In the final dungeon I beat two Gas Ds, one of the toughest enemies in the game. This time I'm able to use bane on the phantom and still get two zombie Ds afterwards by cashing in my heldover levelup. The rest of the game goes just about the same. Unfortunately, there's not much I can do to manipulate the bane sword to work faster. The only way to change luck is to wait while the randomization seed cyles at a rate of one seed every two frames. There is only a 3/256 chance that bane works. However, several of the fiends will kill me for sure if they attack first. In that case I only have a 1/256 chance of going first and successfully killing them. That means I may have to wait up to 510 frames to make things line up.

Other notes

  • One suggestion I got was to transfer or drop something to get the bane sword in the first slot. However, the random seed cycles while moving the cursor so it's no problem to have the bane sword in a different slot.
  • As before, my solo fighter finishes at level 15. But despite fighting fewer battles, he gains more total experience due to the huge amount from the Gas Ds.
  • Since we don't see WarMech, this run should have a new screenshot. I propose the Gas D fight at 231249 or fighting Kraken while Dark at 171475.
  • I haven't analyzed Final Fantasy IV or VI encounter mechanics, but I bet you could use similar pathfinding techniques to improve those runs.

Improvements

  • I did luck manipulation for map-walking by hand. For example, the bats in Earth Cave. I got really lucky this time. If you could automate and tweak this you might get a few frames.
  • There's some other source of delay after the battle that my run analyzer doesn't pick up. It's small, but could add up given the number of battles.
  • Could combine all the scripting together and regress the whole thing. By checking fights, walking and running there might be some advantage to be had. While you're at it you might want to set it up to work on a supercomputer or large cloud computing cluster...

On a personal note...

I'm not saying that this will be my last TAS, but it will be the last one before some major changes in my life. In that respect it's sort of a masterpiece that I've been wanting to finish for quite a while. So I hope everyone enjoys this.
I've been a part of the TAS community for about four years now, though lately I've regressed pretty much back to lurker status. It's been really neat to interact with so many smart people and I'd like to really thank Bisqwit and everyone else on this site for a lot of great times.

Truncated: Accepting this movie.
Nice to see you back, Axe

Raiscan: Processing with MKV/Chapter treatment as I have the permission and information required from the author. Delayed due to hard resets not being converted when using FCEUX's fcm --> fm2 converter. I'd like to use FCEUX for capturing all new publications, so I'll wait for a hotfix on this one.
DeHackEd: <voice style="seagull">Mine! Mine!</voice>


TASVideoAgent
They/Them
Moderator
Joined: 8/3/2004
Posts: 15582
Location: 127.0.0.1
This topic is for the purpose of discussing #2057: TheAxeMan's NES Final Fantasy in 1:10:16.18
Joined: 4/25/2004
Posts: 615
Location: The Netherlands
Heh. I actually "secretly" prepped to redo your run. After much investigation, even diving into the decompiled source to reverse the rng, I started on the run, confident I could smash your old record. However, I couldn't even improve your Garland fight using an exhausting search. Eventually I just gave up. So good work! :)
qfox.nl
Joined: 4/25/2004
Posts: 615
Location: The Netherlands
Ok, a somewhat more detailed comment after watching the run. First off, I expected to shave of more time (I set the mark at 1:00:00 :p), so that's kind of disappointing (that my estimation was so off :). Secondly, but that's just personal, I don't like the reset trick. Ohwell. Thirdly, I was planning on not buying anything at all. I'm quite surprised you actually bought anything at all. I was planning on taking a new sword from the treasure sword and not getting hit as much as possible (should be possible, no?). Fourth, congrats on figuring stuff out like npc positioning (I wouldn't have seen that), being able to determine ambush/preemtive up front, and apparantly being better at manipulating luck then I was :p Garland: Using running away to manipulate luck was brilliant! I never thought of that. Still, you seem to take more turns to skin his purple ass then the (seemingly) minimum of 2 turns and one extra final blow. Howcome you skimp over the forest tiles though when walking to the bridge? Stepcounter padding? Pirates: Wasn't it possible to kill the pirates before they struck? Or was this simply the fastest using an exhaustive search? And also, why not let two of you get killed instead of just one? You're not using the other one anyways... Nice catch getting off shore to reduce stepcounter (yeah I found that too :p). Good one catching the free tile below the door in the second dungeon ;) And the other free tiles you missed in the first run. I have no real comments on the rest of the run. Great job :D
qfox.nl
Ambassador, Experienced player (709)
Joined: 7/17/2004
Posts: 985
Location: The FLOATING CASTLE
qFox, you are very optimistic! Good luck finding 10 more minutes of improvement. It would take a really big glitch. Without the power cycle trick I am extremely skeptical that you could even match the old run. On Garland I really doubt that you can kill him in two rounds with no weapons. I would have done three rounds if I decided not to manipulate luck on levelup. Four rounds was best to get luck. Only a 25% chance to get it. But also remember that the goal isn't fewer rounds, it's less time. Having my guys run unsuccessfully takes a lot less time than a hit and also affects the randomizer differently. So my scripts considered all the options. In the pirate battle you should count the hits. The pirates get the minimum number of attacks. This would be completely impossible to do without taking a lot of damage like this. Also, you do have a good idea with trying to have only one person survive the pirate battle; you only have one person to get the levelup text and run from the rest of the battles. However, the second person is helpful when fighting the wizards. As I said in the submission text, there are a limited number of outcomes and getting both wizards to miss while I hit actually only happens when you have two people and even then there's only a 1/256 chance! With only one person, the best way to proceed would have been to use the inn on the way out of Pravoka as a solo guy would have to take some damage against the wizards. The time to use the inn negated the benefit of having one guy alive! Another possibility is picking up iron armor in the cave, which again takes time.
Former player
Joined: 6/25/2004
Posts: 607
Location: Maine
I haven't watched it yet, but if you found two and a half minutes of improvement out of a video I thought couldn't be done any better, you have my kudos and a very likely "yes" vote. I read some of the descriptions and I got confused at the high-level math terms. Math never has been a real strong point for me. :p
Active player (253)
Joined: 7/30/2006
Posts: 208
Location: Alefgard, USA
Yes vote -- great run, AxeMan. I have a question though -- in the earth cave, do the events during the vampire fight affect the battles you encounter after the vampire is killed? The same question can be posed for the Eye in the ice cave, and the Phantom in the final dungeon. I only ask because I think it would suck to kill the vampire, only to encounter a group of wizards on the way out of the earth cave. Believe me, that happened numerous times on the console!!
Ambassador, Experienced player (709)
Joined: 7/17/2004
Posts: 985
Location: The FLOATING CASTLE
Thanks dave! The algorithms that control which enemy groups you encounter and when/how many steps are completely separate from the in-battle randomization rolls. So when I planned things out I did know for certain that no matter what happens in the boss battles, the random encounters will be with particular groups and after a particular number of steps. The "can't run" flag is tied to the group and is not random. Now most enemy groups have a random number of enemies. The number of enemies that show up is controlled by the same randomizer as the battle algorithm. This also controls surprise and preemptive status, order taken in battle and rolls for success when running. My run analysis script had to consider all of this. For example, after the Phantom, I knew that I was going to meet Zombie Ds. But the number of Zombie Ds varies between two and four depending on the same randomization that controls whether bane sword works or not.
Skilled player (1652)
Joined: 11/15/2004
Posts: 2202
Location: Killjoy
When you built your cost function, did you know exact frame count costs, or did you make your own? Really curious about your equations. What an amazing way to use statistics and detection/estimation theory to maximize the TAS without checking every combination/permutation. Truly impressive. No Vote. (j/k)
Sage advice from a friend of Jim: So put your tinfoil hat back in the closet, open your eyes to the truth, and realize that the government is in fact causing austismal cancer with it's 9/11 fluoride vaccinations of your water supply.
Ambassador, Experienced player (709)
Joined: 7/17/2004
Posts: 985
Location: The FLOATING CASTLE
I used frame count as the unit in all my cost functions. There was a mapping for every enemy group as to what gets added to the cost function when they are encountered. If I could run then the cost used an average of the total time needed to run from battle. I didn't go into too much detail in some cases. For example, in most cases it wasn't important what part of the outer world I was in as long as I didn't have to worry about that "can't run" flag. I think this was accurate enough. The main thing I was going for was cutting out "can't run" fights and then the number of fights in general, so this accomplished that pretty well. The shadow group that has a 251/256 chance to surprise me is also very annoying and I tried to cut those down. Now when it turned out that I couldn't get through the last dungeon without fighting, I needed to estimate the time needed to beat those different enemy groups. Then I would set the cost based on my best guess on how long the fight would take and other things like obtaining healing if I needed to take damage. That's how it arrived at this route.
Experienced player (614)
Joined: 4/24/2005
Posts: 612
Took a bit of time to watch this one but it was worth it. Your work doesn't go unappreciated, at least to me. It takes a lot to take on such a beast and to improve it by that much so, nicely done man. This is an easy yes vote.
Joined: 4/25/2004
Posts: 615
Location: The Netherlands
By the way, I just remembered (so I don't know whether you did this) but it's actually faster not to get a pre-emptive battle. You save 20 frames by not getting the "a chance to strike first" message :p Does make it harder to get a proper flee, but if you can it within 20 frames... And where the hell in the RAM did you find that 'cant flee' switch? I searched and searched but was unable to find it :/
qfox.nl
Ambassador, Experienced player (709)
Joined: 7/17/2004
Posts: 985
Location: The FLOATING CASTLE
By the way, I just remembered (so I don't know whether you did this) but it's actually faster not to get a pre-emptive battle. You save 20 frames by not getting the "a chance to strike first" message :p
That's in the submission text, but I understand if you can't find it because I wrote too much! In fact, I actually counted about 29 frames for preemptives: 19 when the battle starts up and 10 more after the battle. In the submission text you'll also see how I manage that. For more research on the "can't run" flag, I highly recommend that you run ffHackster. It's available from many locations online. But I can answer your question with the offset for the battle data in the ROM: 2C410. Starting there, every 16 bytes describes one of the enemy groups and each group has one "can't run" bit.
Joined: 4/25/2004
Posts: 615
Location: The Netherlands
Ohhh, that's my problem then. I never really gave the ROM data much thought (except for decoding the rng, which was so frigin simple). I guess that data never even gets loaded into the RAM, which was why I couldn't find it. I check FFhackster out, but decided it was a ROMhacking tool and didn't spend too much time on it. Ohwell, I guess now I'm happy I only wasted the preliminary time on it and didn't actually do the run :)
qfox.nl
Editor, Reviewer, Experienced player (979)
Joined: 4/17/2004
Posts: 3109
Location: Sweden
TheAxeMan wrote:
I used frame count as the unit in all my cost functions.
Couldn't you have used entertainment as your cost function instead?
snorlax
He/Him
Joined: 5/20/2007
Posts: 174
Location: Wisconsin
Truncated wrote:
TheAxeMan wrote:
I used frame count as the unit in all my cost functions.
Couldn't you have used entertainment as your cost function instead?
They're the same thing. This run is the reason why I come here. Any questions that I had (and that most people have had) were answered well in the submission text. Congratulations on finding so much time to save; it sounds like you covered your bases pretty well.
caitsith2
He/Him
Player (47)
Joined: 3/26/2004
Posts: 194
What version of FCEU do I need to watch this? I have tried a few versions, all of the ones I tried desyncing at the garland battle.
Joined: 5/29/2004
Posts: 757
I dunno.. almost voted No because there was no War Mech abuse.... but then I realized.. wait a second, this is pretty damn impressive WITHOUT it... and then it dawned on me how much more pwnage there was. A most excellent improvement, despite that... and the whole robot saves the day with the encounter was made of awesome! A definite Yes vote. Mr. Kelly R. Flewin
Mr. Kelly R. Flewin Just another random gamer ---- <OmnipotentEntity> How do you people get bored in the span of 10 seconds? Worst ADD ever.
Ambassador, Experienced player (709)
Joined: 7/17/2004
Posts: 985
Location: The FLOATING CASTLE
Thanks everyone, glad you enjoy it. Caitsith2, I don't know how it desyncs for you. I have tried FCEU 0.98.28 and FCEU 0.98.15 and it is fine.
Player (84)
Joined: 8/18/2008
Posts: 80
This run (much like the previous one) just astounds me with the power of it's manipulation. There are so many hazards that should make what is happening impossible yet all of it is bypassed or skirted.
Player (121)
Joined: 2/11/2007
Posts: 1522
You rock my world Mr. Man. I liked your old one and this was gravy. Could you perhaps make available an IPS for your tile-counting (or whatnot) hack? I think it would be interesting to watch that way.
I make a comic with no image files and you should read it. While there is a lower class, I am in it, and while there is a criminal element I am of it, and while there is a soul in prison, I am not free. -Eugene Debs
Ambassador, Experienced player (709)
Joined: 7/17/2004
Posts: 985
Location: The FLOATING CASTLE
Ok, here's an IPS for my hack: http://home.comcast.net/~f_amoroso/tas/FinalFantasyTAS.ips Making the hack was actually pretty easy to do with ffHackster. Anyway, if you play on this version you can see exactly where around Coneria there are no encounters.
caitsith2
He/Him
Player (47)
Joined: 3/26/2004
Posts: 194
Okay, I decided that it may well be something inside the directory where the emulator was stored that may have been causing the desync. Put the emulator into a new directory, and desync disappeared.
Ambassador, Experienced player (709)
Joined: 7/17/2004
Posts: 985
Location: The FLOATING CASTLE
Could be the savegame file. I forget if that affects things when you play a movie. An interesting aspect of the battle random number generator is that the seed is stored in the WRAM, the savegame file. So it stays when I do a power cycle. All the information for encounters is in RAM, which allows me to manipulate encounters with the power cycle.
Sir_VG
He/Him
Player (40)
Joined: 10/9/2004
Posts: 1913
Location: Floating Tower
Swordchucks win over all! Though I think the Fiends are getting smarter. I noticed that Tiamat tried using Bane against you. Too bad it failed! And putting Kary 4th was really odd. I thought I fell asleep and missed that. ^^;; Good work. YES vote.
Taking over the world, one game at a time. Currently TASing: Nothing
Ambassador, Experienced player (709)
Joined: 7/17/2004
Posts: 985
Location: The FLOATING CASTLE
Thanks. The luck did turn out pretty funny. When playing normally I take out Kary last too. Or at least a little later. There's nothing to stop you from going on and not much useful treasure in the Volcano either.