Nerdy creations with numbers, words, sounds, and pixels

Games, Writing

Anima X

Python code - from Anima X, systemic text adventure game by Anton Hoyer

With some 137+ days of development and 28,000 hand-typed lines of Python code, my text adventure game Anima X is one of the biggest projects I ever worked on, be it privately or professionally. While the final product turned out far from perfect, it taught me a lesson in persistence and object-oriented programming.

All begun during the first corona lockdown, when I spun it a bit further and dug up my first short story ever, “Die gebaute Frau” (The Constructed Woman), in which a biologist/hermit clones himself a woman and falls in love with her. It is a terrible read and I scrapped almost everything, most of all the parallel side story with the bandits, keeping only a couple of details, including the five rooms of the apartment. In fact, I decided early on to restrict the entire game to the apartment and making escape the primary goal. Therefore, Anima X is an escape room, if you will, and as a player you find or guess digits for the forgotten main door PIN, bearing resemblance to the board game “Mastermind.”

Final interface of Anima X, played in the Windows Command shell
Final interface of Anima X, played in the Windows Command shell

Classical text adventure games such as “Zork” or “Colossal Cave Adventure” consist of innumerable rooms and require the player to explore outward (and sometimes backward). However, having only five rooms to work with, namely atrium, laboratory, bedroom, freezer, and a corridor connecting all, motivated me very much to get the core loop of walking between rooms running. Another major difference is that classical text adventures require the player to find out and type commands such as “go,” or “take,” or “attack,” whereas I decided on a multiple-choice approach with some hidden options for more meta gameplay. Because honestly, it is a lot faster and nobody has time today to figure out the commands themselves. Especially, since my bland text console game is competing with AAA open world RPGs for attention.

I also wanted the player character and the cloned woman to be seen as some sort of unified entity and therefore decided against leveling or learning skills as the player character. Instead, you level up only the cloned woman. Specially, you increase one of her five base attributes strength, intelligence, confidence, appearance, or frugality (economy) whenever you clone her next iteration, giving you an incentive to embrace her death as something necessary in order to escape.

Yes, the woman can die and will die lots of times, and yes, you can actively partake in her death. In fact, I touched upon a lot of themes that are shunned by the mainstream, including suicide, depression, murder, violence, abuse, incest, necrophilia, cannibalism, drug use, insanity, expletives, sexuality (and mathematics). As the game could be seen as literature, which does not have any age ratings, I wanted to give you maximum freedom in what to do and what to refrain from doing, leaving only your bad conscience and the woman’s revenge as safeguards if you treat her poorly.

Code from Anima X showcasing dynamic sentence building
Code from Anima X showcasing dynamic sentence building

Just like the short story, the game requires a third character, which I named “Machina,” the quasi-sentient machine that can do a multitude of things, but most importantly construct the woman. After I implemented the cloning procedure and a basic system to talk to the woman, making her follow you or checking on her well-being, instead of working on the quest system, I devised more systems for the player to interact with the apartment, for example a shower between laboratory and corridor, numerical PIN consoles for certain doors, sleeping, meditation, looking outside, and playing chess (or at least a spoofed version of chess).

The player character may not have skills to develop, but he does have an energy meter which is depleted during the day or certain body-intensive activities and replenished when he sleeps. To give you an additional incentive not to go full berserk, I also gave the player character an insanity meter which goes up when you do clever or wholesome things, such as watching a sunset, playing chess, or meditating, and goes down when you become violent or irrational. If your insanity is low enough, more and more letters are swapped for “insanity glyphs,” for example “↓↑ⱯΩ♪∞✶☼,” which is quite annoying and therefore should be avoided.

Early version of insanity glyphs, showing the console output for a fully insane player character
Early version of insanity glyphs, showing the console output for a fully insane player character

Side note: I am saying “he” when referring to the player character because the biologist in the short story is male and therefore always was male in my mind when developing the game. However, I took great care to remove all definitive proof of the player character’s masculinity. There even is a small possibility that the woman asks whether your gender is male, female, or non-binary, but your response has no effect on whether the woman loves you or not. The woman, on the other hand is strictly female because I did not think of also making her gender choosable until very late in the development process. So, it would have been too much of an effort to change, not only all the dialogs but down to her very game object, which is named “she.” Go sue me. 😉

