ID:154255
 
Alright, I am trying to draft an AI structure for a strategy game I am working on. It works like this: Up to 8 leaders can match forces on a battlefield with any combination of alliances. Different alliances are assigned colors (red, blue, green, yellow, white, black, purple, orange). Each leader may place between 3 and 10 units (selected in advance) on the field which are automatically deployed. The match then commenses with alternating turns. During a turn, a leader selects a unit then an option: Move, Attack, Item, Spell, or Special. Different units may restrict these options (IE if the unit has no items or spells, it may not select the Item or Spell commands). After a leader ends his turn, she must wait until all other leaders take their turn before she may go again.

Victory occurs when either:
1) All enemy units are defeated/withdraw
2) Mission specific objectives are completed (IE secure a specially placed object, have units alive after a certain number of turns, etc.)

Now the problem. I am not sure how to design a computer opponent system to work with this system. What I am mainly looking for is speed, but the AI needs to have some plausible strategy. I was thinking I might create a computer "player" and assign it a "personality" that dictated how it uses units. IE an "aggressive" player would seek to move all its units into attack range and go for frontal assaults. A "guerilla" personality would try to have units not engage an attack unless they had enough movement to end their turn out of range of enemy units. A "range" personality would try to maximize protection for missile units. And so on....

Secondly, Deadron had addressed client run games and I wondered if anyone had any ideas on how I could set up a system whereby there could by a large number of battles occuring simultaneously on different runtime created maps.The goal is to have a setup where many players could be connecred simultaneously and challenge each other as well as cooperate against either computer controlled or human controlled foes.

-James
Now the problem. I am not sure how to design a computer opponent system to work with this system. What I am mainly looking for is speed, but the AI needs to have some plausible strategy. I was thinking I might create a computer "player" and assign it a "personality" that dictated how it uses units. IE an "aggressive" player would seek to move all its units into attack range and go for frontal assaults. A "guerilla" personality would try to have units not engage an attack unless they had enough movement to end their turn out of range of enemy units. A "range" personality would try to maximize protection for missile units. And so on....

Warcraft II and Starcraft use very simple AI systems -- they assign "threats" to specific players (Starcraft also assigns priorities to certain areas.) They then average the threats and territorial priorities and determine who they should attack. Finally, it's just a simple matter of following the little AI script that the AI was given, which tells it what it should build and field against the opponent. It tries to build expansion bases every so often, and will also expand its base if it runs out of a certain type of resource. And, finally, it tries to increase the size of its attack force every time, until it manages to get overwhelming superiority.

