Book Review: Behavioral Mathematics for Game AI by Dave Mark

Behavioral Mathematics for Game AI Book

Intrinsic Algorithm’s Dave Mark, a fixture at the Game Developer Conference’s AI Summit, is also the author of Behavioral Mathematics for Game AI.

Most game AI literature covers the basics in a general way, such as finite state machines, flocking and steering to control movement, pathfinding algorithms such as Djikstra’s or A*, goal-oriented action planning (or GOAP), and more.

Mark’s book, however, covers a specific topic in great depth: game AI decision-making.

You might have a character that can do interesting things such as hunt, flee, eat, track, alert nearby allies, etc, but if you don’t create a good system that allows that character to make decisions between those behaviors, it may not convince your players that it is intelligent at all.

The goal is to create behavioral algorithms to get computer-controlled agents responding to their environment in believable and sensible ways. To get there involves a journey through the subjects of psychology, decision theory, utilitarian philosophy, and probability and statistics, among others.

Mark was great at walking you through each step of this journey, combining theory with detailed explanations and examples, including code. Sometimes I felt the detailed explanations were a bit too detailed, but at no point did I feel like I was lost.

He never made a leap in logic that left me behind because he was holding my hand at every step of the way. Sometimes I appreciated that hand-holding, especially for the more involved statistics, but there were a couple of times when I found myself getting a bit impatient and wanting to run ahead.

And it is probably partly due to the fact that it’s a long journey. At one point, I realized I was over 300 pages into the book without feeling like I knew how to integrate and apply all of the individual tools I was learning into a cohesive system.

The examples he used to illustrate his point were sometimes bizarrely relatable. I have never tried to create a model of my behavior related to when I decide to replace my older razor blades with newer ones, but Mark did, and I actually found myself nodding with recognition that I do tend to use my last blade in the refill pack for way longer than my other blades.

Other examples demonstrate how his utility-based decision-making system can address problems with past games, such as the strategy game AI that kept sending its attack force towards the most vulnerable target. Savvy players can keep defensive forces outside of city walls, then place them in the city at the last moment and moving units out of a city far away. By doing so, they could keep the AI units moving back and forth, unable to carry out an attack, for as long as they want.

Solving this issue involves giving the AI the ability to have decision momentum by making decisions include all of the relevant information. The AI isn’t just deciding what city to attack. A single decision is what city to move to AND attack, which incorporates the time it takes to travel to a target city. Suddenly, the decision to change course in order to attack a different city is a bit more painful, and so the current target is more likely to be maintained.

I appreciated that he covered the problem of having the AI always making the best decision. While academic researchers might love that result, players are likely to find such AI as unrealistic and, worse, uninteresting. And if there are multiple AI agents that do exactly the same thing simultaneously, it’s even more of a problem. So there’s an entire chapter on ways to ensure that the game AI can be reasonable yet still interesting from one play session to the next.

The book was published in 2009, and so you would think it means that any information you could glean out of it would be obsolete after almost 10 years of advances and progress in the field. And yet, the basic decision-making system that drives behaviors is still relevant.

One of the benefits of reading an older book is seeing the ideas of that book illustrated in front of you in other media.

You can see Mark’s talks with Kevin Dill from GDC 2010 and 2012 in the GDC Vault. Improving AI Decision Modeling through Utility Theory and Embracing the Dark Art of Mathematical Modeling in AI both introduce the use of this utility-based system in games.

In 2013, Mark’s portion of the panel Architecture Tricks: Managing Behaviors in Time, Space, and Depth introduced the Infinite Axis Utility System, which takes the concepts from the book and puts them together into a simple yet powerful architecture.

In 2015, Mark and Mike Lewis presented Building a Better Centaur: AI at Massive Scale, in which they describe the Infinite Axis Utility System that was the architecture behind an MMO.

I’ve seen these videos before, but having now read the book, I found that upon rewatching them that I understand the sections on response curves and how they apply to the actions the IAUS chooses.

