Minion Academy

Have I mentioned that the nemesis system in Shadow of Mordor was really cool? Because it was. Playing that game made me wander what else could be done with it. For example, I have always been fond of RPG oracles and general random generators for pen and paper RPG games. I am firm believer that every NPC and/or enemy, no matter how minor or unimportant should have a name and a few distinguishing features. A good game master can usually make up such details on the spot, but keeping track of dozens of throw away characters which may or may not die or conversely become important at some point can be difficult. So random generators are GM’s best friend – especially when trying to populate the game world with diverse collection of characters and not just standard “dwarf with brown beard, elf with blond hair” type stand-ins which is what you usually come with when you need to make up a character on the spot.

While there are dozens of random NPC generators, I figured I might as well write my own. It seemed like a fun and quick side project. How would one go about procedurally generating non player characters though?

First and foremost I figured it should be easy to modify and expand. Instead of hard coding values into the generator itself, I figured it should be stored as some sort of a structured list. I went with YAML because unlike many data serialization formats what claim to be “human readable” it actually is. Well, at least for me it is – your opinion may of course vary and it is not like YAML is without a lot of weird quirks. But I basically just needed a simple data format that could be easy to edit by hand, and that could be consumed by my code without doing a lot of parsing. Seeing how in Ruby can slurp a YAML file into an associative array in a single line of code, it was more or less perfect.

Moreover, I wanted my generator not to be “fully” random but rather use weighted probability scores for specific things. For example, it should be relatively rare to see a Rogue wearing a plate armor, but it would be common to see it on Warrior characters. How do you implement that? There is a few ways. For example you could find the discrete cumulative density function (CDF) of your list, generate a random number in the range between 0 and the sum of all weights, do a binary search to find this number… Actually, no. Scratch that. This is a solved problem and there is literally no reason to re-invent it other than as a classroom exercise maybe (or if you are worrying about performance). Instead of spending hours writing and debugging CDF code, we could just grab a gem such as this one and be done with it.

The basic idea was to let me write a weighted list like this in YAML (higher the number, the better likelihood the item gets picked):

race:
    Human     : 6
    Elf       : 6
    Dwarf     : 6
    Orc       : 6
    Goblin    : 5
    Halfling  : 4
    Hobgoblin : 3
    Kobold    : 2
    Ogre      : 2
    Troll     : 1
    
class:
    Fighter  : 4
    Soldier  : 3
    Cleric   : 1
    Bard     : 1
    Diplomat : 2
    Ranger   : 5
    Rogue    : 5
    Sage     : 1
    Scout    : 3
    Warrior  : 6

social:
    Commoner : 5
    Noble    : 2

Then in Ruby I could pull stuff out of it like this:

require 'yaml'
require 'pickup'
 
data = YAML.load_file('stuff.yml')
race = Pickup.new(data['race']).pick(1)
class = Pickup.new(data['class']).pick(1)

This was basically as complex as the code would get. As it is usually the case with this kind of projects the bulk of the work went into actually generating the data files that would yield not only a good deal of variety but also return both mundane and ordinary foot soldiers as well as funky and exceptional fun characters from time to time. It is more of a creative endeavor rather than programming.

What kind of weapons are appropriate for a rogue? What kind of armor should be worn by scouts? What color can Orc eyes be, and would this be any different for goblins? What kind of scale colors are most popular amongst the Kobolds? These were the sort of questions I had to answer while making this tool.

If you follow me on Twitter (as you should) you have probably seen me posting screenshots of the minions I was generating on the console:

This is back when I still had “barbarian” as a class which I later decided against including. Why? Well, to me it seems like every other class (warrior, rogue, bard, cleric, etc..) is something you choose to be. Barbarian, on the other hand is something you are. It is more often than not used to describe a social caste or grouping of people rather than a profession / calling. So I removed it and replaced it with Fighter and Soldier to have 3 solid close combat classes. In my mind warriors fight out of conviction (they have a duty, seek glory, want justice, etc..), fighters do it because they like it (they are the brawler, trouble-maker types that start fights in taverns for shits and giggles) and soldiers do it strictly for money.