The woman also has an energy meter and goes to bed when tired. The main difference is, though, that while the player falls asleep on the spot when too tired, only losing some sanity, the woman can actually die from exhaustion under certain circumstances. As an additional parameter, she possesses an affection meter, which goes up when you are nice to her and down if you are hateful. Additionally, the affection meter is reset to neutral when the woman dies. While she forgets how she felt about you when cloned anew, she does remember your quest progress because anything else would have been too tedious for the player. (I am not saying it cannot be done because it has been done before. For example, in “The Forgotten City,” you have to play the same day looped over and over and always reintroduce yourself again to every character, with some dialogs being abridged for your own sanity.) Besides, from a practical point, the woman is always the same game object, whose state can be set to alive or not alive. Thus, there can never be two women at the same time.

Another fun system to create was “lovemaking,” a minigame whose goal is to make the woman climax by slowly increasing the actions you take. If you are too fast or if she does not like you in the first place, it turns her off. Naturally, I had to endow the woman with another parameter, namely “horniness,” which has a complex interdependency with her affection. The player can also meditate or dream while sleeping, for which the latest dialogs are chopped up and obfuscated with insanity glyphs, sometimes creating avant-garde poems.

Avant-garde poem, automatically generated by the player character while dreaming
Avant-garde poem, automatically generated by the player character while dreaming

The only system I did not design and code myself was the save system, for which my friend David helped me to dump the objects that are derived from the classes apartment, machina, player, woman, and story into a binary file, saving the current state of the game every time you change the room. That can include moving to a different room or literally changing the room by interacting with a trigger, as well as finishing a conversation with the woman.

After I felt comfortable with the systems and the core game loop, I began working on the main story, which first makes you familiarize yourself with the apartment, then lead the woman around, and afterwards find digits for the PIN of the omega-shaped main door, which leads outside the apartment. Not so coincidentally, each digit is assigned to a different room, requiring you to solve puzzles and work together with the woman. The joke is that all the systems you need to find the missing digits are there from the beginning. Therefore, you could theoretically escape without building one single woman or playing any quests. As the PIN is always randomly generated and the door locks you out after three unsuccessful attempts, brute force attacks by blind guessing are not advised, which I hope you realize quickly.

Parallel to the main quests, I wrote a multitude of side quests. Because the game idea was conceived early during the corona pandemic, I started with a quest where the woman becomes sick due to a weak immune system and an unsanitary environment. So, you are asked to develop a vaccine. Due to the systemic nature of the game, you could instead level her strength and always shower before entering or leaving the laboratory. Not to spoil anything, but I wrote quests in which you produce alcohol and have a “party” with the woman, or rather a truth or dare drinking game, yielding several different outcomes between sweet tipsy lovemaking and the woman’s death due to poisoning. Or another quest where you find yourself in a psychedelic, randomly generated maze, traversing from one obstruse room to the next trying to wake up.

Truth or dare drinking game between the player character and the woman
Truth or dare drinking game between the player character and the woman

Aside from the quests, there are myriad detached dialogs and remarks or activities of the woman, always chosen from a huge set of options, which you will never see in their totality even after several playthroughs. The outcomes of all dialogs and quests are determined by various parameters, including your choices, your sanity as well as the woman’s affection, and her base attributes. For example, with a high strength level, she sleeps less, is less prone to disease, and gives you a dressing down if you dare to physically assault her. With a high intelligence level, she is a lot better at repairs, sees through your deceptions, yet is also prone to self-destructive behavior. Is her confidence level high, she gives more insubordinate answers and roams the rooms on her own, making it harder for you to track her down. With a high appearance level, meaning beauty, she becomes cleanlier and narcissistic, yet also reduces your sanity loss. And finally, with a high frugality level, she sleeps less, weighs less, and consumes a lot less nutritious goo, especially during the cloning procedure.

Nutritious goo, or simply “goo,” is pretty much the only resource you need in the game. You have a large contingent at the start and eventually learn to recycle some, but keeping tabs on your goo consumption is necessary as there is in fact one bad ending for when you run out. Speaking of endings, I implemented six others, ranging from happily ever after to being shanked in the neck during the escape if you committed serious offenses against the woman. So, even if you are free in your actions, keep in mind that as the author, I impose certain morals on you.

