We’re Fucked, Pt. 97 (Fiction)


I must have been thirteen when I was startled awake by my father barging into my bedroom. His brown hair, disheveled and matted with sweat, as well as his beard, sported patches the color of dusty cobwebs. He stopped mid-stride. His gleaming eyes widened in their sunken pits, his wrinkly face scrunched up. His cheeks flushed crimson as he glared at my crotch.

I remembered: an explosion of ecstasy and relief had knocked me unconscious. My inner thighs were coated in dried juice, and my folds still felt puffy from the punishment I had meted upon them with the sticky dildo I was holding.

I sat up with a jolt, horrified that my father was getting an eyeful of my pussy. As I stuttered an apology and scrambled to cover myself, the old man let out a strangled grunt, lunged and struck me square in the face. The whiplash cracked my vertebrae and blanched my vision. An overwhelming pain swelled behind my shattered nose as if I had inhaled icy seawater. I was yanked off the bed onto the wooden floor, where my father delivered blow after blow as if I were a piñata. Darkness was pouring in like oily tar. I must have missed my father’s footsteps leaving the room; I was writhing, sobbing and bleeding when he dropped a damp washcloth on my face.

“Quit whining, little pervert,” he said. “You’re lucky I caught you first.”

In one of the first memories that my defective brain bothered to save, I was sprawled out face down across my mother’s lap as she spanked my bare bottom. She’d smack me so hard that the shock traveled along my spine, and the stinging skin of my ass cheeks broke into droplets of blood that dribbled down my thighs. I squealed, I pleaded for forgiveness. My tears seeped into the fibers of the living room carpet. I begged to know what I had done wrong to deserve this pain, but my mother repeated, “This is the only way to get back on track for a better life.” After her wrath subsided, while she caught her breath and my ass burned bright red, she would squeeze me against her chest. Her cheap perfume cloyed my nostrils. Her fingers trailed along the sensitive skin of my back to knead my buttocks. She whispered, “I know you’ll make me proud someday, my baby starfish.” I wanted to ask when would that day come, when would I be worthy of a loving embrace.

Ages of this world have come and gone. Try infinite loneliness. I remember floating inside the amniotic sac, inside the womb, as an embryo. Tiny hands grasped at the umbilical cord. Warmth encompassed me in a soft embrace, a protective fluid that buffered me from the horrors outside, that flowed down my nostrils and caressed my tongue with its velvety texture. The baby starfish swam inside its mother’s tummy, and when it heard music, it waved its tube feet. I was waiting for something, or someone. Perhaps it remains within me, that insatiable longing.

I have been shot, stabbed, strangled, drowned, electrocuted, exsanguinated, eviscerated, crushed by boulders, frozen solid, blown apart, thrown off a roof, run over by a truck, trampled, hanged, crucified, burned at the stake, boiled in oil, decapitated by guillotine, impaled on a pike, poisoned with cyanide, flayed alive, torn to shreds, eaten and excreted. Yet, I still operate a flesh-and-bone mecha from the command center housed within my skull. A couple of years ago this body passed the vertex of its parabola from growth to decay, and began the accelerating descent that one day, turned into an arthritic hag, a withered husk covered in sores and boils, will land me in a grave, to linger as bones with flesh clinging to them while I join the cosmic reservoir of carbon and silicon and phosphorus and hydrogen in the great big mess known as Earth.

My unsteady legs want to drop me like dead weight. Those intrusive daydreams had blocked off the stream of colors and sounds and crazy that reality dishes out, in which I’ve spent a lifetime wading neck-deep, but I feel it rushing back in through my pores, flooding me. I hunch over and hide my face. Some tectonic shift has shaken my mindscape, plunging the plate of my sanity into the ocean, locking it a thousand kilometers below sea level, down into the pitch-black, icy trenches of despair. My brain craves to squander what remains of its energy running in an idle loop, turning over and over on itself.

“What the fuck is wrong with you now?” the blob spits out.

My chest tightens. No, I can’t bear to look up at that rotten blancmange sprinkled with eyeballs. If I’m doomed to receive the visits of sentient monsters from some interdimensional abyss, why couldn’t I have met a half-woman, half-octopus who used her tentacles to draw intricate artwork on the seabed? Or a man with the wings of a bat, who spent his nights soaring through the sky, seeking out those in need of an angelic guide. Or a half-woman, half-serpent who became a healer, milking her knowledge of venom and antidotes to save lives. At least a witch with a vagina of glittering gold. Instead, a black-humored goo-pile, like the foul sludge from my mother’s bowels, got its shit together and came stumbling through a dimensional rift to annoy me.

I’d love to tell my former co-worker to piss off, but my voice would push against the lump in my throat. An insurgent faction within my mind is attempting a coup d’état to usurp control over my nervous system. I turn away from the contaminated wall, then I stagger past the wastebasket where my vomit must have cooled. With my trembling hands, I pull Jacqueline’s chair and I slump onto it, making the chair squeak and skitter closer to the window.

As cold pellets of water splash against the glass, the office lights are contouring in white those raindrops that streak down in zigzag over the black canvas of this night. Amidst the pitter-patter of rain, the wind howls and thunder grumbles. Toss thy dildo at the reflection in that cracked mirror.