Behavioral Mathematics for Game AI is not a beginner’s book at all, but if you are interested in learning how to give your AI powerful reasoning abilities that produce rich, believable behaviors for your players and want it to be easy to understand and design with, I’m not aware of another book on the subject that is as accessible as this one.

How Much Do You Value Privacy and Security in the Apps You Use?

I tend to dislike relying on third parties to provide me with services I find indispensable.

If I can help it, I prefer having control over my own services, even if it means having a poorer experience than a flashier, proprietary solution might provide .

Staying in Control of my Mental Food Sources

For instance, years ago I used Google Reader quite a bit to keep up with news on the game industry, on blogs I followed, and more. It was a great service.

And then I imagine with the rise of social media my own usage dropped without me realizing it, so when they announced they were discontinuing it in 2013, I learned about it probably on Twitter.

There were plenty of tech-oriented news sites putting out articles on replacement services, such as Feedly, which I know lots of people recommend.

But I was curious about creating my own personal Google Reader-like site. It’s just collecting a bunch of RSS feeds and showing them, right?

Before I got too far wondering how to do it myself, I learned about Tiny Tiny RSS, open source web-based news feed (RSS/Atom) reader and aggregator.

Open source means I don’t have to worry about a third party disappearing or pulling the service for one reason or another. I also don’t have to worry about said third party collecting data on my reading habits.

It was years before I got around to setting it up on my own web host. In fact, I didn’t do so until last December. But now that I have, I feel like kicking my past self for not doing so sooner. It’s incredibly useful, especially as I can’t trust various algorithms (and the algorithm writers) at Twitter and Facebook to show me what I specifically wanted to see.

And the best part is that I am in control. I can backup my data and take it to another web host. I can use my own desktop computer to act as a server if I want. I can see everything without filtering or some company deciding that NOT showing me what I subscribed to is somehow better.

I just hope I never need to ask for support, unless I want to deal with the developer equivalent of the Soup Nazi. Reading through the support requests I did see when I was trying to figure out how to set up the software left a bad taste in my mouth. Yeesh.

But since Tiny Tiny RSS is open source, I technically have the ability to take my support requests elsewhere. Again, I have more control and more options.

My Any.Do Woes

More recently, I ran into a frustration with an app I depended upon to manage my todo lists. A few years back, a friend recommended the Android app Any.Do to me, and I’ve used it ever since.

It was intuitive, allowed me to setup recurring items, and showed me my items in the order I liked, separating things that are to be addressed today from the things of tomorrow or in the vague future.

I of course used it for one-off items. Maybe someone recommended a book to me in a conversation. I would pull out my phone, open up Any.Do, and add an item to remind me to look up the book later.

But the ability to set recurring tasks was a huge feature. I set reminders for mundane things like watering my plants every week or cleaning the litter boxes each morning. I used it for regular habits, such as writing a daily summary of the prior day each morning and using my evenings to plan for the next day. I even used it to remind me to write blog posts or update my finances.

At one point it started trying to get me to install their calendar companion app, but I was fine with my current situation, and I learned I could disable the reminder.

It also kept asking me to get the pro version, but as I had no interest in syncing between devices, I was fine with the free version.

And everything was fine. Well, mostly. It had a few minor bugs I got used to over the years. Every once in awhile, the UI would get glitchy. Sometimes the tasks would look like they were reloading on top of each other, and eventually I think there would be a conflict that would prevent me from swiping a task to completion or adding new tasks. Closing and reopening the app usually cleared it up, though.

The bigger, scarier one was when I would open Any.Do only to find a blank screen. My task list, the one that that I live by, was gone!

The first time, I had a moment of panic because, hey, free version, meaning no syncing, and therefore no backups existed. But then I not only closed the app but shut it down. When I launched Any.Do again, there was my list. Whew! Every critical bug with a workaround becomes a minor bug. B-)