One rather difficult topic to deal with was suicide. Late during production, I decided to allow the woman to kill herself, most of all to prevent you from holding on to one single iteration of the woman, thereby obstructing your own progress. Even worse: it is not a question of whether she will kill herself, but when. You will notice that when her timer runs out, she will come up to you and begin a dialog about the meaningless of things. Then you have the option to remind her of what her strengths and the positive things in her life are, checking on whether you as a player truly know your cloned woman. Either she understands, postponing her self-murder until much later, or she should better not be left alone afterwards. In any case, the suicide timer improved the pacing of the game a lot. I am aware of how sensitive the topic is, so much that I think others should be more aware, too. Hence, I did my best not to take it lightly and write the dialogs based on what humans tend to say when they are suicidal. If you are easily triggered, please note that the trigger warning at the beginning is not a joke.

I am half-ashamed to admit it, but I am a huge fan of cheat codes and I think that one should always be allowed to cheat in single player games, if it does not hamper but increase the fun. In that regard, it saddens me that few and fewer game developers implement cheat codes in their game as they represent further systems that need to be bug-proofed and play-tested for players to not break the game. Therefore, I also coded a powerful cheat system, which also helped me a lot during development (the way cheats were originally intended). Not only can you adjust parameters such as energy, sanity, affection, or horniness, but also set any quest to an arbitrary stage or even run entire python commands within the framework of the game. Of course, the latter is a major security risk, but as long as the game runs within its own stable version which you downloaded from my page, there is nothing to be afraid of apart from breaking your own playthrough.

One additional step I took to prevent the player from running into game breaking bugs was to code a bot that play-tests the game. Basically, it tries all possible choices randomly, thousands of times, until it eventually escapes the apartment. Once I disabled all console outputs, the bot managed to finish one playthrough in about five seconds. Simple as it was, the bot helped me find at least 40 major bugs because it either caused an exception or got stuck. In any case, I could follow up on where exactly the error happened and even load the faulty save file. Needless to say, by the time it got stuck, the bot usually was 100 % insane and had killed and recycled dozens of women.

Debug bot playing the game to find errors
Debug bot playing the game to find errors

There is one thing I did not do yet: spellcheck the game. I had plans with my good American friend Abram, who is very gifted with languages and especially English, but due to time constraints, I released Anima X before he could take an in-depth look. Besides, just by looking at the code, one would not find all the grammatical mistakes it is capable of. Due to the highly dynamic nature of the dialogs, I could not outsource them to separate text files, like most other games would do to make editing and localization much easier, if not possible. Some of the quests and wordplays could not be translated, so I hope you are fine with C2-level English and the occasional missing word or comma.

Another thing that is left to do: making the game available on multiple platforms. Since I am working on Windows, it was almost effortless to create an executable file. However, as I understand it, macOS is a bit more difficult. And then there are mobile devices. The best option would probably be to let the game run on this website once I patch up all safety risks and figure out where to store the save files. But like so many other things, this does not have the highest priority right now.

In summary, Anima X is a highly systemic text adventure game and ideal for players who enjoy escape rooms. I implemented a ton of quests, details, jokes, Easter eggs, and so many hidden sub-systems and choices that even I forgot half by now because they are not documented anywhere else than in the code itself. However, you need to be patient and a bit lenient because the game is far from perfect. Whenever I play, I encounter new glitches – not necessarily bugs, but mostly the plot becoming unclear because of the order by which the quests are handled. On the upside, every playthrough I had the chance to watch over a friend’s shoulder turned out very different. Therefore, I believe that Anima X has an extremely high replay value. So far, only a few people have played it and even fewer people managed to escape the apartment.

If you are interested in joining those who did escape or simply want to have a good time for a couple of hours, feel free to download the game for Windows:
https://silverfisk.itch.io/anima-x

← Return to “Text Aventure”

← Return to “Games”

2 Comments

  1. Steve

    This game is so well thought through, created with a meticulous level of detail and a very interesting and challenging plot, truly amazing! I enjoyed playing it a lot, thank you for sharing this. The only thing missing is a proper visualisation, maybe you could add this one day? 🙂

  2. Caspar

    Well done for creating this Anton and thanks for sharing with us! Definitely one of the best text adventures I’ve played so far!

Leave a Reply