The outside world awaits me in a superposition. In how many of those probabilities has everything already come to an end?

I close my eyes. I take measured breaths of fetid air to steady my racing heart. The cacophony of noise and colors fades into the background, and my mind starts painting on the void. A cabin, its cedar boards grown mossy and bowed with age, its shingles weather-beaten by decades of harsh winds and rainstorms, its wooden shutters hanging crooked on their rusty hinges, stands on a plot of land by Crystal Lake, surrounded with snow-laden fir trees. I’m sitting next to my father on a bed covered in blood and hair and bits of bone. As usual, the old man is naked. He’s combing the hairs of his forearm with his fingernails.

I clench my eyes tighter. In the vast, dark, cold ocean of my mind, an intricate tapestry blooms as it unravels, stretching to infinity. Galaxies shine like jewels, glued to trillions of purplish-pink, bioluminescent threads woven in a cosmic web.

I’m an infinitesimal starfish suspended on a silken thread over an abyss. My lips have been sewn shut with tiny sutures by my surgeon goddess. As Her glowing, blood-red gaze penetrates my consciousness, I expand through the vortex of Her web.

A silver-white flash dazzles me. I’m melting. My cells burst and ooze with viscous juices, and my atoms break down into electrons, protons and neutrons, until only my ghost remains. A phantom, a specter in the void, a lost soul drifting through the endless expanse of space alone.


Author’s note: today’s songs are “Oh Sister” by Neutral Milk Hotel, “Made-up Dreams” by Built to Spill, “How Does it Feel” by Roy Harper, “Always This Way” by Laura Marling, “Fallin’ Rain” by Link Wray, and “It’s Happening Again” by Agnes Obel.

I keep a playlist with all the songs mentioned throughout the novel. A hundred and forty-six songs so far. Check them out.

You would love to hear Leire narrating this troublesome chapter, wouldn’t you? Maybe you would not, but regardless, here’s the link to the audiochapter.

AI news #2


For me, the holy grail of gaming involves characters driven by AI that could pass the Turing test, and who could trigger changes in the game world according to your unscripted conversations with them and/or their own decisions.

The first half of that dream is already being developed for different games thanks to the astonishing AI of GPT-4. Check out the progress done for the undying Skyrim (its VR version no less, for added immersion):

These conversations are character-appropriate, so the video is much more impressive if, like me, you’ve known all these characters for about twelve years. The voice generation can be plugged to Eleven Labs’ API for more realistic results, although that would burn plenty of the monthly allowed credits.

Here’s another video of this technology in Skyrim, now using Eleven Labs’ voices:

I love how Ysolda admits to being a drug dealer right in the middle of Whiterun’s market. And what’s with that town guard abusing metaphors?

Here’s more or less the same kind of stuff but with a human being acting like a bastard toward Fallout: New Vegas characters:

The following video is an overview of this technology applied to Skyrim (and other games in general), along with its possibilities and limitations.

We’re Fucked, Pt. 96: AI-generated audiochapter

Don’t you love AI-generated voices that have no choice but to act out your scenes whenever you want? Check out the audiochapter I produced for chapter 96:

Cast

  • Leire: Vex, thief extraordinaire from back in Skyrim times
  • Blob: Lizard men from Cyrodiil
  • Spike: Travis Miles, that radio guy from Fallout 4 (sorry, Spike)

I have produced audiochapters for this entire sequence so far. A total of an hour, thirty-three minutes and nine seconds. Like a whole movie! Check them out.

We’re Fucked, Pt. 96 (Fiction)


I’m thrust back to that October night in my former home, a madhouse of lurking shadows. Spellbound, I’m staring at the shabby, demon-spawned horse that stood on his hind legs in front of my busted living room window. His mangy coat, crisscrossed by scars, reeked of rot. His brain and nervous system must have been atrophied, maybe vestigial. He had headbutted the windowpane, so his forelock was matted with blood that flowed down his forehead, between his bulging eyes, which were black as midnight oceans, and along the long slope of his face. Through his puffing, the gaping holes of his nostrils blew drops and strings of blood, splattering the shards of glass strewn on the floor. A foul green pus oozed from the jagged wound where his missing genitals ought to be. The horse opened his jaws wide, exposing dagger-sharp teeth, and let out a mournful bray.

Alberto the blob shakes, making his dozens of eyeballs swing and jostle in their gooey sockets.

“Poor Spike, he was unprepared to handle a lunatic like you, and too eager to help if that meant protecting his pals. I never knew him as well as the professor did, but he always struck me as a good guy, the kind of pushover that could irritate you with the lengths he went to accommodate others. He didn’t deserve any of this shit, and now he’s lost to wander madly for eternity.”

My mind is going numb. I avert my gaze from the malevolent glop and his dozens of eyeballs, which are focused, laserlike, on my hunched self. I fear that if the blob blames me again for that horse’s mental collapse, I may break down in tears.

“Wh-why a horse?”

“Why not?” the blob croaks, his voice a cacophony of mucus and slime. “If you are forced to slough off your human form, you may as well become a horse. I’d rather be a majestic animal capable of trampling people to death.”

“That’s a horsey way to put it. Nobody would give a damn if you stepped on your own excrement, and horses care more about their hooves than their souls.”

The blob snickers.

