Dragon Age: Origins and the Tic Tac Toe Computer AI

Posted by saurookadook on January 24, 2018

I never thought my that my love for video games (specifically role-playing games, or RPGs) would ever help me in my professional life. Hell, I certainly know that my parents certainly thought it was a waste of time. Well Mom and Dad, to our surprise, my experiences playing RPGs helped immensely with building the Computer AI for Ruby Tic Tac Toe project.

However out of all of the RPGs I’ve played (of which I’ve lost count), one in particular stands out: Dragon Age: Origins (DA:O). ) Developed by BioWare, DA:O is a strategy RPG in which you control a party of 3 characters at a time, with various other characters to use at your disposal, the number of which varies depending on plot-related decisions. The aspect of DA:O which helped me the most was the Tactics(CT) gameplay mechanic, which enables the player to set commands, given certain criteria, for each character. For instance, you could set characters to automatically attack enemies in the area with the lowest health, or heal other characters if their health dropped below a certain percentage. As the game offers at least 15 different Tactics slots per character (though the game can be modded to allow even more), BioWare has given the player the power to customize not only their character’s equipment and abilities, but also their behavior in combat to be as specific to any given situation.

The Tactics mechanic (still one of my favorite parts about the game) enables players to eliminate much of the micro-managing which would normally be prevalent in even low-risk encounters, needing to pause the game every few seconds just to give your other characters directions. Tactics are not just useful for eliminating monotony, though; they also help in higher-level fights when any well-handled situation can instantaneously become a frantic struggle for survival (big dragons can be scary…). For me, the reason they are so useful and successful is based on their design: the enabling of prioritized behavior. It wouldn’t make much sense for my healer to be attacking an enemy when my other characters are about to die, would it? And it would be equally nonsensical for my tank (aka, the meat-shield) to be focused on one creature in particular when three or four other creatures are all attacking my healer. Again because of Bioware’s ingenious design, the Tactics mechanic allows the player to essentially program the behavior of each of their characters.

And so I found myself thinking back to my own use of the Tactics mechanic while I was programming the Computer AI for Tic Tac Toe. It wouldn’t make much sense for the AI to block a win when it could win the game in another space, though it should block a possible win for the opposing player if one exists before it would move somewhere else on the board. The concept of priority here is what I found most useful from my time playing DA:O. Though DA:O is a much more complex game with far more variables to manage, the basic priorities remain the same: you program your characters to give you the best chance of winning (ultimately, surviving any given encounter), making abilities which keep the party alive the highest priority, followed by use of abilities to deal as much damage as possible in the least amount of time. So the same is true with Tic Tac Toe: winning is the priority and all of the actions with lesser priority either help stop the other player from winning or force a tie.

Tic Tac Toe is, obviously, a fairly simple game, as there are only so many possible ways for any given game to unfold and winning largely depends on your opponent making a mistake or not being familiar with the general strategy. Despite that, I feel that my experience playing DA:O helped to streamline the coding process, as I knew exactly how to prioritize my code within the AI. Again, who knew that playing video games would come to help me in my professional life?

As an aside, coding the AI for Tic Tac Toe has also given me a newfound appreciation for good AI in video games. There are plenty of bad examples, one of which being in a game I’ve been playing recently, called Sword Art Online: Lost Song (an original story based on the anime, Sword Art Online). Nothing is more frustrating than watching your computer-controlled teammates stand next to you, doing nothing while you’re fighting a boss (and ONLY a boss). Other games like The Witcher 3: Wild Hunt have incredibly intelligent AI, who almost seem to predict your actions exactly and act accordingly. At the moment, I can’t fathom how complex the code for those computer AI must be, but I’m hoping that, as I progress through Flatiron’s curriculum and explore additional coding languages, I may get the chance to work out something similar on my own.