views:

99

answers:

3

Hi All,

I would just like to know the various AI algorithms or logics used in arcade/strategy games for finding/selecting best target to attack for individual unit.

Because, I had to write an small AI logic, where their will be group of unit were attacked by an various tankers, so i am stuck in getting the better logic or algorithm for selecting an best target for unit to attack onto the tankers.

Data available are: Tanker position, range, hitpoints, damage.

please anybody know the best suitable algorithm/logic for solving this problem, respond early.

Thanks in advance, Ramanand.

+5  A: 

I'm going to express this in a perspective similar to RPG gamers:

What character would you bring down first in order to strike a crippling blow to the rest of your enemies? It would be common sense to bring down the healers of the party, as they can heal the rest of the team. Once the healers are gone, the team needs to use medicine - which is limited in supply - and once medicine is exhausted, the party is screwed.

Similar logic would apply to the tank program. In your AI, you need to figure out which tanks provide the most strength and support to the user's fleet, and eliminate them first. Don't focus on any other tanks unless they become critical in achieving their goal: Kill the strongest, most useful members of the group first.

So I'm going to break down what I feel is most likely pertains to the attributes of your tanks.

RANGE: Far range tanks can hit from a distance but have weak STRENGTH in their attacks.

TANKER POSITION: Closer tanks are faster tanks, but have less STRENGTH in their attacks.  Also low HITPOINTS because they're meant for SPEED, and not for DAMAGE.

TANKER HP: Higher HP means a slower-moving tank, as they're stronger.  But they won't be close to the front lines.

DAMAGE: Higher DAMAGE means a STRONGER tank with lots of HP, but SLOWER as well to move.

So if I were you, I'd focus first on the tanks that have the highest HP/strongest attacks, followed by the closest ones, and then worry about the ranged tanks - you can't do anything to them anyway until they move into your attack radius :P

And the algorithm would be pretty simple. if you have a list of tanks in a party, create a custom sort for them (using CompareTo) and sort the tanks by class with the highest possible HP to the top of the list, followed by tanks with their focus being speed, and then range.

And then go through each item in the list. If it is possible to attack Tank(0), attack. If not, go to Tank(1).

Jeffrey Kern
It all also depends on personal preference. You could also find the closest tanks to your own and attack them :P
Jeffrey Kern
Firstly Thanks a lot for your explained details.Now thing is in our case Tanks won't move they are fixed with various random HP, damage and range. so our unit has to and will move with limited fixed speed to attack the tanker.Our unit has fixed HP, range and damage can make.
Ramanand Bhat
Now my major goal is to achieve maximum win percentage for unit group( Total unit count = 10), and not to the tankers( total tanker count = 5), say for 1000 simulations 90% of the time Unit group need to win against the tankers.Your above mentioned approach of selecting first tank which has maximum HP for attacking and for next select rest of them will result into only 40% win percentage. And for selecting the tanker which is closest first, will result into 70% win.
Ramanand Bhat
So till now i haven't come-up with the best algorithm/logic that gives the Unit win percentage near to 90% over tank.If you have any thoughts or plans on above requirement, please share it with me.Thank you very much,Ramanand.
Ramanand Bhat
Well it all comes down to what your values and game design are. I am basing it off of how I would personally design a tank game - I didn't realize the tankers were fixed with random HP. I figured they could move and had static HP amounts. Are you trying to come up with a 90% win rate for each scenario? It might not be possible with your current scenario, 70% might be your best. Have you tried running different scenarios with the same algorithm?
Jeffrey Kern
Also - you said HP is randomly generated. Are the tank's initial values the same generated numbers each time a scenario is played out (e.g., Tank1 will always get 45 HP, Tank2 will get 59, etc.) or do they change with each simulation? If the values constantly change, that will affect the outcome of each battle.
Jeffrey Kern
Yes. These simulations are for the Test purpose, and not for the actual game scenario. So yes we have tried running different scenarios with the same algorithm result into 70% win rate when we tried to target nearby tank to attack first.Anyhow i have learnt that, each algorithm/logic are basically based on the our game data and requirement, their is no proper or straight forward logic available, we need discover our own.Thanks, your support is really appreciated.
Ramanand Bhat
+2  A: 

The goal is to attack only one opponent at a time and receive fire from at most one enemy at a time (though, preferably, none).

Ideally, you would attack the tanks by remaining behind cover and flanking them with surprise attacks. This allows you to destroy the tanks one at a time, while receiving no or little fire.

If you don't have cover, then you should use the enemy as cover. Move into a position that puts the enemy behind the enemy. This also improves your chance to hit.

You can also use range to reduce fire from multiple enemies. Retreat until you are only within range of one enemy.

If the enemies can all fire on you, you want to attack one target until it is no longer a threat, then move on to the next target. The goal is to reduce the amount of fire that you receive as quickly as possible.

If more than one enemy can fire on you at the same time, and you can choose your target, you should fire at the one that allows you to reduce the most amount of damage for the least cost. Simply divide the hit points by the damage, and attack the one with the smallest result. You should also figure in any other relevant stats. Range probably affects you and the enemy equally, but considering the ability to maneuver out of the way of fire, closer enemies are more harmful and should be given some weight in the calculation.

If moving decreases the likelihood of being hit, then you should keep moving, typically by circling your opponent to stay at their flank.

Team tactics would mostly include flanking and diversions.

What's the ammo situation, and is it possible to miss a stationary target?

Marcus Adams
+1  A: 
Eric
Tanks, Eric.We will look over both types of algorithms and get back to you, if any help needed. thanks again.
Ramanand Bhat