Creating plausibly sounding names proved to be a whole separate problem. I knew that when it came to elves and Dwarfs, I could just shamelessly crib from Tolkien if I wanted to because there are billions of good names for both of these races in the Middle Earth lore. But I didn’t just want to have gigantic copy pasted lists. So I opted for something slightly more clever. I grabbed some interesting names, broke them into (usually) two parts, and then randomly recombined them. For example, here is a sample of Orc name table:

Orc:
    given:
        Male:
            prefix:
                grish: 5
                gor: 5
                muz: 5
                maz: 5
                lag: 5
                lat: 5
                lar: 5
                lir: 5
                rad: 5
                shá: 5
                rag: 5
                rat: 5
                urf: 5
                goth: 5
                núr: 5
                nir: 5
                fár: 5

            postfix:
                nákh: 5
                bag: 5
                gash: 5
                gnash: 5
                bash: 5
                mash: 5
                gol: 5
                mol: 5
                duf: 5
                buf: 5
                rúf: 5
                muf: 5
                dúr: 5
                grat: 5
                gnat: 5
                thrak: 5
                lúk: 5
                múk: 5
                mog: 5
                rog: 5

This particular selection can yield names like Grishnákh, Gorbag and Muzgash (all of whom are named characters from Lord of the Rings) as well as dozens more or less plausibly sounding names.

Most races have gendered first names and last names dictated by social status. So for example a noble’s name may include the name of their estate, or name of their father, whereas the names of commoners are typically nicknames or trade profession related. Elves, Hobgoblins and Trolls ended up with gender neutral names just because of how alien they sounded and because I wanted to have at least one group which did not have a concept of gendered names.

Once I had basic data files created, I wrapped it up in a bit nicer interface and started generating minions by dozens. It was interesting just to read their short descriptions and try to imagine how they would look and what their personalities would be. At some point I even noticed emergent little micro-stories popping up every once in a while. For example, here are two randomly generated Orcs I got the other day:

I found it interesting that they were both ambitious and feared losing face. It felt like they were connected somehow. Ragma was a noble born warrior while Mizni one was a commoner and a ranger. Possibly Ragma’s attendant and a guide? They were likely traveling companions: Ragma young, impetus, and irresponsible, but eager to make a name for herself. The older, wiser Mizni was likely appointed by her parents to keep the young warrior in check, and make sure she returns home safely from their adventures. They both driven by their ambition. Ragma wants to prove she can live up to the high standards of heroism set by her parents. Mizni wants to prove her value to the family by taking on a challenge of keeping the wild and irresponsible Ragma in check. You could literally write a short story about them, just based on this relationship.

This is the beauty of randomly generated content: sometimes a short little blurb can strike a chord with you and your imagination will immediately fill in the blanks creating interesting and meaningful relationships and scenarios. I figured it was worth sharing this little thing that I have done with others.

Minion Academy Screenshot

Minion Academy Screenshot

I set it up on Heroku cloud platform, and named it Minion Academy, mainly because I managed to snag that as a URL. So it is now up at minion.academy. When you visit the page you will get five randomly generated NPC’s and you can refresh the page for five new ones. It’s very basic, and still rather rough around the edges. There is still some work I want to do with it.

For example, I want to add more armor choices. Right now it’s basically just cloth, leather, chain or plate. I would like to expand it so that you could have a wide variety of different armor types for each of these categories. You might have also noticed there are no magic user types being generated right now. This is partly by design (I was initially trying to make a minion specific generator which kinda grew to cover all kind of NPC’s) but I’d like to add some wizards and sorcerers at some point.

If you notice a bug, I have the source code on Github so feel free to submit a bug report. As usual, let me know what you think in the comments.

Posted in programming | Leave a comment

Shadow of Mordor

