Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am designing a game where the battle system is similar to Pokemon. That is, a 1 on 1 battle with only a few (4-6) moves to choose from. As the game is taking shape, I'm starting to think about some of the more difficult coding areas such as enemy AI and I have a few questions. I have already thought about some possibilities for designing the AI and wanted also to hear your feedback.

I am thinking of trying a universal AI for my game where all monsters will utilize the same logic for determining what move they will use. It will be based around equations/values assigned to each move and determining which is the best to make. For example, if the monsters move will be resisted (1/2 damage) by the opponent then it receives a lower effective value than the others and moves that do extra damage due to vulnerability will receive higher effective value. Also, I was thinking of adding a variable that reduces the value if the move has been used repeatedly to avoid the computer always using the same move. I feel that this is currently limited just to making the computer use the highest damage move. Any suggestions?

SO for my questions.

  1. How does designing AI logic for each monster/Pokemon vs having a general set of rules for all effect the size of my game in terms of code and effectiveness of the AI?

  2. Are there any resources that discuss designing AI in this manner? I found very little on the AI in Pokemon games and I'm unsure what other games might be similar in mechanics.

Thanks for your time!

share|improve this question

2 Answers 2

up vote 10 down vote accepted

Generalized AI with modular components will probably result in smaller code, and will be easier to expand for a larger number of characters. Here are some example considerations, assuming you construct a generic weighting system for all characters.

-You could assign each character a 'personality' or 'attitude' from a set list (e.g. 'Aggressive', 'Defensive', 'Random'). Then, have your weighting formula take that into account. So, say, an Aggressive character would give more weight to damaging moves, while a Defensive character would give more weight to healing himself. Then, you only have to assign the personality to each character rather than writing unique scripts for each.

-Instead of always choosing the 'best' option, your AI can weight each option, then randomly decide between them. So, given 4 moves, if their calculated values come out to 60, 35, 25, and 20 in this turn, that adds up to 140. Pick a random number in the range 1 to 140, and check against the weights to decide which move is used. This will make the AI usually use the best move, but often surprise you with an alternate choice.

-You can give each AI character a numeric "skill" rating that is used to scale the chances that they will pick the best move.

-Remember that Pokemon has a LOT of moves that do not do damage directly, but instead apply status effects, buffs, or debuffs. You can give each character a numeric preference for damaging versus non-damaging moves. You could also give them a set number or possible range of non-damaging moves that they will use before starting to attack directly. Current self and opponent HP values could also be a factor in the formula to weight attacking versus using strategic moves - when you're both at full health, you've got time to set up, but when it's down to a sliver of HP each, it's time to use an attack (hopefully one that hits first!).

-Also, Pokemon has attacks with secondary effects. Consider how you want to weight an attack that does more damage versus a weaker attack with a chance to stun or that always goes first.

share|improve this answer
    
thanks for much for those suggestions. I think that would be a great idea to set up a few different styles (aggressive, defensive) to add some variety and then give weight to different things such as status effects or damaging moves. –  willmer May 7 '12 at 21:06

So your biggest concerns are code and AI effectiveness. Since your question has 44 views an no suggestions, I thought you wouldn't mind ideas from a basic gamer - esp one that has played Pokemon games. I do not have an AI background an only a small programming background however I think:

If you have unique AI per Poke (Pokemon), your code may be huge. Thus you need Poke classes, and AI (a strategy set) per class. The problem is that for classes=n, you have "The sum from i=n to i=0 of i" strategy sets (SS) to make.

Example: 
Classes A, B, C have match-ups AA, AB, AC, BB, BC, CC. n=3 SS=6=3+2+1
Classes ABCD; match-ups AA AB AC AD BB BC BD CC CD DD. n=4 SS=10=4+3+2+1

If you design your classes the typical way, there is a rock-paper-scissor way to everything. Like fire beats water beats earth bears fire (cycles around). Thus, each Poke can have an identifier for the Class of Poke. Also you have say a maximum of 5 moves.

Example:
Pikachu's "growl" has the same effect as Raticates "squeal" to "Lower defense"

Your Poke object would contain the following

  1. It's class (A,B,C, etc)
  2. class# of ordered lists that prioritize which move to use against other classes

    Example: Pikachu: Class A. StrategySet A;12345, B;34512 C;51234 Chrmndr: Class B. StrategySet A;21543, B;12345 C;34512 Squirtl: Class C. StrategySet A;43215, B;21543 C;12345

When they fight, (Say Pikachu vs Charmander) if the CPU is Pikachu, the Charmander object passes Class B to Pikachu, and the CPU-Pikachu selects strategy set B;34512, which is the pre-prioritized way to fight a Class B opponent. Those five moves fall into general categories (attack, defense, self-speedup, enemy-speeddown, enemy-attackdown) or what have you, and thus the computer knows what to use first. Using other items in the list can be up to parameters like opponent's health frequency, or even something crazy like the sim of priority values going over a maximum.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.