“Do you hold a grudge against equines?”

“Not at all, even though a stallion once pinned my mother to the ground with his steaming member while the rest of the herd feasted on her entrails. Horses may lack empathy and compassion, but they know how to survive in this fucked-up world. They are also a key component in the food chain. However, do I hold a grudge against deformed and putrid horses? I should have despised them on principle, but Spike held a special place in my heart. Anyway, you know what I meant: why a horse instead of a giraffe, or a caribou?”

“The professor suggested that it depended on the person’s self-image. What we truly feel or believe about ourselves, beyond conscious recognition, becomes flesh. Our current forms incorporate elements of decay and suffering because we are always aware that our efforts will be curtailed by death, as much as we’d love to forget it, or deceive ourselves.”

I rub my chin and squint.

“Spike didn’t have a dick. What does that mean?”

“It means he couldn’t get himself off.” He chuckles. “Was it so important to you for his horse form to be capable of ejaculating?”

I fold my arms, annoyed at the blob’s frivolous answer.

“I’d say so, yes. Whenever I caught a glimpse of that jagged scar down south, a chill ran down my spine. Besides, nobody should deny any mammal their primary pleasure.”

The blob sweeps his dozens of gazes around the office. When he focuses back on me, an elongating rope of goo breaks from his underside and plops into a puddle.

“Spike showed up deformed and dickless. What did that illuminate about his self-esteem?”

“I see. An unlovable workhorse that wasn’t even built properly to fulfill his role as a slave to the system. So he was a horse for horses’ sake and a horse for his own sake.”

The blob snorts.

“A sad example of human potential, for sure. The guy even avoided using his real name; he referred to himself by some ancient IRC handle. Is that a symptom of profound self-loathing?”

“Perhaps that’s how horses communicate nowadays.”

“Or he believed that he wasn’t worthy of an authentic name.”

“That is plausible. His low self-esteem manifested as a tenebrous desire to lose himself in the abyss of a nameless existence, to exist unnoticed as inconsequential flotsam. Anyway, what is IRC?”

“Have I become obsolete? It’s short for Internet Relay Chat. Late nineties, early two thousands way of communicating for nerds and horny teens.”

“That’s why Spike referred to himself as IRC?”

“No, that’s why he called himself Spike!” His dozens of eyeballs joggle around as they glitter menacingly. “Whatever. Back to the point: these horrid forms are creative incarnations of our self-image. That’s the professor’s working hypothesis. Some days I’m inclined to believe that the universe is playing a joke on us, maybe to highlight the absurdity of our lives. I used to come to such conclusions even when I could rely on skin to contain my oozing insides.”

“Sure, I hate to see your phlegm-like innards leaking out, but of course you’d rather believe that the universe has conspired to torment us all the while.” I gesture towards the slimy infestation, the many-eyed, squishy bag of rotting guts at which I’ve been staring unflinchingly. “Your bizarre form doesn’t speak wonders about you.”

“I suppose not, but do you choose what reality you accept based on how it suits your vanity?”

“I rarely accept reality. And don’t change the subject! This isn’t about the universe, buddy. This is about you, a lonely and disturbed man-slime.”

The blob glugs as it wobbles from side to side, slopping gunk onto the ruined carpet, expelling a gust of putrescent gas that reminds me of rotten cabbage and anus breath.

“Well, my self-image did falter regularly. Even now I feel my gut digesting what remains of that self-esteem. It’s getting all sludgy inside me.”

“I bet.”

“In my youth, I went to see a psychiatrist for my problems. What about you, huh?” he asks in a piqued tone. “Were you ever analyzed, diagnosed and treated by a proverbial horse doctor? ‘Hey, why the long face?'” He laughs insanely. “Because if you want to talk about disturbed minds, you need a shrink far more than I do. Who knows, you may come to shed layers of your own repulsive form.”

“Thanks for the unsolicited advice, but my mental dysfunction can only be cured by a bullet.” I sigh. “It seems that the three of us, collections of fluids and biochemistry that occupy a certain volume in the space-time continuum, are overgrown clusters of germs with a low opinion of ourselves, damaged creatures in need of a hand and a quickie, who grew up as half-person, half-slime in this fucked-up society of one-size-fits-all humanoids. We should have been born to shine as noble steeds.”

I recall a night when I wandered into an old tavern. In a dimly lit, dusty corner, a deformed horse was twisting his elongated neck and torso to accommodate his position atop a worn wooden stool. He was munching on fried chips. The hazy light of a dying bulb highlighted the scars that crisscrossed his once majestic coat. Other patrons were stealing glances at the equine as they traded whispers and hushed theories about the life he must have led before being confined to this hole in the wall, where no self-respecting animal deserved to dwell.

I approached the bar. Despite the horse’s atrophied forelegs, his stench and his dribbling mouth, he possessed a quiet dignity. Melancholy flickered in his bulging black eyes. I recognized a fellow weary soul that sought solace in the embrace of a cold beer, or in my case, a mug of warm milk.

I sat on the stool next to his, and we drank together until the sun awakened from its coma. The horse gazed at the reflections in the dwindling amber liquid of his glass while we talked about life’s inanity, about how little we enjoyed our time as half-people in this world where only whole persons mattered. I have retained a single sentence that the horse uttered from his slobbering muzzle: “Your dreams are wishes you lack the courage to express.”