Back in the 90’s I used to play Middle Earth: The Lidless Eye which was a collectible card game about being a Ringwraith. Unlike Magic The Gathering and similar games, MELE was not as much about defeating the opponent, but about being the best minion of the Dark Lord possible. Your mission was to recover ancient artifacts, recruit powerful allies and convince major Middle Earth factions to side with Mordor. Whichever Ringwraith secured more resources won. You could also play against someone with Middle Earth: The Wizards deck, who would be doing the same thing, but for the good guys. The players could only fight directly if their minions visited the same location at the same time (a rare occurrence, and easy to avoid if you did not want a direct confrontation) and instead they would try to thwart each-others efforts by playing environmental hazard cards as the enemy minions traveled.

It was more of a board game with quasi-RPG mechanics, but this was why I loved it. Most of my Friends had Istari based decks, full of Dwarfs, Elves and Hobbit heroes. My deck was full of Orcs, Trolls and evil men and I loved it that way. So did they actually, because it was fun to play these good vs evil games. It felt like there was much more at the stake.

You know what I loved best about that game? That Orcs, Trolls and The Nine fallen kings were given names (not always cannon names mind you, but I did not care). It is a simple thing really: give an entity a name, and it becomes a person. It becomes imbued with life and personality. I could write an entire sitcom worth of stories about Gorbag, Grishnákh and Muzgash – the three plucky Uruk Hai minion-friends who got into all source of trouble all across the Middle Earth.

In Shadow of Mordor I became frenemies with Ronk The Flame Monger, who just wanted to learn how to ride a caragor beast while wearing his absolutely awesome flame hat.

Ronk Flame Monger

Ronk Flame Monger

No, seriously guys, lets take a moment and take in the glory that is Ronk’s hat. As far as I could tell it was unique in my game, and I have never seen it repeated on another Orc captain. I don’t know how it works, or how Ronk prevents his head from being over-heated, but I do think the looks magnificent. He quickly became my favorite and I was overjoyed to help him win duels with other, less fashion conscious Uruks. I loathed having to kill him but the game said I had to. It is a systems thing: in most video games your objective is to bring about a positive change via destructive force. You are always killing enemies, destroying their infrastructure, toppling evil tyrants and etc.. Hardly ever do you get to affect the game world in a positive way by adding something to it – you are almost always a force of destruction and erasure.

Ronk died without ever fulfilling his dream because he had the misfortune of being an Orc leader whose path intersected with half-man half elven wraith assassin and the titular Shadow of Mordor. Oh, you thought that was about Sauron? Nope, that’s you: the protagonist. The silent assassin, ghostly killer, Robert Neville of Mordor but without the “I am legend” epiphany. Your objective in the game is to perpetrate a campaign of terror against the Uruk-Hai natives of Mordor. You use bodies of slain Orc captains to get to their War Chiefs and you use their deaths to draw out and slay the big-boss minions who take their direct orders from the Dark Lord. And when taking Orc lives is not enough your Wraith-half, teaches you how to take over their bodies.

The void that the death of Ronk Flame Monger left in my life was not filled until I met Lûga the Literate One.

Lûga the Literate One

Lûga the Literate One

Perhaps he did not look as cool as Ronk, but his love of literature has won me over. From the moment we crossed swords, I knew this was going to be a long lasting bromance. At that time I had already learned how to “brand” orcs, making them into friendly NPC’s. And so, after defeating Lûga I used my wraith powers to convert him into my own minion. This was really the only way to save his life. If he was not one of “my” Orcs he would continue being an obstacle in my way, and would have to be toppled. We had a good system going: Lûga would challenge another captain to a duel, I would swoop in and either shank his opponent in the back, or brand him. Lûga would take the credit for the victory, quickly rising in the ranks. Soon he became a War Chief and helped me to either brand or topple all the other War Chiefs.

My Minions

My Uruk-Hai Minions

I had a full control of the local Orc society – all of the War Chiefs and captains were branded, and loyal to me. When I heard there was a new captain who rose to power on my turf, I quickly sent Lûga to challenge him. I dodn’t want him dead – I just wanted his eyes to glow blue. As I was branding the plucky upstart, I had a sudden epiphany: I was the new Dark Lord or Mordor. And it felt good. Almost too good. I presume that this is precisely how the Nine Kings fell and became Ringwraiths in the service of Sauron. Because they were offered the same kind of power.

