Submission #8608: OceanBagel, Svool_Gsviv_, duuuuude5, BlueMushroom64 & chair547's Linux Undertale "all major endings" in 3:58:21.91

Linux
all major endings
(Submitted: all major endings)
(Submitted: UNDERTALE USA)
libTAS 1.4.4
575967
40.272030826270885
58761
PowerOn
Submitted by OceanBagel on 9/18/2023 2:51 AM
Submission Comments
Undertale is a 2015 2D role-playing video game created by American indie developer Toby Fox. Undertale is notable for its use of multiple endings that change depending on the player’s actions. The goal of this TAS is to achieve each of the major variations in the endings, 10 of them in total. This allows for a diverse mix in the gameplay, as a lot of aspects that are normally skipped become required. For example, one of the main branching qualifications in the Neutral endings is which of the main bosses are left alive (besides Asgore who dies in all Neutral endings). Normally in Neutral speedruns, all four main bosses are left alive, but in All Major Endings, boss kills are part of the route.
The multiple branching endings also create opportunities for clever routing to save time. For example, we could save before Mettaton, kill Mettaton, and get an ending, then reload, skip Mettaton, and get a different ending. The unique route resulting from optimizing these routing decisions is what makes this an attractive and interesting way to speedrun the game.
This TAS was made as a collaboration between the five authors. We first TASed the endings individually and then stitched the individual files together into one movie file at the end. This process was not trivial and required quite a bit of research and scripting to pull off, but allowed us to make improvements to individual endings without having to redo everything afterwards.

Note to Publisher

This TAS ends on the True Pacifist Ending, which includes a unique credit sequence where you can dodge the credit names. We made a version modified to put the TAS authors’ names at the end of these credits, which is done with a .bps patch applied to the game.unx file in the game's assets folder. This patch only changes the final credits and their label ("AME TAS AUTHORS") and leaves the rest of the game untouched, including everything that happens within the timed portion of the TAS. The patch is available here:
We would prefer this version with the modified credits to be used for the published encoding, with the file for encoding here:
If the use of modified credits in this way is deemed unacceptable, here’s an alternate file for encoding that syncs with the unmodified credits:
Additionally, this TAS contains segments where the game itself runs at different framerates, including 30fps, 20fps, and 10fps. For this reason, we recommend encoding the TAS at 60fps.

Sync instructions

Install libTAS v1.4.4. Install the Linux Steam client. Install Undertale v1.001 (the latest version on Steam). Check that the game runs through Steam. Launch libTAS using the Steam runtime with the following command: ~/.steam/bin/steam-runtime/run.sh libTAS
Set the game executable to runner, located in the game's directory. Under Runtime > Time Tracking, clock_gettime() monotonic should be checked. Also ensure that the save directory at ~/.config/UNDERTALE_linux_steamver either doesn't exist or is empty.
In order to encode audio, you may need to install the 32-bit version of libswresample3 with the following command: sudo apt install libswresample3:i386

Game Objectives

  • Emulator used: libTAS v1.4.4
  • Plays on version v1.001
  • Reaches all 10 major endings, as defined below
Endings in Undertale are divided in several ways: by route (Neutral, Genocide, True Pacifist, Hard Mode), by branch (the major variations of the Neutral ending based on the dialogue path, as well as the other routes as one branch each), and by ending (with each specific variation of the ending cutscene counted as its own ending). While the total number of endings in Undertale is 93, these can be grouped by branch into 10 distinct major endings (excluding Hard Mode, which is not considered a major ending).
This category definition corresponds to the definition in the RTA All Major Endings speedrun category. End timing for each ending is also taken from the RTA ruleset. Namely, the ending is considered complete upon touching the final door for Neutral, upon choosing “Erase” or “Do Not” for Genocide, and upon closing Toriel’s final textbox for True Pacifist.
Here is a flowchart of all 93 endings in Undertale, arranged by branch:
Here are the 10 major endings, along with basic requirements and the corresponding ending numbers from the above flowchart:
Ending nameEnding numbersRequirements
True Pacifist Ending65-68Complete any True Pacifist Ending.
Genocide Ending90-93Complete any Genocide Ending.
Family Ending/Betrayed Undyne Ending31-64Complete the Neutral Ending with Toriel, Papyrus, and Undyne alive and less than 10 kills.
Exiled Queen Ending5-30Complete the Neutral Ending with Toriel alive and at least one of the following: 10 or more kills, Papyrus dead, or Undyne dead.
Undyne Ending69-74Complete the Neutral Ending with Toriel dead and Undyne alive.
Mettaton Ending75-80Complete the Neutral Ending with Toriel and Undyne dead and Mettaton alive.
Papyrus Ending81-85Complete the Neutral Ending with Toriel, Undyne, and Mettaton dead and Papyrus alive.
Dog Ending86Complete the Neutral Ending with Toriel, Undyne, Mettaton, and Papyrus dead and exactly 4 kills.
No King Ending87-88Complete the Neutral Ending with Toriel, Undyne, Mettaton, and Papyrus dead, a murder level of less than 12, and a number of kills that is not 4.
Alphys Ending89Complete the Neutral Ending with Toriel, Undyne, Mettaton, and Papyrus dead, and a murder level of 12 or higher.

Version Choice

Undertale has several versions to choose from, all with a unique mix of version-exclusive glitches and features. This TAS uses Undertale v1.001, which is also the preferred version among RTA runners. Another option would be to use v1.05, which disallows certain glitches due to a less responsive input system but has Japanese text. Although the reduction in glitches causes significant time loss, the Japanese text save much of that time back. Finally, there’s v1.00, which has a unique major glitch that allows the player to get the punch card on the Genocide route. This may or may not lead to a faster run but it would have to be fully TASed to compare accurately. In order to align with the preferred version among RTA runners, we chose to use v1.001. Undertale is available on several different platforms, but the Linux version of 1.001 is conveniently already the fastest platform and so that’s what was used.

Collaboration Tools

The original plan for this All Major Endings TAS was to leave it as several individual movie files, one for each ending, rather than attempt to make a single movie file. The reasoning behind this was that we’d be able to edit together the encodings themselves. However, thanks to some crucial research into the RNG algorithms by colinator27, the idea of stitching together the endings into one single movie file became more realistic. This ended up being a relatively complex issue to solve, but the end result turned out well and it also led to the creation of the UT-LTM-Merge-Tool, a toolset that can be used to manipulate different RNG seeds, including stitching together movie files into one continuous file.

Undertale’s RNG

(Note: This section only applies to Undertale v1.001 on Linux. There are version differences not covered here.)
Undertale uses a random number generator that’s seeded from the monotonic clock. The seeding process doesn’t happen automatically, but rather it happens whenever the functions randomize() or randomise() are called in code. When this function is called, the game reads the monotonic clock time to microsecond precision and converts this to a 32-bit integer representing the RNG seed. Thus, there are 4,294,967,295 possible RNG seeds.
However, the breakthrough happened when colinator27 was researching how the game converts these RNG seeds to the 512-bit RNG state, which is what’s actually used in the random number generator itself. He found that due to the algorithm used to convert seeds to states, many of the seeds map to exactly the same state. The result is that these RNG seeds map to a total of 65,536 unique initial RNG states, a much more reasonable number.
Thus, as long as we match up each call of randomize() with a microsecond on the monotonic clock that generates the same RNG state as the original, the RNG will sync. This is what allows us to sync the RNG of each segment when stitching it together.

Implementation in libTAS

In order to manipulate the initial RNG state for the different segments, we needed to manipulate the monotonic clock time at the time when RNG is called. Because the monotonic clock is by definition not intended to be changed, this must be accomplished by delaying the start time of each segment. This is accomplished through the use of libTAS’s variable FPS functionality: by precisely setting one frame’s FPS value, we’re able to add a microseconds-precise delay in between closing one game instance and opening the next game instance. Thus, the first step was to prepare each segmented input file with variable FPS values corresponding to the desired start time of the next game instance. This is more complicated than it sounds, however, because we first need to determine what the original RNG state was in order to know how to reproduce it, and we also need to determine the exact microsecond that the randomize() function is called if the segments were concatenated with no delay in between. Once these are determined, the delay needed to sync the RNG state is calculated and converted into a variable FPS value.
This process is performed through the use of the UT-LTM-Merge-Tool created specifically for this TAS. The tool also performs various cleanup actions, such as adding together the rerecord counts of the individual segments. Although the tool handles much of the process, there’s still a good deal of effort needed for each stitching as part of the process involves replaying the TAS using a game mod to gather some of the necessary data, and executing seed searches due to the randomize() function being run at a different time than the reported Elapsed Time in libTAS.
The end result of this process is one continuous movie file for the entire run, with all of the RNG used in the original segments entirely intact. Without stitching together segments, the only other way this could have been accomplished would have been by working on segments in order, preventing the collaborative workflow used in this TAS.

