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'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.

share|improve this question
    
If any part is not clear enough or if I should present more information about how I handle a functionality in the game, just leave a comment and I'll edit my question. Also - should this be a community wiki? I personally don't see it as subjective or argumentative but I may be wrong. –  Jesse Emond Mar 11 '11 at 19:25

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer

First of all, I wouldn't include short-term goodies such as income or speed upgrades into account - I think players expect that these things help them for a while, not that the AI adapts immediately and gets stronger as well.

And for the rest: try it out. Start with a power formula that seems reasonable to you (nimbus57' response should be a good starting point) and then develop your formula and the AI iteratively.

Last but not least, try to make sure that the underlying formula cannot be exploited by the player to gain unfair advantage etc - it also shouldn't be too obvious how it works, so pull in a bit of randomness.

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.