In fact, I realized that perhaps my power was actually more sinister than than theirs. Both the Nine Kings and the game’s antagonists such as The Hammer of Sauron and The Tower ruled by fear and respect. Orcs followed them either because they dared not to refuse their orders, or because they looked up to them as strong leaders. But a disgruntled Uruk-Hai in their armies had options: he could walk away, challenge his superiors, plot revenge. My minions could not do that: my power over them was absolute. I don’t even know what books Lûga liked to read, because I was using him as a tool. He became a weapon in my arsenal without any agency of his own. He was an empty shell, forever bound to my will.

Tûmûg and me did not get along very well.

Tûmûg and me did not get along very well.

The Uruks of Mordor keep human slaves which is one of the many ways the game tries to justify the terrible violence and destruction you unleash upon them. But even though their bodies are bound and broken, the spirits of these slaves are free. As you explore the game world, you can often hear the slaves talk amongst each other: they tell stories filled with hope, they sing songs and sometimes even laugh. Orcs whom I branded can’t do any of that. They just stand there, their eyes glowing with the unearthly wraith energy. What I have done to them is a hundred times worse than what they have been doing to the humans. I have chained not their bodies but their minds. I became a monster: an absolute, irredeemable villain masquerading as a hero of the people. I have fallen lower than anyone in the Tolkien lore, and I did not even have a cursed ring to blame for my moral lapse.

You might be tempted to blame Celebrimbor for this, because it is his power that was used in branding, and he has been guiding your hands throughout the game. But while he is not necessarily a good guy, his ultimate goal was to strike a blow against Sauron, and put things right after his own greed and lust for power destroyed his own kingdom and put all of Middle Earth in peril. At the end of the game, he is ready to move on and leave the mortal realms behind. I thought this was a good thing. Both Celebrimbor and Talion would get their final rest, and all the Uruks who survived their reign of terror would be freed from under their influence. They would go back to doing whatever it is that Orcs do when they are not being lead to war by some dark power. But at the last minute Talion convinces Celebrimbor to stay and continue their partnership – you know, in case of a sequel. And that’s absolutely frightening.

It actually shows how little self-awareness the designers had when they crafted the games mechanics. At the very core, the game is very much an exploration of colonialism. Talion is a “civilized” outsider who finds himself among “barbarians” who he neither understands, nor respects. He sets out to disrupt and neutralize their power by coercing or assassinating their leaders to impose his own cultural and moral values onto those people. Mechanics reinforce this, but the story refuses to acknowledge these dark undertones and instead it pretends to be a heroic power fantasy. It is almost as if the story and the game mechanics were designed by two separate teams who did not communicate with each other – which seems to be a common trend in modern video games.

You can’t divorce game mechanics from the story any more than you can do with visuals and music. All of these parts contribute to the overall player experience, and all of them come together to tell a story. Shadow of Mordor is a great example of a really fun game in which the story and mechanics are at odds with each other. You can identify with Talion as a heroic figure only up until you actually realize the implications of the “branding” mechanic which becomes fairly important in the later game. An apt storyteller would try to capitalize on this, and depict Tallion’s inner struggle. But the hero never actually thinks about what he is doing to the Orcs. He hates them, and considers them inhuman monsters to be used as tools in his campaign against the Dark Lord… But you wanted to represent them as sub-human monsters, then why give them all names, goals, dreams and fears? The answer is obvious if you read the developer interviews. It is mechanics: engineered and designed completely separately from the story.

I want to give the writing team some credit for capturing the essence of Tolkien’s Uruk society, for crafting cool villains and aptly telling the story of Celebrimbor despite having to work against conflicting mechanics. But can I really do that? I mean, they did enough research to do deeply hook their story into Silmarilion lore, but not enough to comment on the Orks as subaltern people critiques of the text? The discussion about colonialism in Tolkien’s writing have been an academic staple for decades now – it’s not like we’re breaking a new ground here.