So, I happened to see that Any.Do had an update in Google Play, and I went to check the changelog, and all it said was “Every update is a boost to the app’s stability, speed, and security…” Maybe they finally fixed the bugs?

So I update the app, and now I find out that the syncing feature of the pro version is required in the free version.

Required.

Now when I launch Any.Do, I see a screen asking me to create an account by linking the app with my Facebook, Google, or personal email account in order to keep my tasks and lists in sync across all of my devices.

And there is no way to get past this screen so I can see my list again if I want to avoid creating an account I don’t need.

I’ve learned that Any.Do is also integrating with Alexa and will have a chatbot to help you with your to-do items. I’m sure those are great features for people who like them, but I’m decidedly not an early adopter, and I think I prefer my to-do list app to be sans A.I.

TODO: Find Another To-Do List App

So the changelog lied, and now my choice is to comply and lose a bit (or a lot?) of my privacy, search for older APKs of Any.Do and worry about where they came from and whether or not it is safe to install them, or find another app.

I decided to look for another app, but I wanted to be more careful this time. I already hate it when seemingly simple apps ask for way too many permissions.

Unfortunately, almost all of the apps I could find that focus on privacy and limited permissions were too simple. Recurring tasks are almost never available as a feature.

Privacy Friendly To-Do List by the SECUSO research group would otherwise have sounded perfect in terms of limiting permissions and providing control.

I did find an app called To Do List & Widget. It had limited permissions, which boiled down to “it needs to read and write to files”, and it lets you back up your lists manually.

It’s only downside besides a UI that is somewhat less intuitive than Any.Do’s is that there’s almost no information about who made it and where it came from. It’s definitely not open source. While the permissions allow it to do only so much, I still found myself being a bit uneasy about trusting it on my device. And besides, what happens in the future? Will it continue to be updated?

So ultimately I settled on Taskwarrior, which is a GUI app wrapping the command line tool of the same name.

The underlying system is incredibly powerful, and so unfortunately I found the UI requires me to learn how to use it. Recurring tasks aren’t as easy to setup, for instance, but I can do more interesting schedules than what Any.Do restricted me to.

And if I ever do setup my own Taskwarrior server, I can get syncing on my own terms.

I was surprised that it requires a lot of permissions, but it boils down to the app needing to create and use an account on the device and needing access to the network to do the syncing. There are no in-app purchases or ads, and the source is available so I can build it myself and read through it to verify that nothing nefarious is happening under the hood. I also have the ability to continue updating it if the original maintainer disappears.

The user interface is awkward for me at the moment. Any.Do showed me my tasks for today, tomorrow, and later, and it even had a separate category for unscheduled stuff as “Someday”. A recurring daily task I completed would show up in the Tomorrow list automatically.

Taskwarrior’s default views are showing me everything, and while they are in date order, it’s not cleanly separated. Also, recurring tasks are automatically synthesized from the template task, and so I find I can have multiple instances of the task at once in my list.

Then again, these issues might be due to me not knowing how to use Taskwarrior properly.

What’s Important to You?

Some people might balk at the idea of investing time into learning how to use an app when a more intuitive one is available.

And that’s fine. I get it.

But I’ve been starting to value my privacy and my security even more these days.

And it’s not an absurd paranoia. Recently there was news about a popular makeover app with privacy red flags. Pokemon Go was a concerning app until they changed the scope of the permissions it required to run.

I already know that Google tracks where my phone goes, which means it knows where I go. I should really turn off the GPS when I’m not actively using the map functionality, in fact. It’s always disconcerting to see the notification telling me that it is using it because none of the running apps in the background should care where I’m at.

I mean, when I took a picture at my mother-in-law’s house during a party, I got a request to upload the picture and attach it to the search results of the nearby public park. Ick.

Artificial intelligence is huge these days, and with chatbots and intelligent personal assistants such as Siri, Google Now, Cortana, and Alexa, we’re seeing a lot of benefits in the way of convenience.

