Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Basic AI for turn-based AI (xcom-like) soldiers


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 suliman   Members   -  Reputation: 568

Like
0Likes
Like

Posted 24 October 2012 - 02:13 AM

Hi

Im planning a tactical turn-based squad game. Combat is similar to old xcom (time units is being spent to move, turn shoot etc).
8 vs 8 soldiers, gridbased maps. One team moves all soldiers, then opposing team moves all.

I need something like AI doing:

1. Positioning, use cover/walls depending on known position of hostiles (probably hardest to implement)
2. "Plan" usage of timeunits so doesnt end turn in exposed location
3. Pick suitable firemodes (snap shot, aim fire, full auto) depending on "situation"
4. Choose when/if to use special actions like throw grenade, crouch, heal teammates
5. Choose weather to run after enemies, stay put, scout for additional enemies when noone is visible etc.

To perfect this is VERY hard i know, but how do i go about making a acceptable system that gives a feeling of intelligence (or at least offers some resistance to the player)? Any guide? Where to start?

Thanks a lot
Erik

Sponsor:

#2 Delphawi   Members   -  Reputation: 235

Like
0Likes
Like

Posted 24 October 2012 - 08:18 AM

Hi suliman

I think your cases are too general and dividing them will help you to deal with them easily .
I will assume you have different soldier classes , just for clarification .

1. Positioning, use cover/walls depending on known position of hostiles (probably hardest to implement)

That depends on many things :
Is the teammate taking/not taking fire ?
Heavy soldiers prefer close cover , Snipers prefer far ones .
Is the teammate injured ? if so he will need to take the closest cover to the medic .
Choosing High areas to expose as many enemies as possible .
Choosing Hidden areas to make surprising attacks .

2. "Plan" usage of timeunits so doesnt end turn in exposed location

You must prioritize your conditions (time , safety , superiority , close / far ... etc) , that will help you determine which position to choose for every situation .

3. Pick suitable firemodes (snap shot, aim fire, full auto) depending on "situation"

That will depend on how far is the your soldier , armored/weak enemies , covered / exposed ...

4. Choose when/if to use special actions like throw grenade, crouch, heal teammates

I think of something like :
Fighting group of enemies ? -> They are far ? -> Throw grenade , They are close ? -> open heavy fire .
Going to positions A ? -> Crouch if that will help you hide from enemy's sight , getting to narrow areas or when getting behind cover ...
Check for close teammates ? -> if no one injured -> check for far ones , if a close teammate is injured go help him . Here you will have to make the other teammate come closer to the healer as well as the healer will go closer to him (if possible) . Also you must make conditions about who will get treated first (closer first or critically injured first ...)


5. Choose weather to run after enemies, stay put, scout for additional enemies when noone is visible etc.

mmm , I suppose chasing enemies will be better if the team is in superior condition , if not then they will have to retreat instead .
Staying will be preferred if you want to ambush the enemy when he comes to your area , or to hide from scouts .
Scout for enemies while your team is recovering from a fight for example , so you can get ready as early as possible .

There are so many conditions and variables here , I think you'd better play XCOM for some more time and try to draw a tree or something to define the situations and actions .

Good luck Posted Image

Edited by Delphawi, 24 October 2012 - 08:20 AM.


#3 TechnoGoth   Crossbones+   -  Reputation: 2787

Like
0Likes
Like

Posted 24 October 2012 - 10:33 AM

I'd suggest looking into Goal Oriented Action Planning and starting small. For phase 1 try working with perfect knowledge so the AI know everything and build a Kill Nearest Weakest plan.

For this plan you'll want to
  • Move a unit so that at end of turn it is in cover and can attack the weakest target in range.
  • If it can't move to cover and attack in the same turn prioritize cover.
  • If already in cover and in range of weakest check if in optimal position and attack or move accordingly.
That should give you plenty to work through for initial iteration. After that's working and you've built your Tests around it then expand on it by adding greater depth and decision making. For example are the chances higher to kill the target if the unit moves to another position or to fire twice. Then move to other areas like adding different types of plans, new behaviours, optimizing, reducing AI knowledge, coordination between units, to the plans.

The're will be lots you'll need to do just with first iteration plan. You'll need to work out how to represent the data. How the planner will work. Implementing search algorithms or heat maps for placement of units. So keep it small testable and with room to expand.

#4 suliman   Members   -  Reputation: 568

Like
0Likes
Like

Posted 24 October 2012 - 02:46 PM

But when comparing different options should i work out some "point" system or how do i check priority, like:

In this soldiers situation right now (all this must be calculated every time a soldier needs to take a decision):
1. Moving to a certain cover is worth 45p (doesnt have cover +30p, close to good cover +15p)
2. Staying but firing at an enemy at 24 % hitchance is worth 33p
3. Scouting is worth 0 p (visible enemy closeby so this shouldnt be an option)

And then check, what do i "want" the most (in this case move to cover)?

#5 IADaveMark   Moderators   -  Reputation: 2512

Like
0Likes
Like

Posted 24 October 2012 - 03:03 PM

... and thusly was invoked the AI concept of "utility theory."
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#6 Delphawi   Members   -  Reputation: 235

Like
0Likes
Like

Posted 24 October 2012 - 03:03 PM

You must set a "weight" for every action , for example :
every hit taken = 3p , so if there is an enemy that could deal 10 hits , then getting to cover will save you 30 points .
every damage dealt = 2p , and for powerful enemies it will be 3p , 4p for medics ...etc .

Notice that there are special cases , like healing your last teammate is more important than dealing some damage (unless that damage is enough to kill the last enemy for example) , but you shouldn't worry about this for now :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS