Tuesday, July 14, 2009

Island Commander AI

I've received a total of zero emails asking me about how I implemented the AI in Island Commander, but screw you lot, I'm going to talk about it anyway.

This is all probably exceedingly simple to anyone's who written any kind of strategy game AI, but the enemy works in this way: every so often, it scans the map for the players units. It then gives each square a threat point value, based on the unit type (the meaner the unit, the higher the points) and how far away the square is. It then totals up all the points for each square, and then finally takes the square with the highest points of which the AI owns. This square is where the AI will build its next attacking unit (if there is actually any threat to that square).

Of course, this may not be the case. There may be no threat whatsoever, and in fact there may be some juicy enemy mines to destroy. If this is the case, the AI does the same thing as above, except instead of looking for threats, it looks for targets. If there are within range, it will launch an attack on them.

Incidentally, you can see this in action by pressing T (to see the "threat map") or Y (to see the "target map") when playing the game. There are a few other nuances, like the fact then if the AI is attacking, it will sometimes build 2 or more units since they have more chance of surviving. It will also choose certain units for certain roles, like defending or attacking. But in a nutshell, that's it.

The next step is to implement different "personalities" of AI, one of which is chosen at random at the start - a defensive one, an aggressive one, and maybe a mad one that does random things. I may even get them to shout sarcastic remarks at the player via the console.

3 comments:

stevec said...

LOL. I actually did try playing the game, but I couldn't figure out what was what or what I was supposed to do.

Maybe you should make a little demo video or something.

-- steve

Panu Kinnari said...

Seems a bit too easy. I found at least following "winning" formula I managed to replicate several times.

-Build mines to best areas until you have 10-15 of them. I tried to remain out of direct conflict with AI.
-Wait until you have money for 2 silos. And build 2 of them next to each other as close to AI as possible. AI will feed some unit but your 2 units kills it easily.
-Build at least one more silo and then few mines.
-Rinse and repeat as needed.
-Clear the field with fighters and expand with mines.

Steve said...

Stevec, I'll have a go at creating a vid, good idea.

Panu, thanks for the feedback. You're right, it is a bit easy cos I think the silos are a bit too cheap. I'll have a go at tweaking the prices.