To get that convenience, though, we’re handing over our data to the people behind our devices. And yet, security is rarely treated as a priority, which means that even if we trusted our data to those people, it might also be getting to people we don’t trust.

And so, because I value my privacy and security, often it feels like my choice is to opt-out or roll my own solution.

And since everything is getting artificial intelligence integrated in, it often means tolerating third parties getting access to data more or using alternatives. And if I am going to use alternatives anyway, they may as well be ones I have the most control over.

Thank goodness for free (as in speech) software, eh?

Looking Back on 2016; Looking Forward to 2017

Wow, it’s almost February? I’m incredibly overdue for the blog post in which I give a post mortem of the previous year and talk about my plans for the coming year.

Which isn’t to say that I’ve been doing nothing this past month. I just haven’t prioritized telling you about it over actually doing it. B-)

WHAT WENT WELL IN 2016

As I said in 2015, I improved my ability to remember my goals. I no longer did the equivalent of setting New Year’s resolutions that I forgot within weeks. Throughout the year, I knew how well or poorly I was doing according to metrics I tracked.

Unfortunately, it meant that I was very aware of how poorly I was doing most of the time.

Last year I set out to build on my success with remembering goals by focusing on what’s needed to actually accomplish those goals.

One big and important improvement I had was in the area of project planning.

In the past, even if tried to be formal about my project management, my actual planning efforts never amounted to more than creating a list of tasks.

Now, some developers find that they can do just fine with nothing more formal than a TODO list or two, and it worked fine for me if I just wanted to know WHAT to work on and maybe even in what order.

But when you’re a lone wolf indie game developer, you need to wear a lot of hats. I had no problem with donning the Software Developer Hat, but my Producer Hat was neglected and gathering dust.

So I might spend weeks working on a particular feature or task without realizing it because I never stopped to think about how the entire project’s progress was being impacted.

At the beginning of the year, I spent quite a bit of time in project planning mode. I even wrote about how I approached it in How to Create a Game Development Project Plan. Then I dove into executing the plan.

And I was very pleased at how well following the actual plan worked for me. Even when my project started running late and surprises appeared that I hadn’t planned for, having a more active Producer Hat meant that at any given time I was focused on actually shipping my game.

Which leads me to the next thing that went well: I shipped!

I published my business simulation game Toytles: Leaf Raking for Android.

I still need to write the post mortem for it, but it is my first finished commercial project in years. While there are still features and content I wished I could have added, I’m proud of what I put together.

The release of my first commercial game in years also gave me my first sales in years. After earning $0 in 2015, I like this new trend of actually earning money from my business.

Speaking of money, 2016 was also the first time I put together a detailed budget for my business.

I used to track my expenses and income as they happened, and my aim was to ensure I had enough money in my bank accounts to cover everything.

But I got tired of learning that my bank account balance was lower than expected, only to discover that an automatic renewal on domain names or web hosting had occurred. I felt like I should be able to anticipate such regular expenses instead of being surprised by them.

So, I put together a projected budget, which allowed me to see not only how much I anticipated spending in the coming year, but also when my expenses were expected to spike. For example, I knew that my annual web hosting renewal was coming up in August.