Perhaps this is a symptom of what I like to call a “professional fan fiction writer syndrome” – which is what happens when you tell a die-hard fan to write an adaptation of their favorite thing. They tend to be too close to the source material to step back and objectively look at the critique of the text, and thus unknowingly amplify the source works biases and problematic themes. So perhaps I could forgive them for being over-eager fans and trying really hard to do Tolkien justice.

But if I’m going to do that, then I also have to mention that their story would be ripe for Tropes vs. Women analysis. There are three female NPC’s in the game: first gets put in the fridge to provide motivation for the protagonist, second is remote controlled by Saruman and the third gets damseled and you literally have to carry her out of an Orc stronghold.

Litrhaiel

There is about 20 minutes of game play between the moment you meet the brave warrior Litrhaiel and the point where she gets super-damseled and you need to carry her to safety.

This is quite sad, especially seeing how that entire rescue mission was not only pointless but annoying from purely mechanical standpoint. It combined all the worst qualities of an escort mission while at the same time forcing you to move at an excruciatingly slow rate. I guess the writers really wanted to have a heroic moment for Talion to remind players he is not just a shadowy assassin and they figured the best way of doing so is to throw a woman under the train.

There is also that thing where your assassination tutorial consists of sneaking up on your wife to give her a surprise snog which is is weird and unsettling for a whole plethora of reasons.

Did I have fun though? Hell yes. Painting the Orc leader-board blue with my Wraith Flame was more satisfying than it had any right to be. The game actually helped me to find a whole new level of appreciation for Frodo and the temptation he must have felt while carrying the ring. I did not even have a ring, and I was having way to much fun being a pseudo-Ringwraith. The Nemesis system is really cool, and I hope that procedural NPC generation really catches on. I’m looking forward to seeing what other games will do with it.

That said, once I have killed or branded all the Orcs on the board, the game lost a little bit of it’s charm. The only thing left for me to do was to hunt for collectibles, do timed trial missions (bleh) or finish up the story. I wish I could have done more with my hordes of minions. All I really wanted was to be able to issue constructive orders. Like, how awesome would it be to order my underlings to free their slaves, to put Uruks to work repairing strongholds or rebuilding villages. If the game suddenly turned from revenge power fantasy into a city building simulator where you get to manage your armies, make sure they are fed, equipped, trained and have to resolve local disputes as an impartial judge, I would not mind at all.

In fact, I kinda wish the whole branding mechanic would not even be there. After all, Orcs follow strong leaders, no? So what if you could simply defeat an Orc leader in a duel and take his place as a leader? What if you could earn loyalty and gratitude of orcs by sparing their lives, helping them win a duel, or rescuing them from a Caragor. Wouldn’t that make more sense? Wouldn’t that remove at least some of the uneasiness that came from enslaving hordes of Uruks and using them as weapons?

Posted in video games | Tagged | 4 Comments

Make Your Web Forms Time Lord Friendly

This was a conversation rolling through my Twitter feed lately: how do we design good web service signup form? One that is unobtrusive, intuitive and inclusive. How many fields do you need? What is the best way to arrange them? What kind of questions are important to ask your users? Turns out that there is a lot of disagreement on this, and a lot of misinformation and false myths floating around.

For example, is this a good sign up form?

Facebook Signup Form

Facebook Signup Form as of Oct 2014.

I would argue that it is not great. In my opinion splitting the users name is absolutely pointless. Even, assuming your service needs to use the legal names of your customers (which 99.9% of web services do not “need” to do, they just choose to do so because of reasons) you really only need a single field. This is not a very popular opinion, and a lot of programmers are very, very defensive of their first name/last name split.

I get it, though. I too was taught the mantra of “always be normalizing” when it comes to a database scheme design. The software engineer in me wants (even needs) to have human identity split into two or more clearly labeled forms so that it can be properly sorted. But, asking for first and last name does not work for everyone. As soon as you normalize this way, you are automatically starting to exclude swaths of users whose names do not conform to the particular pattern you chose.