It's kinda funny that such a simple AI causes such a problem for players... of course, the AI mostly gains its advantage from numbers, and it doesn't recognise enemies massing forces -- so, if you manage to build a stable defense, you can build your forces and then overwhelm them in a counterattack (which, as in any military situation, is the best time to attack -- assuming, of course, that their attack didn't weaken you).
In response to Spuzzum
That's actually the AI model I use currently. The computer will run through its units, evaluate any enemies it can see and move towards the one that has the best index of threat/distance (IE it will move to one it can attack rather than a "better" target that it cannot reach this turn). Units with special abilities will randomly use them depending on factors such as range and whether it would harm nearby friendlies (IE no fireball when the enemy is surounded by friendly melee units).

However, I find such a simple AI system has some huge flaws. For one thing, once the player realizes how the computer is making decisions, it's fairly easy to exploit. IE if you know the computer will probably not use its wizards to fireball enemies if they are close to CPU friendly units, just rush. This is too high a degree of predictability. Likewise, you can feel confident running your brute strength units up on the wizzies as long as you engage their brutes with a unit with high defense. This is unrealistic as any decent player would probably disengage the distracting units and move to intercept. It also shows problems in multi-player settings in that there is no coherent response to teams and team strategies. I am sure other flaws will emerge with playtesting.

I reasoned that a slightly different approach will still have flaws, but at least the flaws wouldn't be so persistent and predictable....

-James
In response to Jmurph
How about making a few possible responces to the same situation. If the fireball-thrower won't throw a fireball near its fellow units in one instence, then maybe randomly they'll do it in another, or maybe in another it'll measure the value of the surrounding units compared to the attacking units, etc...

You could also give CPUs a random agression factor (whatever you want to call it) that decides how much they care about their fellow units in such cases.
In response to Foomer
Oooh, I like that one. Aggression. That might just work..... Now if only I could figure out a way to dynamically load maps at runtime so that I could support multiple simultaneous battles.....

-James
In response to Jmurph
Yeah... My suggestion is to create your AI by giving them the strategy that you yourself would use in a given situation... If it would be beneficial to throw a fireball even if they'll lose some units... Then by all means...toss some flaming death...

But of course...even that gets a bit predictable... A player could guage what their opponent is likely to do based on their own weighing of the consequences...

So there has to be some sort of randomness added in... And that "aggression" factor is the perfect tool for that... You could also throw in other deciding variables like "desperation" for the extreme case of a desperately losing battle (making those fireballs much less likely... want to save as many friendly units as possible, now don't we? lol)...or at the opposite end of the spectrum "cockiness" (or something along those lines... making fireballs much more common...even if it means wiping out whole platoons... because, hey...you can spare them...lol)
In response to SuperSaiyanGokuX
You could even make them learn if you wanted. They might be able to learn certain battle techniques by surviving a battle where they saw and learned the technique. Then you'd be in trouble if you let one survive too many battles because then it'd be smarter than you and ultimently kill your sorry ass for letting it live.
In response to Nadrew
Nadrew wrote:
You could even make them learn if you wanted. They might be able to learn certain battle techniques by surviving a battle where they saw and learned the technique. Then you'd be in trouble if you let one survive too many battles because then it'd be smarter than you and ultimently kill your sorry ass for letting it live.

Er, well, learning AIs are more powerful, yes, but then characters can do wacky things and the AI will adapt to them. Once the AI is thoroughly convinced that the player will try their pointless offense, then they could try performing their normal strategy -- the AI would be confused and easily beaten. A normal player would know that the player was trying to confuse them and simply crush them. =P

Teaching AIs to learn is a generally difficult venture, both programming-wise and design-wise, since you need to plan out how you want the AI to learn, what you want the AI to learn, what to do when it learns that, and so on. I'd recommend a finite-state AI (do that if this happened, else do this if that happened, else do that if this happened), or even a simple AI script (do this, do that, do this, do that), for now -- you can move onto the bigger stuff later. =)
In response to Spuzzum
That's why you make them smart and make them learn from players that kill off their friends.
In response to Spuzzum
Considering games like Warcraft 2, I think it was easy enough to design AI that'd crush most players to begin with. Doesn't matter how smart they are :oP If the computer has 20 units when you're getting you 6th, you're in trouble.
In response to Foomer
True, but you're forgetting that the Warcraft II AI only holds the advantage if you go slower than it. If you go at the same speed, it doesn't stand a chance.

It has the advantage that it doesn't actually have to input its commands. It just does what it wants to do. However, as history has seen, some of the best players of Starcraft can make their towns more efficient, billions of times faster than the computer can.
In response to Spuzzum
Well, consider this:

Dumb AI is for unskilled players.
Smart AI is for medium-skill players.
Humans are for highly-skilled players.
In response to Foomer
Foomer wrote:
Well, consider this:

Dumb AI is for unskilled players.
Smart AI is for medium-skill players.
Humans are for highly-skilled players.

Whoa, now that's a good statement. If I even tried to disagree, I would kill myself.
In response to Spuzzum
Spuzzum wrote:
Foomer wrote:
Well, consider this:

Dumb AI is for unskilled players.
Smart AI is for medium-skill players.
Humans are for highly-skilled players.

Whoa, now that's a good statement. If I even tried to disagree, I would kill myself.


I agree!
In response to Nadrew
I fourth that statement...

And this is why we call it "Artificial Intelligence"... We're trying to do our best to mimic "Actual Intelligence"...which can only be truly given by a human being...

Which is why the goal of any AI should be to act in any situation in the way that a human would...
In response to Foomer
Foomer wrote:
Considering games like Warcraft 2, I think it was easy enough to design AI that'd crush most players to begin with. Doesn't matter how smart they are :oP If the computer has 20 units when you're getting you 6th, you're in trouble.

There are more advanced things you can do reasonably easily than just make the AI build units efficiently...

Anyway on the subject of WarCraft 2, I just got this recently and have been playing with a friend. We tried coop against the computer, and found that if it's a pure-land game, the computer frequently builds quickly and comes and stomps one of us (especially if there are 2 since they will work together).

But...if it's a mixed land/water game, the computer often does very badly. We easily beat 2 computer opponents because they spent most of their time building up large navies...only problem being, on that map the water was just for decoration and wouldn't actually let them get anywhere.

So I'd recommend a simple game structure that will allow you to make a better AI.

[edit]
Come to think of it, this is probably why StarCraft doesn't have water units and doesn't, at least in the maps I played, use outer space as a factor in multiplayer games.