And then I tracked my actual expenditures against the budget. It was eye-opening, and not just because I was able to quickly learn that my web host increased its rates without telling me before autorenewing. B-(

As a side effect of being hyper-aware of where my money was coming and going (er, mostly going), I also added to my budget a plan for a monthly investment into my business. I managed to add a significant amount of money into my business bank accounts by the end of the year.

Also, I updated my website, which is something I’ve been meaning to do for quite some time. My blog used to be completely separate from the main site, and now it’s integrated.

WHAT COULD HAVE BEEN BETTER IN 2016

Aside from my newly detailed budget and more robust project plan, I didn’t have plans for much else.

I wish I had spent some significant time on creating a promotion plan for Toytles: Leaf Raking. I had done some keyword research and put together a list of reviewer contacts, but most of my effort was spent on actually finishing the game.

Once it was nearly ready, I struggled to make forward progress on getting it in front of people. I realized quite late that the reason I was struggling was because I had no real plan to make it happen.

I didn’t even blog much about it, so I rarely mentioned it during development. I was a bit too accidentally secretive.

For a long time, I had a TODO item on my list to create a skill development plan for myself. I wanted to direct my learning more rather than pick up things haphazardly, but all of 2016 passed without such a plan in place.

I read 54 books, but only 8 were business related, of which I believe only one was game development related.

My project ran late. I didn’t plan for balancing the design, and so quite a bit of work to make the game feel complete wasn’t in the original plan.

Had I published it in three months, I would have had the rest of the year to figure out how to promote it. I wanted to try earning $1,000 by December 31st, but between the late release and my lack of promotion, I fell way short of that mark.

WHAT I WANT 2017 TO LOOK LIKE

2015 was about keeping my goals in front of me and establishing habits.

2016 was about being outcome focused. I logged more game development hours in 2016 than in 2015, but the more important thing was that those hours were aimed at targets.

In 2017, I want to focus on promotion and sales.

Which means I’ll be putting together concrete, specific, actionable plans instead of hoping and praying, or haphazardly trying to tweet about what I’ve made, which is basically the same thing.

I’ve already started the year with efforts to port Toytles: Leaf Raking to other platforms. More platforms means more opportunities for people to find my game. First up is GNU/Linux, mainly because it is my development platform and is easiest for me.

But what about making other games? Project planning is one thing, but product planning is another thing entirely. I have various ideas for new games, but I don’t want to be random about picking something just because it appeals to me. It will be easier to promote new projects if I do my market research and ensure my projects already appeal to players.

My blog has historically been about running an indie game development business, and so my audience has been other game developers primarily. My customers, however, aren’t going to be other game developers and aren’t necessarily going to care about what happens behind-the-scenes.

The thing is, I like writing what I’ve been writing on my blog and don’t want to stop. Can I address players more directly, or do I need to separate my business from my blog to do so?

I am confident when it comes to creating games, but thinking about selling them is both exciting and terrifying to me, the way new things often are.

2017 is when I challenge myself to be incredibly proactive about putting myself and my work out there.

Let’s start. Oh, and happy new year!

Where To Donate Some Money Before the End of 2016

There’s only so much time left for your charitable contributions to count towards your 2016 taxes.

If you’re looking for recommendations, here’s two organizations I have contributed to because I believe in what they do.

Electronic Frontier Foundation

“Defending Your Rights in the Digital World” is the EFF‘s tagline, and I’m unaware of another organization focused on our rights and liberties in the context of our digitally-enhanced age.

Founded in 1990, EFF champions user privacy, free expression, and innovation through impact litigation, policy analysis, grassroots activism, and technology development. We work to ensure that rights and freedoms are enhanced and protected as our use of technology grows.

When the Digital Millenium Copyright Act was passed in 1998, there was a lot of abuse potential.The DMCA is overly restrictive in what it allows people to do legally with their own technology, and it allows large companies to abuse the system.

Yet the DMCA has become a serious threat that jeopardizes fair use, impedes competition and innovation, and chills free expression and scientific research. If you circumvent DRM locks for noninfringing fair uses or create the tools to do so you might be on the receiving end of a lawsuit.

In one high-profile example, Dmitry Sklyarov, working for ElcomSoft, was arrested by the FBI while he was in the United States on a trip where he spoke at DEF CON about ebook security, specifically Adobe Systems’ technology. Why?

Because…well, it wasn’t clear at the time, but Adobe Systems thought that his published research and software was a violation of the DMCA’s circumvention of their copy protection systems.

The thing is, Sklyarov is from Russia. The DMCA has no jurisdiction there, so what he or his company did wasn’t illegal.

Also, while Adobe’s software didn’t allow people to exercise Fair Use, ElcomSoft’s software did.

Throughout the years, the EFF has been leading the charge against abuses such as this one.

I like my copyright law to be used to promote the useful arts and sciences, not to allow copyright owners complete control over all potential uses just because there happens to be a DMCA-covered copy protection scheme to prevent my otherwise fair use.

I also like my privacy to be protected, and I don’t like finding out that my technology is forced to have backdoors or introduced a rootkit onto my computer.

So, I support the EFF’s work, including their projects such as HTTPS Everywhere which is aimed at helping to make our web browsing more secure, and recommend you do the same.

Contribute to the EFF and become a member.

The Internet Archive

I’ve been blogging for over 10 years, and a lot of the blogs and news sites I’ve linked to in the past are no longer around. Sometimes, I want to reread an article, but the link I have is dead.

Another issue that could arise on the Internet is that someone’s stance may have silently changed. You were pretty sure that politician was pro a few years ago, and yet they insist that they are con and always have been.

So I go to Archive.org‘s Wayback Machine and find the article from around the time it was originally published and prove that the politician has flip-flopped.

The Internet Archive not only has the history of over 279 billion web pages, it also has a library of books, movies, music, and software.

Did you want to watch The Great Train Robbery, the 1903 silent film with the terrifying surprise ending? Well, it’s not really all that terrifying, but back when it was originally in theaters, it made audiences jump out of their seats to safety because no one had seen anything like it before.

It revolutionized certain film-making techniques, and you can watch it for yourself thanks for the Internet Archive:

Or maybe you miss playing certain games on your Apple II computer, such as the classic game Lemonade Stand:

Oh, wow, does that take me back!

I believe in the importance of preserving our history and ensuring free and open access to knowledge is available to millions of people for many years to come, and I’m happy to support the Internet Archive in its efforts to be the most trustworthy and important non-profit library for the world.

Contribute to the Internet Archive today, and your donation will be matched 1-to-1 to double your impact.

Those are my two recommendations. What are yours?

Merry Christmas!

When I was younger, I loved the challenge of sneaking around the house during the holidays to find my Christmas presents before Christmas Day.

I like I think I was pretty good about it, too. I would sometimes find the already-wrapped boxes above the china cabinet or in my parents’ dresser.

Once I located the packages, I would slowly peel back the tape, being careful not to rip the wrapping paper. Then I would peek at what was inside, and after seeing the picture on a box or a name in big, bold letters, my curiosity would be satisfied. I’d replace the tape, and no one would be the wiser. Or at least I thought so. Maybe I believed I was sneakier than I really was.

One year, however, I went a little far. Well, ok, a lot far.

At that time, what had just been released for the N64 was The Legend of Zelda: Ocarina of Time.

I didn’t preorder it, so I didn’t get the cool gold cartridge, but I knew my mother had gotten me the game for Christmas.

But who could wait that long?

So I found the box, peeled back the gift wrapping on one end, sliced through the shrink wrap, opened the box, took out the game, and replaced it with another to ensure that the weight of the gift felt the same. I believe I used Body Harvest since I wasn’t playing that much at the time.

I think I played the game for two weeks before Christmas, and as far as I know, no one noticed that I was playing a game that I wasn’t supposed to have yet. When I opened my gift on Christmas day, I showed a lot of gratitude, and when no one was looking, I put Body Harvest back in my collection of games and continued playing Ocarina of Time from my last save point.

At some point, my family started double-wrapping my presents, which meant that I could no longer carefully peel back the tape and wrapping to see what I was going to get. I would just see more wrapping paper, and I wasn’t going to risk ripping it and giving away the fact that I had found the presents.

Today, my own home is preparing for the holiday. As of this writing, the stockings are stuffed, including the ones for the cats.

Christmas 2016 - Stockings Stuffed

Christmas 2016 - Cat Stocking

Hopefully Diego and Gizmo don’t sneak a catnip toy before the morning.

May you enjoy sharing tales with loved ones of the glories of Christmases long, long ago. Merry Christmas, and happy holidays!

Follow GBGames on Google Plus and Facebook!


Twitter: gbgames