Tricks Used

For additional definitions of various strat names used in Undertale speedrunning, see the USRC Dictionary by Jean Poilu.

Wall Humping

Wall humping is a movement technique where the player oscillates between facing up and facing down each frame. This technique is performed by holding Up and Down simultaneously while against the bottom side of a wall. This can be useful in certain circumstances such as when you are moving left or right but need to be facing up or down. In rooms where the player is in contact with and between two horizontal walls, this technique will cause the player to move at double speed, as the two walls both move the player simultaneously.
Menu buffering is a movement technique where the player opens the menu and presses an arrow key on the same frame. This type of movement does not count as a step for random encounters and is not considered movement by blue lasers. Although menu buffering causes the player to move at half speed (alternating between the menu buffer and closing the menu), this technique can save time in certain circumstances where additional steps are not desirable.

Wallclips

Wallclips refer to the ability of the player to clip into vertical walls by one movement pixel when entered from the top or bottom. This can save time in some circumstances due to shortening the distance traveled and can allow movement after certain events one frame earlier than normal. Note that it is not possible to menu buffer while wallclipping.

Punch Card Exploit (PCE)

Although the punch card can be used to trigger many different exploits, PCE refers specifically to a glitch where the player menu buffers onto a cutscene trigger, uses the punch card from the item menu, then closes the punch card to regain movement in the cutscene. The reason this glitch happens is because there is one frame between using the punch card from the item menu and the punch card opening where the player has full control, and it is during this one frame that the cutscene trigger is activated. Because most cutscenes only lock movement at the very start of the cutscene, the punch card's own ability to unlock movement after being closed is enough to skip the entire cutscene. There is a variation of PCE called PCE slide where instead of menu buffering onto the cutscene trigger, the player uses the one frame of full control to walk onto the cutscene trigger, which also triggers the cutscene.

Wrong Warp (WW)

In Undertale speedrunning, wrong warping refers to entering a room and being placed at the default location in that room rather than the door the player entered from. When the player touches a room transition, the variable global.interact is normally set to 3. Then once the player reaches the next room, the game checks if global.interact is set to 3 and if it is, the game runs the code that places the player at the appropriate door marker. However, if global.interact is not 3, the player is not moved from the default location in the room. This default location is manually assigned per room by the game developer and is often closer to the middle of the room than the door marker is. There are several methods of triggering a wrong warp, all of which achieve the same result: setting global.interact to 0 (the value for full player control) while transitioning to the next room.

Text Storage/Overflow

Text storage (also called overflow) is a type of glitch where the player regains movement while text is on the screen. This can be useful in different ways, as some text can be used to set global.interact to 0 upon closing the textbox. Sometimes text storage saves time simply by being able to mash the text while moving. When text storage is used to wrong warp, this is known as an overflow wrong warp (OWW).

Choicer Overflow

Choicer overflow in the context of Undertale speedrunning refers to a glitch that involves using multiple choicers at once to advance text beyond its normal limits. Choicers are types of textboxes that give the player a choice between two different options. These choicers use a variable called global.msc. When a textbox is created, the object creating the textbox assigns a value to global.msc, which is then used to lookup which set of text to display. Then if the set of text includes a choicer, global.msc is incremented by 1, which normally contains the post-choicer text, if any, as well as potentially other code that accompanies the selected choice. If another choicer is then activated, the value global.msc is incremented a second time and the corresponding set of text is displayed. This can be done repeatedly to advance global.msc to a particular value, as long as there are enough choicers available.

Punch Card Advance (PCA)

Punch Card Advance is a glitch where the punch card is opened and closed while text is on the screen. When this is done, the one frame of full player control that normally happens immediately after using the punch card is delayed until after the text is closed. The reason this happens is because this is how text created from the menu returns control to the player after the text is closed. PCA can be used to allow text that normally doesn't return control to the player to do so. There is a variant of PCA called Special PCA (SPCA) where text that has been PCA'd is left open while transitioning to another room. When this is done, the frame when control is returned to the player happens in the next room, which can allow certain cutscenes to be skipped if the cutscenes lock movement at the start of the room. Text created from the menu can also enable SPCA even if this text is opened during the room transition fadeout.

