Showing posts with label genetic algorithms. Show all posts
Showing posts with label genetic algorithms. Show all posts

Friday, November 9, 2007

Game AI, or Do game AI's feel pain?

As some of you may know, I am currently working on an rpg.(Who isn't it seems like).

However, I was thinking about different AI ideas that could be implemented in an RPG. For this post, I will focus only on monster/enemy AI.

Now, the first thing that can make rpg battles/dungeons a bit more interesting is a context outside of battle, where what happens in battle does affect the overall dynamic of the dungeon. Here is one possible idea, similar in aspect to a genetic algorithm. Each enemy has a fear and an intelligence rating, randomly assigned within a predetermined racial standard deviation. Say, slimes are smarter than kobolds for example, on average.

Now what this means is that if you cross an enemy's fear/intelligence barrier, ie, "They're really tough, maybe I should run." So they'd try to escape. If they do escape, what happens? Normally, you'd never see that enemy again, or at the very least, never be able to tell. However, what if the enemies that survive or escape you, communicate with each other? And even are able to formulate plans and groups to take advantage of whatever they learn.

This can be done by giving escaping monsters a memory, a kind of statistical observation of your performance. Then in a background task, have a couple or more of such monsters communicating their knowledge to each other. Now, based on the length of time since the knowledge was obtained, the detail, and what is observed, different information will be valued more than others. By sharing the information between the monster memories, the background task is able to determine your weaknesses. Say it saw your white mage fall to two hits, but your knight took 10. That would be taken into account.

Then, the enemies would lead a charge against you, with slightly modified battle AI's. As per our example, focus on the white mage!

And since this would be largely time and number of battles based, the longer you are in the dungeon, the tougher the enemies get.

To balance that, we make it so that when you leave the dungeon, the monsters all forget about you.

This behaves similarly to a genetic algorithm, where the fitness test is fighting you. And the sharing of information is similar to swapping genes, but, in this instance, its a method that can deal with unexpected shifts of the problem space. Whereas, in genetic algorithms, the genes have to fit the problem well, and take a while to adapt. By data-mining observed actions, the enemies can adapt faster than with a genetic algorithm.


Another idea I considered was enemy genes, where each enemy you manage to kill does not reproduce, and thus, the more you fight in an area, the tougher the monsters. However, without a very flexible genetic system(IE, one too powerful to adequately simulate) this would only lead to monsters with stronger and stronger genes. Also, the algorithm would have to be tweaked to show results quicker than most GA's.

Next post: RPG AI Part II