Author Topic: AI for RPG chess-type game from scratch  (Read 5983 times)

SomeGuy

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
    • View Profile
    • Email
AI for RPG chess-type game from scratch
« on: January 18, 2013, 11:11:42 AM »
Hi there.

It's a game I'm developing now, much more advanced than WitchavenRL in some aspects.
It is/will be something like Chaos: The battle of wizards but with some different game mechanics.


I know it's not a Roguelike Game, but some RL developers may have some ideas about AI development so I would want to discuss here some "homemade" methods for this game.

Right now, I'm implementing an AI based on threat level and character personality. Let me explain this:

The map or board is cell based. The player can summon creatures, and the enemy too (if you watch the video before you know what i'm talking about).
The player will be able to move his creatures, so the AI part will be only for enemy creatures and enemy mage.

When the enemy turn starts, the game calculates a "threat table", that is exactly like the game board, but each cell contains the threat level of such cell.
The threat of a cell is calculated by "running" through every player creature and adding to all his possible movement cells a threat amount based on the creature overall strength.
So, after checking all player creatures, the threat map is filled with numbers.

The second part of the AI is the movement itself. I'm using an efficiency method using personalities.
When the enemy mage wants to move to a cell, the game checks every possible cell where the enemy mage can move. For each of those cells, a cell efficiency is calculated. To do this, the game adds or deducts efficiency by having into account if the cell is closer to the player mage, if the cell has high or low threat, if the cell has or not a player monster, and some other parameters.
After running for all those cells, we obtain the most efficient one, so finally the enemy mage (or enemy creature) moves to that cell. Of course, the cell efficiency calculation has into account the enemy personalities such as aggressiveness and wariness (more personality aspects could be included).


That's basically the AI for choosing the best cell to move.
It doesn't have any possible future movements checking like in a true chess AI. This would be fairly easy to implement. But right now, I got the AI like described above.

What I would like is to know some opinions and tips on how to enhance this, or even other algorithms that are simple as this one.

requerent

  • Rogueliker
  • ***
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: AI for RPG chess-type game from scratch
« Reply #1 on: January 21, 2013, 12:15:55 AM »
How many actions can a player take per turn? Does every piece on the chess-board get to move and do all enemies behave according to the 1-HP rule of chess?

I suggest modifying the threat table so that protected squares reduce the threat. That is, even if a pawn, a bishop, and a knight threaten a single tile- it's relatively safe to move there if you have a pawn and a bishop also covering that tile. Each tile that a unit can move to, however, needs to be re-evaluated for every possible move. That is, if I move this pawn, it changes the threat level of the tile that I am moving to- perhaps it opens up a line of passage for a bishop or something else. This can make the AI appear dumb if every unit gets to move, because the order that moves take place will have a huge impact on whether or not intelligent moves are made. You would also have to modify it so that only previously moved pieces reduce the threat level, otherwise a piece that should be protecting another piece might move, not realizing that it should stay still. A piece that is explicitly good at protecting others, however, might choose to not move if it is protecting other pieces.




If you want to avoid future-checking and keep all of your agents reflexive, you can implement a number of heuristics and then use a probability distribution over those heuristics to determine the next move. These heuristics would depend both on the type of creature (does it have specific vulnerabilities?) and the board configuration.

For example, lets say you implement a Least-Conflict heuristic and a Max-Balanced-conflict heuristic. Least-conflict evaluates each tile based upon the number of enemies that could move there (like your threat map), and then picks the lowest value, whereas max-Balanced-conflict picks tiles based upon equivalent threat (that is, allied+enemy units that could threaten a tile). If a creature has a damage shield, or something, then max-balanced-conflict heuristics are good. Balanced-conflict is also good for pieces that are effective at occupying protected tiles. If there is a tile where there are 6 or so pieces with access to it (3 enemy and 3 allied), moving a sturdy piece there might make sense.

Most-protected tile, most-threatened tile can also be useful-- it just depends on what sort of properties each unit has. I'd recommend coding each personality as a heuristic and then weighting those personal-heuristics based upon the unit. A mage, for example, might be .75 least-conflict and .5 most-protected. Whereas a Suicide Bomber might be 1.0 most-nearby-enemy-units, .4 least-conflict and .6 most-protected (you can pre-sum them to 1 if you want). Protects-Most, most-nearby-allies... etc etc etc.

There is no assurance that this technique will result in interesting and seemingly intelligent AI. Some sort of state-based search tree is pretty important for that- especially when multiple agents are working together. I've coded reflex agents that are smarter and faster than model-based agents, but they would immediately suck balls if working on a team.

The more you describe your objectives and how the game plays, the more help you will receive. Certainly describing what sort of properties your units have might help.
« Last Edit: January 21, 2013, 12:24:48 AM by requerent »