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.
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?
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!
Answer
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.
No comments:
Post a Comment