You probably heard of this little factoid: in some cultures you list your family name first, and your given name last. That alone should give you a pause, and make you re-consider using a two field strategy. Some people think that simply labeling the fields as “given” and “family” instead of “first” and “last” will do the trick. I also saw a developer claiming that his app is going to be primarily used by English speaking Americans so it does not matter. But that’s wrong too, because even in that narrow demographic you are going to have a number of people whose names do not fit into the first/last pattern. You want examples? How about Madonna, Eminem, Pink, Xzibit, Nelly, Sinbad, Rihanna, Kesha, Mr. T, Lady Gaga or “The Artist Formerly Known as Prince”. There is a strong history of performers adopting mononyms or stage names which either become their legal names, or at the very least are more publicly recognizable than their birth names.

The fact that I could rattle a dozen names of the top of my head, all of which belong to prominent and recognizable celebrities is a proof that this practice is very much part of western culture. Mononyms and funky stage names are as American as apple pie. So you can’t really use “culture” to defend the over-normalization of the name field, when your own culture has a large group of very prominent outliers.

People make a lot of assumptions as to how people’s names work, but all of them are false. Yes, all of them. The single, uniform field for name is not just something I pulled out of my ass for the purpose of this article. It is actually the best practice recommended by W3C.

Same goes for sex. Why does Facebook think it is necessary to ask its users what kind of genitals they have? I can see how this could be a valuable data point for a dating service, since people use those specifically to facilitate mutual mashing of genitals together. So it makes sense to let people sort and filter potential future romantic partners based on their sex and gender preferences in addition to other criteria. Facebook however, like most social and anti-social web apps in existence has virtually no business to ask this question.

Don’t even try to sell me on “demographics” and “advertising” argument because it is bullshit, at least with respect to Facebook since they track your behavior and browsing habits anyone. There is nothing your sex tells their advertisers that they could not get from analyzing your posts, likes and social graph interactions. In fact, the tracking data is more valuable and more accurate way to target advertising than an empty data point that designates you as “man” or “woman”.

Also, why is it a strict binary choice? I mean, unless you’re building something like Christian Mingle type service (where religious dogma only allows you to recognize an arbitrarily chosen set of genders and appropriate parings), why would you want to wantonly ignore biology? If you are going to ask this question (and you have no business doing so in the first place), why not ask it the right way?

Is the Facebook form asking for sex, or gender? Because I honestly can’t tell? This is an important question to ask because Facebook has weird “real name” policies that could result in the suspension of your account if their support staff determines you “lied” on this question. So what do you put down biological sex does not match the gender you identify with? What if you don’t identify neither as male nor as female?

I think Twitter does this right:

Twitter Signup Form

Twitter Signup Form as of Oct 2014.

A single field for “full name” and no unnecessary questions about sex and gender. This is how it should be.

My personal rule of thumb for designing web forms: make them Time Lord friendly. Whenever you want to add or normalize a field, think how the protagonist of BBC’s Doctor Who series would fill it out. Your form should allow one to use The Doctor as the single and only personal identifier.

  • The Doctor does not have a first name
  • The Doctor does not have a last name
  • The Doctor does not have a middle name or middle initial
  • The Doctor does not have a set of initials based on name
  • The Doctor is not a given name
  • The Doctor does not have a family name
  • The Doctor does not use a honorific – it’s just The Doctor
  • No, you can not abbreviate Doctor as Dr. or anything else
  • The Doctor does not have a short name or nickname. You address him as Doctor
  • You can’t use Doctor’s date of birth to calculate age because he is a time traveler
  • The Doctor’s age won’t fit in your two-digit age field
  • The Doctor’s does not have a fixed height, eye color, hair color, etc..
  • The Doctor does not have a fixed ethnicity or skin color
  • The Doctor does not have a fixed gender

If you keep these things in mind you can avoid common pitfalls of web form design and build signup forms that are not only intuitive but also maximally inclusive.

Posted in programming | Tagged | 4 Comments