After I shuffled out of the tavern, a pain ached deep in my chest, as if someone were stabbing my heart with a needle. I miss that broken-down ungulate, my friend, more than words can describe.

Spike suffered like me, like any being that ever existed and will ever exist. Back when he stalked me, I believed that he wanted me to become an accomplice and abettor to his villainous deeds. I had become terribly vigilant of every hurt from which I needed to protect myself; after all, what had my parents achieved except teach me to distrust others? Wary of every bump on the sidewalk and every scrap of litter, of every stranger that crossed my path and every corner I turned, I was afraid to leave my apartment. I pictured savage beasts leaping out of the darkness to strike with claws sharpened by broken bottles. We see in the world a reflection of ourselves.

I kept to myself whenever possible, I hid whenever necessary, and I prevented others from getting too close. I welcomed them believing I was insane, as long as they left me alone. I refused to face in the mirror those tears and scars, and that black ink from the inscriptions of self-hatred. My mind was my only refuge against the all-consuming abyss, the sole weapon against a loneliness that threatened to drown me.

Spike was a vulnerable soul who carried his broken heart around like a primed grenade. He neglected to feed himself, he let his hooves grow long and scratchy as he wasted away, and he killed himself because I’m an unbridled machine of ruination that I can barely steer, destined to hound more and more victims to insanity or suicide.

Can’t I bring everything back like I’ve always done?

A white coat shimmers under a sunny sky, a silky tail lashes around, hooves tread on the sands of time. Show me a beautiful horse. Let that beast look me in the eye and share his name. Tell me he’s proud of what I’ve made out of him.


Author’s note: today’s songs are “A Horse With No Name” by America, “Caribou” by Pixies, “Australia” by The Shins, and “Kim’s Caravan” by Courtney Barnett.

I keep a playlist with all the songs I’ve mentioned throughout this novel. A hundred and forty songs so far. Check them out. I didn’t add “Caribou” because it was already there, but I made a reference to the song.

Are you following the audiochapters I have made for this whole sequence so far? No? Anyway, here’s the latest one.

Interdimensional Prophets (Game Dev) #6


I had finished programming the non-visual part of Team Struggles (a part of the encounter system that involves character traits and psychological dimensions against some performance thresholds) when I faced the fact that the game was loading too damn slow. I admit, I have been a bit overeager demanding more anime photo IDs from Midjourney, and they are completely unoptimized, but still, I figured that this project could load much faster. So I figured the following solutions:

  • Lazy loading. Instead of loading encounter, biome, and photo ID images at once, just the image path is registered. Right before I need to draw a certain image, I check if it has been loaded, and if it hasn’t, I load it. That makes it so that the many images that won’t be seen in a particular testing session won’t need to be loaded at all. This change alone has sped up game loading significantly.
  • Multithreading. This project didn’t feature any multithreading up to this point, as it is a static, 2D strategy game, but the process of loading the various parts (most of them from TOML files) could use some multithreading. My previous experience with this subject involved trying to develop a Dwarf Fortress-like simulation in Python, only to realize that Python isn’t suited for multiprocessing, nor remotely big simulations at all, due to its garbage-collected nature and a core that is locked to a single thread. However, Rust has mature crates that make multiprocessing relatively simple.

I asked GPT-4 to give me an overview of multiprocessing in the Rust programming language. It suggested a combination of the “rayon” and “crossbeam-channel” crates. The process works like this:


let (sender, ecs_receiver) = crossbeam_channel::unbounded();


You declare a sender and a receiver. The sender part will put on a queue the work done from a different thread, and the receiver will remain on the main thread to try to figure out what it can extract from the queue. However, those threads don’t need to disconnect: they are open channels. I assume that you could have a dedicated thread pumping out pathfinding-related calculations back to the main thread.

Spawning a thread is as easy as the following:

       std::thread::spawn(move || {

            load_ecs_threaded(sender);

        });

The “move” order, or whatever you would call it, is tricky. Any information at all that you are sending from the main thread changes its ownership, even if you clone it normally, so you need to use the “Arc” library to clone it in some special way. Not sure how expensive it is.

Anyway, “load_ecs_threaded(sender)” is in this case the function that will run in the spawned thread. The definition and contents are the following:

use crate::{

    gui::image_impl::ImageImpl,

    world::{create_world, ecs::ECS},

};

pub fn load_ecs_threaded(sender: crossbeam_channel::Sender<ECS<ImageImpl>>) {

    sender

        .send(create_world::<ImageImpl, ECS<ImageImpl>>())

        .unwrap();

}

That function merely sends through the sender the results of the “create_world” function, that registers all necessary components with “specs” Entity-Component System.

You won’t be able to check if the spawned threads have done anything unless you are running some sort of loop on the main thread. In this case I’m running the game with the 2D game dev “ggez” crate, which operates a simple, but well-working, game loop. From there, you need to rely on the “receiver” part of the channel to try to receive data:

        if let Ok(ecs) = self.ecs_receiver.try_recv() {

            match self.shared_resources.try_lock() {

                Ok(mut bound_shared_resources) => {

                    bound_shared_resources.set_ecs(ecs);

                    self.progress_text = Text::new(“Loaded Entity-Component System”.to_string());

                }

                Err(error) => return Err(GameError::CustomError(format!(“Couldn’t lock shared resources to set the world instance. Error: {}”,

                error))

                ),

            }

        }