Persistence Glitch

The persistence glitch is the newest type of glitch in Undertale speedrunning. Rooms have a property called persistence, which saves the state of each object in the room. This property is set when entering a battle and then unset once the player returns. However, by leaving the room on the frame before a battle starts, the room persistence is never unset. This glitch is used in the mad dummy fight to trigger the post-battle cutscene without finishing the fight.

RNG Manipulation

Undertale's RNG is determined by a seed that advances each time RNG is called. By calling RNG a different number of times, different outcomes can be achieved. Text calls RNG twice per character per frame and so changing how many frames text is displayed is the most common method of RNG manipulation. RNG is manipulated for various reasons such as getting particular attacks and determining which step count random encounters will occur on. One thing to note is that the function randomize() is called upon loading into the game and this function sets the RNG seed based on the system time. However, after this initial seed, RNG is no longer affected by system time until the save file is reloaded or the game is restarted.

Run Comments

Papyrus Ending

We start the run with the Papyrus Ending, where we follow the Genocide route up to Snowdin. This allows us to reload later and continue the Genocide route, which keeps us from having to repeat Ruins or Snowdin. Once we reach Snowdin, we intentionally don’t fulfill the kill count, and then we save the game and spare Papyrus.
Because we aborted the Genocide route by sparing Papyrus, we now have access to the Punch Card. We proceed through Waterfall with the Punch Card, performing Early Early Burnt Pan (EEBP) along the way and using the Burnt Pan to kill Undyne. Then, we make our way through Hotland, kill Mettaton, and kill Asgore before fighting Flowey.
Because the save data never gets removed between resets, this is the only ending in which we actually need to defeat Flowey. However, in order for the ending to count in the save data, we must wait until the title card appears before closing the game. This will be done a few additional times to shorten some dialogue, and then the remaining Neutral endings will end upon touching the door.

Alphys Ending

Alphys Ending is commonly referred to as aborted genocide, because this ending involves completing the Genocide route through Waterfall but then aborting the route in Hotland. We start by reloading in Snowdin, completing the kill count, then killing Papyrus.
The Punch Card is not available because we’re on the Genocide route, so we proceed through Waterfall, completing the kill count and killing Undyne the Undying with the Ballet Shoes. It’s not possible to save an extra turn in this fight over the fastest RTA method, so some hits are intentionally weaker to complete the attack pattern quicker.
We proceed through Hotland on the Genocide route up until Core, where we complete some of the kills but save and kill Mettaton before fulfilling the kill count, aborting Genocide. We then kill Asgore to complete the Alphys Ending.

Genocide Ending

We reload to Core and complete the kill count before proceeding to New Home, where we fight Sans. We use the Ballet Shoes in the Sans fight because it’s the weapon with the fastest attack pattern, and then we proceed to Asgore afterwards. Once we select the Erase option, we are considered to have completed the Genocide Ending so we reload the game.

Undyne Ending

We reset to start a new run for the Undyne Ending, and we proceed through the Ruins on a neutral route before betray killing Toriel. We then continue through Snowdin and kill Papyrus as well. Although killing Papyrus is not a requirement of the Undyne Ending, it is a requirement of the Mettaton Ending and so killing Papyrus here minimizes repeated segments.
We pick up the Burnt Pan in Waterfall using EEBP and use it to attack Undyne for a bit before fleeing. We immediately save so that we can return to kill Undyne in the next ending. We then proceed through Hotland, skipping Mettaton and completing the Undyne Ending.

Mettaton Ending

We reload to the beginning of Hotland and turn around to kill Undyne. After this, we proceed through Hotland, skip Mettaton, and save in Judgement Hall before completing the Mettaton Ending.

Dog Ending

Dog Ending requires killing all four area bosses, of which we’ve killed all but Mettaton. So we backtrack from Judgement Hall to Mettaton, where we kill Mettaton and then save in Core before defeating Asgore once again to complete the Dog Ending.

No King Ending

No King Ending is similar to Dog Ending except with at least one extra kill. So we reload to Core, kill one monster, and then kill Asgore to complete this ending.

Family Ending

Family Ending is the start of the final branch, which will end with the True Pacifist Ending. Because of this, we start by following the True Pacifist route, by collecting the Butterscotch Pie and completing the Papyrus date. We continue through the game up to the end of Hotland, where we watch the Alphys elevator cutscene to enable the Undyne’s Letter event and then save in Judgement Hall before defeating Asgore and completing the Family Ending.

