Advertisement

Board rpg ai

Started by September 21, 2011 01:11 AM
6 comments, last by rpiller 13 years, 2 months ago
I have a game that is a 10x10 board where you have 6 units to move and do rpg type actions with. Each unit type has 4 unique abilities. Each ability has a cooldown to it. The game is realtime based. My question is what would be the best methods to do this ai with? There are a ton of options to do so not sure how to go about this.
Step 1: How would you go about making a decision when you play? What are the factors you take into account? What are the criteria that you use for one action over another?

Fill that out -- simply on paper -- and your AI is well on its way.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Advertisement
I was thinking about that, but would that mean I'd be "stuck" with that approach always? Would I be required to come up with a bunch of different "approaches" and pick one at the start in order to make the AI not predictable. Even if I come up with 5 different approaches it would become predictable by players at some point on the strategy. Do I mix approaches in a single match and if so how often to mix so it's not constantly switching and doing crazy things.

Also, there are so many moves that could be done, and adding in cooldown timings makes it even more difficult. I've read that Chess can have around 319 billion possible ways to do the first 4 moves. I have less squares and pieces, but have removed movement restrictions, added 4 other actions per piece, and added the cooldown time element so I'm guessing I'm sitting close to the 319 billion mark if not over it.

So I was just wondering if there are some preferred techniques that could help me make this AI seem "consistent" and "intelligent" without some feeble attempt at trying to have it do what I would do. There will be many judgement calls that have to be made while playing this game. Many priority changes in real-time as you see what the player is doing to your units.
You program the AI in steps. Start with how you would make your decision. You have a goal set (perhaps win or something slightly closer to the end of say 2 rounds). Then you look to see how to best achieve this goal. If it is about taking all the pieces, and you can only move one at a time, decide which piece can make the best move (which of your pieces can take the enemy's piece that is worth the most). Then do the action. Think of it as weighting options and choosing the one that best fits. If an ability is in cool down, rule it out

Edit: You have more squares and less pieces, by the way. And for weighting things and priority changes, have saving units low on health (if it has that RPG element) take priority to save themselves. Or use a combined value -- heuristic is the word for all these values -- that determines whether saving a unit or taking a piece/using an ability is the best option.
I'll give it a go straight up like this but there are so many possibilities I wouldn't even know how to program how to pick the best one at what time.

If an ability is on cooldown I might not want to rule it out entirely. It might be worth waiting the x seconds in order to do it again but during that wait time the player does something that changes that. It's all real-time and I can move and do abilities on all the units at any time pending cooldowns.

There are 2 units that can heal and I suppose those would be the primary targets, but I can't just have my units all swarm the healer(s). That AI wouldn't be much fun to play over and over again. The hard part about this is that I don't even really know how I would play it exactly right now.

I almost feel like I'd have to play it against people first just to see what kind of strategies would work or develop. Maybe I should get the multiplayer working first so I can play against others before diving into making a crappy AI system.

I guess I just thought there were some techniques and tricks out there to help me get started. Seems brute force is what people are recommending. With basically unlimited amount of moves and actions to do brute force just didn't seem like the way to go about it.


EDIT:
Sorry it's an 8x8 board. I misspoke before. Thanks for the edit tips. There is health to these units so self preservation is probably a good idea to a point of where sacrificing ones self to benefit the whole would be required.So how would you come up with these heuristics?
Step 2: Use the ">" and "<" symbols. That is, compare stuff.


Don't be daunted by all these "billions of possible moves". You are only making one at a time. Even in chess this is so. The trick is evaluating what your options are for the next possible move. The cooldowns, in this case, actually make it easier because you are taking some of the options off the table.

This is why you need to do step 1... make a list of the things you take into account when you are playing. Seriously... write it down. What are your factors? Damage dealt? Mana? Time? Vulnerability? How important is one compared to the other? How do you evaluate threats to your own pieces? Is it better to kill recklessly or play it safe?

Once you have scores for these you can choose. Evaluate the potential costs and gains of each of your possible moves at that moment. Score them somehow using a system that makes sense to you mentally... e.g. "damage dealt"... and compare your results. If you simply sort the list of potential actions by this figure, you can take the move on the top.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Advertisement
If you want a quick idea of heuristics, look into A* pathfinding. Each square one moves to costs a certain amount. Diagonals are a bit more distance (considering a square-tiled board), so a diagonal movement costs more. Perhaps 10 for North, South, East, and West, and 14 for each diagonal. Then take into account how close it puts you to your goal. If moving diagonal puts you closer to your goal than say moving up/down or left/right, your distance left is less. So to calculate which tile is best to move to, you get a number for all 8 squares. Add the movement cost (10 or 14) to the distance left (some number, say 10 squares for the diagonal and 15 for a + direction towards the goal). The lowest square is the right choice.

Same with your game. Each unit has options. Each player has to choose which unit to act with at a given point. Is it better to move the knight or the mage? Should I heal or throw a fireball? Like IADaveMark said, figure out what each piece/character can do, figure out cooldowns, figure out movement, figure out damage, decide on a final goal. Use these to determine things. For instance:

If your total current HP / total max HP is less than 50% your units should not make fighting decisions but instead safe movements/defensive actions and healing. If a character is almost able to cast a big spell and is in no immediate danger (enemy distance), only move or position him, then cast when cooldown expires. Decide what types of things each piece values most, decide what goals are valued. Perhaps have a list: Eliminate Enemy, Buff Piece, Heal Piece. Then adjust which is more worth while at a given time (say like with that HP check). If HP hits that halfway mark, then you make Healing more worthwhile. Say you are 75% down. Or an ally in range is below 50%. You raise a piece's heal piece value so it will be the better choice, but still isn't as worthwhile as eliminating a piece (perhaps an enemy is close and can be attacked this time around). Say it gets worse, then healing a piece reaches the top. It's all about deciding what can be done at a given moment then deciding on the best action.
Evaluate the potential costs and gains of each of your possible moves at that moment.[/quote]
OK, it's starting to get more clear. Thanks guys, I'll take this and run with it!

This topic is closed to new replies.

Advertisement