Through the call “ecs_receiver.try_recv()” I will get either an Ok or an Error. An error may just be that the channel is empty because the remote function hasn’t finished working, so we just check Ok. In that case, the thread has finished doing its job. We gather the results (the “ecs” in this case) and store it into our shared_resources as I did previously.

That’s all. You need to be careful, though, because there are some structs that you can’t send through channels. For example, you can’t send the graphical context of “ggez”, meaning that you always need to load images in the main thread. You also can’t send the random number generator through, as it’s explicitly working on a single thread. But I haven’t found any issue sending my game structs.

Now that the game doesn’t seem to freeze on launch, I can focus on implementing the visual aspect of Team Struggles.

Interdimensional Prophets (Game Dev) #5


A couple of entries ago I presented my first version of the encounter screen. As the team of explorers wanders around in the map, the stored encounters will get shuffled, and the first one whose condition gets triggered will present itself. Here’s the somewhat updated screen:

I was checking out the moddability of this game by changing most pictures to manga/anime aesthetics, and I realized that I liked it more this way. With a simple change of directory names, all names and pictures could get swapped to American ones. In any case, this screen presents what encounter has been triggered. The description gives a brief overview of the situation. The rest of the text informs that this encounter, at least the psychological part of it, will test each team member’s self-regulation (which is one of the psychological dimensions, the grouping of a few psychological criteria).

Yes, I know that there’s a lot of black space. Don’t know what to do about that.

Once you click the round button on the lower right, you are shown the results of the psychological test:

A brief text indicates the reason of this psychological test; in this introductory event/encounter to a narrative line called “The Verdant Assembly,” the characters test their self-regulation against the overwhelmingly lush and alien surroundings. For each character, the average value for that psychological dimension gets tested against a series of performance thresholds in the TOML files. The highest threshold they pass, they get that reward (or punishment). In game terms, an Encounter is associated with a series of Outcomes. Here’s how the outcomes for this encounter look like in the raw TOML file:

# Possible placeholders:

#

# {CHARACTER_NAME}

# {CHARACTER_FIRST_NAME}

[[outcomes]]

identifier = 1

outcome_type = “PsychologicalTest”

description = “Overwhelmed by the alien nature of this plant-based world.”

consequences_identifier = 1

[[outcomes]]

identifier = 2

outcome_type = “PsychologicalTest”

description = “{CHARACTER_FIRST_NAME} becomes fascinated by the plant-based entities, leading to increased motivation and a desire to learn from them.”

consequences_identifier = 2

They are self-explanatory. The most important part is that they link to another store of game entities, the Consequences. I intended to unify the concept of game consequences to a single block of game logic that could be applied to psychological tests and, in the future, to team struggles. The TOML file of related consequences is the following:

[[consequences]]

identifier = 1

illness_identifiers = []

injury_identifiers = []

mental_status_effect_identifiers = [1, 2]

character_trait_identifiers = [1]

add_features_identifiers = []

remove_features_identifiers = []

[[consequences]]

identifier = 2

illness_identifiers = []

injury_identifiers = []

mental_status_effect_identifiers = [3]

character_trait_identifiers = []

add_features_identifiers = []

remove_features_identifiers = []

It is quite inexpressive in its contents because it only links to other entities through their identifiers. However, the outcome of each psychological test and team struggle could have any of the following consequences (or all of them):

  • The team member(s) involved receives one or many illnesses. Illnesses reduce the team member’s health every turn until they run out or are cured.
  • Receives one or many injuries. Instant reduction of health, and the permanent ones even reduce max health.
  • Receives one or many mental statuses (like Confused or Discouraged). They increase or reduce the value for associated psychological criteria.
  • Receives one or many character traits (like Terrified of Octopi, or Botanist). These help or hinder during team struggles.
  • The exploration zone the team is exploring either gains or loses features. For example, if some outcome enrages the natives, the exploration zone could gain the feature Enraged Natives, which would present more combat-oriented encounters in the future.

The consequences are already being applied in the code (which was some heavy amount of code, well-tested thanks to test-driven development), and once I get around to implementing team struggles, their consequences will work seamlessly with the code already written.

In the near future I’m going to focus on making sure that encounters can be blocked by other encounters or even their outcomes, if necessary. For example, if during a team struggle the team screws up bad enough to unleash something dangerous, that should cut off access to more positive branches of that same narrative.

A detail about Rust’s fastidious nature: this is a programming language built upon security and protection against the nastiest bugs from the C++ era. As far as I can tell, in Rust it’s impossible to corrupt some memory allocation that it wasn’t supposed to touch. That forces you to change your approach to programming in quite a few ways, but not because Rust is annoying for no reason, but because in other languages you were doing dangerous things. In my code, I was passing around a SharedGameResources entity that had access to “specs” Entity-Component System (that’s a whole thing; if you are interested, google it) as well as the stores of data loaded from TOML files. At one point I had to borrow that SharedGameResources entity both as immutable (just to read from the stores) as well as mutable (to write the results in the components). That’s impossible. Although it forced me to rewrite some basic architectural code, it illuminated the point that stores of game systems (like the “databases” of mental status effects or of character traits) are separate to the Entity-Component System, which handles a lot of mutation. In the end, Rust’s compiler steers you towards proper architecture, because you simply can’t run your program otherwise.

Asking GPT-4 the real questions

“Do groundhogs actually exist?”

Yes, groundhogs do exist. They are a type of marmot, a large rodent found in North America. Groundhogs are also commonly known as woodchucks, and their scientific name is Marmota monax. They are primarily herbivores and live in burrows, which they dig with their strong claws. Groundhogs are often associated with the North American holiday Groundhog Day, which takes place on February 2nd each year. On this day, it is said that if a groundhog emerges from its burrow and sees its shadow, there will be six more weeks of winter; if it does not see its shadow, an early spring is predicted.

“Is it true that groundhogs cause someone to be trapped in a loop that repeats a single day?”

The idea of a groundhog causing someone to be trapped in a time loop that repeats a single day is not true in reality. This concept comes from the 1993 movie “Groundhog Day” starring Bill Murray. In the film, the main character, a weatherman named Phil Connors, gets trapped in a time loop that causes him to relive February 2nd (Groundhog Day) repeatedly. The movie is a work of fiction and should not be taken as an accurate representation of the abilities or effects of groundhogs in real life.

Interdimensional Prophets (Game Dev) #4


As I was writing unit tests for a perilous, convoluted part of the game logic, which I wanted to lock in place as I moved forward, I realized that to test one relatively small part of the code, I would need to create both World, the main entity of the Entity-Component System “specs”, as well as Image, which is tied to the Context of the 2D game dev “ggez” crate. World is heavy by itself to fire up for a simple unit test, but Images themselves may not even be feasible, as they are glued to the graphical context (no graphics should run during unit tests), and they are tied to a single thread, while the unit tests run in all CPUs.

Therefore, I came to the dreaded conclusion: I needed to refactor their entire code into traits (interfaces). Traits are contracts that encapsulate a behavior without implementing anything. If you program to traits (interfaces) instead of to classes, you are working with future, potentially unimplemented structures whose details are irrelevant to you or the compiler, because they are only forced to fulfill a contract (the trait/interface). It’s like telling an animal to say something; a dog would bark, a cat would meow, but both have fulfilled the contract of “talking,” which is apparently all you cared about.

It just happens that traits in Rust involve generics, and generics in Rust are unholy. Due to Rust’s welcome but tough borrowing rules and lifetime whatevers, Refactoring any behavior to traits involves dealing with bizarre generic declarations, and worse yet, nearly incomprehensible lifetime signatures.

Behold the horror:

pub struct MainState<‘a, T: ImageBehavior + ‘static + std::marker::Send + std::marker::Sync + Clone, U: WorldBehavior<T>> {

    active_stage: Option<GameStage>,

    base_state: BaseState<‘a, T, U>,

    expedition_state: ExpeditionState<‘a, T, U>,

    encounter_state: EncounterState<‘a, T, U>,

    shared_game_logic: Arc<Mutex<SharedGameLogic>>,

}

That’s the definition of MainState, the head honcho of the state machine that figures out which other stage needs to update, or draw on the screen. It declares that it’s somehow involved, to start, with an ImageBehavior contract. Every image throughout the program, except in the launcher, is now unaware of what type of structure it’s actually dealing with, except that it fulfills the contract of being static (I assume images are fixed in memory or something), they Send and Sync for multithreading, and can be Cloned. That’s the hardest one. Then we have WorldBehavior, which abstracts away the entirety of the “specs” Entity-Component System into a wrapped class. The resulting contract for WorldBehavior, if I may say so myself, is a thing of beauty:

pub trait WorldBehavior<T: ImageBehavior + std::marker::Sync + std::marker::Send + Clone> {

    fn new(world: World) -> Self;

    fn join_coordinates_and_tile_biomes(&self) -> Vec<((i32, i32), TileBiome)>;

    fn retrieve_player_coordinates(&self) -> Option<(i32, i32)>;

    fn retrieve_biome_at_player_position(&self) -> Option<Biome>;

    fn retrieve_unique_character_traits_of_team_members(&self)

        -> HashSet<CharacterTraitIdentifier>;

    fn count_team_members(&self) -> u32;

    fn calculate_average_mental_strain_of_team(&self) -> f32;

    fn calculate_average_health_of_team(&self) -> f32;

    fn set_player_position(&mut self, x: i32, y: i32);

    fn retrieve_player_entity(&self) -> Entity;

    fn retrieve_name_of_entity(&self, entity: Entity) -> Name;

    fn retrieve_psychological_profile_of_entity(&self, entity: Entity) -> PsychologicalProfile;

    fn retrieve_health_of_entity(&self, entity: Entity) -> CharacterHealth;

    fn retrieve_team_members(&self) -> Vec<Entity>;

    fn retrieve_team_members_except_player(&self) -> Vec<Entity>;

    fn retrieve_photo_id_of_entity(&self, entity: Entity) -> PhotoId<T>;

    fn move_direction(&mut self, direction: Direction);

    fn create_entity(&mut self) -> EntityBuilder<‘_>;

}

With that contract in place, there’s no more need to deal with “specs” way of working. You want to retrieve the player entity? Call “retrieve_player_entity”. Do you want a calculation of the average mental strain of the entire team? Call “calculate_average_mental_strain_of_team”. Of course, the contract can be developed further as more information or calculations need to be gathered.

I’m at ease now that I have managed to refactor those two unit test blockers into behaviors, but it took hours, and if it weren’t for the indefatigable help of GPT-4, I wouldn’t have been able to do it. But thankfully there shouldn’t be any major obstacles to unit test every part of the code now, which should speed up development significantly.

A boring entry compared with the three previous ones, perhaps, but programming is a fight against entropy: the further you build your system, the harder it becomes to change. You have to stop every few days (if not once a day) to make sure that some part of the code isn’t rotting already.

Interdimensional Prophets (Game Dev) #3


The core loop of this game/experiment of mine consists of the encounter system. As the team of explorers (consisting of four members for balancing reasons, like in Arkham Horror LCG) ventures through strange new worlds, they will face encounters (psychological tests, team struggles) in the following circumstances: either the player ends the turn deliberately, or he/she moves the team to a different tile. That will trigger the code to shuffle the potentially very, very large list of encounters loaded from a TOML file, and then a complex function will determine which will be the encounter that the team of explorers will face based on numerous conditions.

The following is an example encounter from the TOML file, that gets loaded to the game on start.

encounters.toml

[[encounters]]

identifier = 1

title = “A New World”

image_path = “/resources/encounters/1.png”

description = “We have made it. Nobody believed we would manage to create a portal to a multiverse, but here we are, in this strange new world. I take a deep breath as I gaze at the field of grass.”

duration_in_turns = 1

encounter_condition = 1

psychological_test_identifier = 1

[[encounter_conditions]]

identifier = 1

requirements_biome_identifiers = [1]

requirements_feature_identifiers = [

    { AnyRequired = [] },

    { AllRequired = [] },

    { AnyExcluded = [] },

]

requirements_encounter_identifiers = [

    { AnyPreviousEncounter = [] },

    { AllPreviousEncounters = [] },

    { AnyExcludedEncounter = [] },

]

requirements_trait_identifiers = [

    { AnyRequired = [] },

    { AllRequired = [] },

    { AnyExcluded = [] },

]

team_size_requirements = [

    { MinimumTeamSize = 1 },

    { MaximumTeamSize = 6 },

]

team_overall_mental_health_requirements = [

    { MinimumTeamOverallMentalHealth = 0.0 },

    { MaximumTeamOverallMentalHealth = 100.0 },

]

team_overall_health_requirements = [

    { MinimumTeamOverallHealth = 0.0 },

    { MaximumTeamOverallHealth = 100.0 },

]

time_spent_in_alternate_earth_requirements = [

    { MinimumTimeSpentInAlternateEarth = 0 },

    { MaximumTimeSpentInAlternateEarth = 10 },

]

Each encounter is, so far, associated with a psychological test, but soon enough they will be associated with a team struggle as well. The most important part of an encounter is the conditions for it to trigger, which can be the following:

  • The current biome is any of the required (obligatory: all encounters should be attached to at least one biome).
  • The features associated with this exploration zone (ex. NativeInhabitants, Irradiated) are compatible with the any/all/excluded specifications.
  • The list of previous encounters is compatible with the any/all/excluded specifications. This should allow for story-like threads of narrative that depend on previous “chapters” having been passed.
  • The combined list of character traits (from all team members) is compatible with the any/all/required specifications.
  • The team size should be between the set values, if any.
  • The team’s overall mental health should be between the set values, if any.
  • The team’s overall health should be between the set values, if any.
  • The time spent wandering in the current exploration zone should be between the set values, if any.

This allows, for example, for encounters with mythical beasts that only inhabit certain biomes, maybe during some lunar condition (which would be a feature), and only when the team of explorers has trackers (which would be a character trait). Also, when the team’s mental health is deteriorating and their overall health is becoming dangerous, encounters about the team stopping to rest and heal could pop up.

When an encounter triggers, the user is presented with the following window:

I’m not an interface man. I need to figure out which background color would be preferable to plain black, but white and such other clear options seem too grating to me. Anyway, the photo on the upper left is the one associated with the encounter. The row of photo IDs under that is the team of explorers, starting with the player. Regarding text, there’s the title, a short description (thankfully you can program text wrapping). A blue text that you can barely distinguish from here announces that there’s a psychological test associated with the encounter, and that it tests the following psychological dimensions: cognitive abilities and interpersonal skills. Then the values of those psychological dimensions are displayed for each team member.

In the lower right you get a reminder of what biome you are currently in (in this case, a temperate grassland). The fancy button to its left is the one to trigger the psychological test. I have already written the code to gather all the results, which will appear under the description of the encounter.

Thank you Midjourney for the effortless AI images. Regarding GPT-4, I make a point of bothering it by presenting my code and asking “this represents an Outcome given [game concept]. Can you offer any suggestions and improvements?” The AI is eager to point out what I’ve done wrong, with no regard to my feelings. As such, it has proven to be an invaluable tool while programming. Also, when I suspect there’s more to squeeze out of a concept (such as psychological tests, team struggles, outcomes, etc.), I ask GPT-4 if it can come up with more features for that concept, and more often than not, it provides very valuable insight.

Anyway, I have been feeling guilty because I’m mainly a writer and I have neglected my novel for a week. I think that for the foreseeable future I will write one day, program the next. Programming is very addictive for the obsessive mind I was born with, as long as you don’t end up in some ditch of which you don’t know how to climb out.

Interdimensional Prophets (Game Dev) #2


Although I had managed to develop the code to load environments (now called exploration zones) from a Lua file, to pick one and then create a map using the biomes that the exploration zone allowed, the process of loading relatively simple data from Lua annoyed me. It seemed way too complex for this day and age, even though GPT-4 wrote most of the code helped me. I asked the AI for preferable alternatives, and it suggested either JSON files or TOML ones. TOML seemed fancier and better somehow (I have already forgotten the reasons), so I have spent some hours going through the somewhat grueling process of destroying the basic code that worked, to improve the system.

Thankfully, deserializing TOML files to Rust instances is trivial thanks to the “serde” crate. In addition, it had worried me that the process of adding a new type of biome or a feature (some aspect of the exploration zones, like bad weather) required me adding a new element to the corresponding enum, which meant that no user of the game (meaning me for the most part) would be able to add new biomes nor features without access to the code. Obviously that’s terrible for modding; the holy grail of modding consists on having every piece of game data exposed to be fondled by the greasy fingers of the users.

Behold the TOML files that now store all the game data for biomes, features of an exploration zone, and the exploration zones themselves (obviously the data itself is made of examples):

biomes.TOML

[[biome]]

identifier = “temperate_grassland”

name = “Temperate Grassland”

description = “A biome characterized by rolling grasslands and few trees.”

[[biome]]

identifier = “sky_islands”

name = “Sky Islands”

description = “A biome consisting of floating islands high in the sky.”

[[biome]]

identifier = “alpine”

name = “Alpine”

description = “A biome consisting of high land and some pines.”

features.TOML

[[features]]

identifier = “haunted”

name = “Haunted”

description = “a supernatural presence, allowing encounters with ghosts.”

[[features]]

identifier = “ancient_ruins”

name = “Ancient Ruins”

description = “contains the remains of an ancient civilization, with hidden treasures and traps.”

[[features]]

identifier = “unstable_geology”

name = “Unstable Geology”

description = “frequent earthquakes and volcanic activity, posing geological hazards for the team.”

[[features]]

identifier = “radioactive”

name = “Radioactive”

description = “high levels of radiation, potentially causing health problems and mutating local flora and fauna.”

exploration_zones.TOML

[[exploration_zones]]

identifier = “zone_1”

name = “Verdant Valley”

description = “A lush valley with dense forests, clear rivers, and abundant wildlife.”

allowed_biomes = [“temperate_forest”, “river”, “temperate_grassland”]

features = [“rich_flora”, “native_inhabitants”]

[[exploration_zones]]

identifier = “zone_2”

name = “Frozen Tundra”

description = “A vast, frozen wasteland with treacherous ice and snow, and sparse vegetation.”

allowed_biomes = [“tundra”, “ice”, “glacier”]

features = [“extreme_cold”, “limited_visibility”]

From now on, as long as the identifier of a biome written in the exploration_zones TOML file matches with an entry in the biomes TOML file, the game will work properly and use that biome (and its image). If not, the game will burn to the ground (in Rust’s terms, it will panic).

Now I will move on the encounter system, which is composed of various steps:

-A very complex determination of whether or not any given encounter will trigger (can depend on certain biomes and/or features and/or previous encounters having been seen and/or the team members having certain traits and/or the team size being between a certain range and/or the team’s average mental health being between a certain range and/or the team’s overall health being between a certain range and/or the time spent exploring being between a certain range. That code is already written and is the most unit tested area of the game so far (thanks to GPT-4).

-If an encounter triggers, then each team member should go through a number of psychological tests. For example, having walking octopi wanting to drink your blood may test their self-regulation and/or coping skills. The outcomes are on a range of thresholds, so worse outcomes should cause worse consequences, and so on. Those will also end up as TOML files.

-After all the psychological tests pass, there should be one or more team tests. The way these tests work, the best one that GPT-4 and I have come up with, is adding beneficial character traits * their individual weight against negative character traits * their weight, and applying outcomes based on a range like in the case of the psych tests.

If that psychological test thing followed by team test reminds you of something, yes, I was inspired by the Arkham Horror LCG, my favorite card game. In that game, before your turn starts, you are forced to deal with some nefarious encounter (it’s always unnerving to see that card coming from the deck) that you have to face with your abilities. The encounter can make you lose sanity and/or health, or who knows what other horrors. Afterwards you can act with your cards, and other players can get involved if you share a location with them. Hence my notion of a round of psychological tests followed by a team test/struggle.

I won’t go through the trouble of creating a anything visual for this encounter system until it works well in the console and is well-tested. The encounter system seems like the toughest nut to crack of this game, and I’m for one excited to face how to implement it.

If you, whoever the hell you are reading this, can come up with some idea for this game, please tell me. If it’s good, I’ll implement it. Otherwise I’ll yell at you and call you stupid.