Exiled Queen Ending

After reloading, we backtrack to Core and kill 10 monsters to fulfill the requirements for the Exiled Queen Ending, then we defeat Asgore and complete the Exiled Queen Ending.

True Pacifist Ending

We reload once again and backtrack to Undyne’s house, where we complete the Undyne date and are immediately given Undyne’s letter, which we use to start the Alphys date and open up access to the True Lab. After completing this area, we fight Asriel and exit the Underground, closing Toriel’s final textbox to complete the True Pacifist Ending and the All Major Endings speedrun.

Final Comments

Future Optimizations

As mentioned previously, this TAS was created by stitching together individual endings into one movie file. Unfortunately, this added some time onto the run for each stitched segment. This adds up to a total of 4.57 seconds of time loss. Realizing this time save would require redoing the entire TAS as a single movie file from the beginning.
There are most likely some minor optimizations that were either overlooked or newly discovered, including a newly discovered strat where you’re able to move for a frame while overflowing single textboxes and another new strat to allow PCEs of solid triggers during a wallclip.
There aren’t currently any major strats that could be added to this TAS, although there are likely more strats to be discovered in the near future as Undertale has an active speedrunning and technical community that’s always looking to discover new ways to break the game.
Finally, there’s routing. This TAS does the fastest known route for v1.001, but there’s a possibility that an alternate route on v1.00 would be faster. This would have to be fully TASed to know for sure, though, and it might just end up being slower anyway.

Extra Material

Premiere video with live commentary:
Encode with OSD frame count and input display:

Screenshots

Recommended publication screenshot:
(Frame 276349)
Other screenshots:
(Frame 498185)
(Frame 49222)
(Frame 236051)

Special Thanks

Thanks to the following people, all of whom helped in some way, big or small:
  • colinator27
  • I'm an issue
  • willyjwillyj
  • Winter Storm
  • RichConnerGMN
  • benedictk12
  • Jean Poilu
  • Radu
  • Shayy
  • mrlink2k
  • Geo
  • NeoBones
  • Kilaye
Finally, thanks to the entire Undertale speedrunning community for constantly pushing this game to its limits!

CasualPokePlayer: Claiming for judging.
CasualPokePlayer: This movie is a fairly impressive showcase of most of the unique content Undertale provides, presenting interesting routing and optimization challenges. The goal of "All Major Endings" itself makes sense, and with the context of Undertale makes sense for this movie.
There was some consideration of putting this as a "full completion" movie in Standard. However, this ultimately does not make sense, for a few reasons:
  • We currently already have a "full completion" movie in Standard, being "True Pacifist" (i.e., "best ending"). This makes more sense for this game, with it having many different endings and "best ending." We don't really have any precedent for having multiple different kinds of full completion either, with this line of thinking, would this cause this movie to obsolete the True Pacifist movie? I would doubt that'd this movie was submitted with the intent to obsolete any current publication, but rather be its own independent branch.
  • This movie doesn't necessarily have to do the "best ending" per se, as "Soulless Pacifist" is considered valid for completing the "True Pacifist" major ending branch. So, you would end up with a "full completion movie" which could be completed without even doing the "best ending" like the other "full completion" movie.
  • If we want multiple endings in a full completion movie, why stop at major endings? Why not do *all* endings?
  • Or on the other side, why do all these "major endings" when you could potentially just consider the 3 main endings (Neutral, True Pacifist, and Genocide) as "full completion."
  • There is another matter which is specific more to how this run "defines" an ending. The movie effectively defines it as doing the last gameplay action. This ends up having consequences for this movie, primarily for the Genocide branch: you would be able to quit/reopen the game, and this will prevent the game from doing an autosave and thus preventing the typical forced reset of the save file, allowing the previous save file to be reloaded. For the purposes of Standard, this might not be kosher, but for Alternative, this could be considered acceptable.
The feedback on our site seemed to be fairly positive, although somewhat lackluster. Off site feedback seemed to be more plentiful and also very positive. Considering too the variety this run brings, this makes sense, and so this overall seems acceptable for Alternative.
Accepting as a new branch in Alternative.
feos: Pub.
Last Edited by OceanBagel on 1/8/2024 3:07 AM
Page History Latest diff List referrers