Monday, July 20, 2015

ai - Calculating the "power" of a player in a "Defend Your Castle" type game


I'm a making a "Defend Your Castle" type game, where each player has a castle and must send units to destroy the opponent's castle. It looks like this (and yeah, this is the actual game, not a quick paint drawing..):


enter image description here


Now, I'm trying to implement the AI of the opponent, and I'd like to create 4 different AI levels: Easy, Normal, Hard and Hardcore. I've never made any "serious" AI before and I'd like to create a quite complete one this time.


My idea is to calculate a player's "power" score, based on the current health of its castle and the individual "power" score of its units. Then, the AI would just try to keep a score close to the player's one(Easy would stay below it, Normal would stay near it and Hard would try to get above it). But I just don't know how to calculate a player's power score. There are just too many variables to take into account and I don't know how to properly use them to create one significant number(the power level).


Could anyone help me out on this one?


Here are the variables that should influence a player's power score:


Current castle health, the unit's total health, damage, speed and attack range. Also, the player can have increased Income(the money bag), damage(the + Damage) and speed(the + speed)... How could I include them in the score?


I'm really stuck here... Or is there an other way that I could implement AI for this type of game?



Thanks for your precious time.



Answer



I'm not positive how easy this would be to tell, but trying to find out how important each variable is is probably the place to start (if you gain 50 health, you can last 10 seconds longer; if you gain 5 damage, you can destroy 50 health 10 seconds faster; etc...). After that, trying to normalize the abilities might be worthwhile (50 health is the same as 10 speed is the same as 100 income).


I imagine an easy way to find some of this is by just running simulations. Keep one player at a single level, and then start adjusting individual variables to how they scale.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...