What does AI need to do?
This is kind of a programming question, but since I''m not delving into actual code implementation I figure it might go better here. If AI is missing certain features, then I think it would make for less fun gameplay, but on the other hand, frivolous or unnecessary features will just increase development, possibly introduce more bugs, and possibly slow down gameplay.
What I''m asking is, what Object data (state) and methods must the AI have in order to be effective? Also, what are the interfaces needed to have AI objects "talk" and interact with other objects? Mind you, I''m specifically looking for AI involved in strategy games, but alot of this could be effective in a wide range of areas.
Unfortunately I don''t have a flow chart or anything, or a UML capable diagram (man, I need to learn Linux''s Dia...I don''t want to shell out for Visio or worse Ration Rose) Here''s my short list so far:
1) Awareness: This includes environmental awareness and sensory abilities. For example, looking at terrain and seeing the best waypoints or chokepoints.
2) Assessment: The ability to analyze other objects. Mainly this is threat assesment to ascertain whether something is dangerous or benign
3) Prioritization: Once assesment is made, the ability to prioritize actions.
4) Analysis: This is the "planning" stage where the AI determines the best course of action to take based on the above 3 factors, as well as an initial State data....the orders given to the AI.
5) Communication: The AI must now communicate its intentions to enact a behavior based on the Analysis phase. If the AI does not control any other objects, then this can be the Implementation phase in which actions are carried out
I think the AI should then have a Feedback phase, where it looks at its actions, and sees whether they were effective or not, thereby introducing learning into the loop.
Since I''m not really a programmer, much less an AI specialist, is this basically about how programmers implement AI? This seems like a basic enough AI logic flowchart, although each of the phases has to be explored more thoroughly.
The world has achieved brilliance without wisdom, power without conscience. Ours is a world of nuclear giants and ethical infants. We know more about war than we know about peace, more about killing than we know about living. We have grasped the mystery of the atom and rejected the Sermon on the Mount." - General Omar Bradley
Hmm I strongly suspect that the breakdown of game AI doesn''t follow any standard pattern. It depends a lot on the particular game, and also on the kind of AI player one wants to end up with. Some AIs are as simple as a combination of 2 and 5. Introducing learning would be great, but I don''t know of a strategy game that has done that, so I''m guessing it''s not easy.
Bear in mind that strong AI in strategy games is a rarity, so people evidently haven''t found the best way to develop it. Your algorithm sounds as good as any.
Bear in mind that strong AI in strategy games is a rarity, so people evidently haven''t found the best way to develop it. Your algorithm sounds as good as any.
I think the question is a bit too broad. You could probably break it down to just:
- Awareness
- Planning
- Execution
Which could be as simple as IF enemy_is_near THEN approach_enemy.
I think you''ll find that most game AI systems don''t bother with prioritisation, and that they instead just pick the one action deemed best at this point in time. The situation tends to change sufficiently quickly that it''s worth recalculating all options after each one is completed. That said, I believe some games have prescribed ''opening moves'', somewhat akin to Chess, where they know which buildings they need in which order, and so on.
I would also guess that most AIs won''t have feedback loops once the game ships, as this runs the risk of them becoming too good (or too poor, in certain conditions) over time, which is no fun. It might be feasible and interesting to have such a loop on a per-mission or per-campaign basis, though.
It also depends what you mean by ''effective''. Often there are 2 aims for game AI, which are potentially conflicting - to make a challenging opponent, and to make a realistic/humanlike opponent.
To give you a vague answer, I think the most important element in whether your AI is effective or not is in your knowledge representation method. The holy grail for any project is to find some sort of representation that is faithful to both the real world domain that you''re modelling and the computer''s implementation of the various algorithms.
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions ]
- Awareness
- Planning
- Execution
Which could be as simple as IF enemy_is_near THEN approach_enemy.
I think you''ll find that most game AI systems don''t bother with prioritisation, and that they instead just pick the one action deemed best at this point in time. The situation tends to change sufficiently quickly that it''s worth recalculating all options after each one is completed. That said, I believe some games have prescribed ''opening moves'', somewhat akin to Chess, where they know which buildings they need in which order, and so on.
I would also guess that most AIs won''t have feedback loops once the game ships, as this runs the risk of them becoming too good (or too poor, in certain conditions) over time, which is no fun. It might be feasible and interesting to have such a loop on a per-mission or per-campaign basis, though.
It also depends what you mean by ''effective''. Often there are 2 aims for game AI, which are potentially conflicting - to make a challenging opponent, and to make a realistic/humanlike opponent.
To give you a vague answer, I think the most important element in whether your AI is effective or not is in your knowledge representation method. The holy grail for any project is to find some sort of representation that is faithful to both the real world domain that you''re modelling and the computer''s implementation of the various algorithms.
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions ]
quote: Original post by Kylotan
It also depends what you mean by ''effective''. Often there are 2 aims for game AI, which are potentially conflicting - to make a challenging opponent, and to make a realistic/humanlike opponent.
If the intent is to produce simulations for academic study or research purposes, then I think I
would agree with your suggested aims, but in computer game AI, entertainment is the goal .
Perhaps the aim of creating an entertaining opponent is in conflict with all of the above?
A computer game AI opponent that is entertaining, does not have to be challenging to all players
of the game to be considered entertaining. Likewise, realistic and humanlike computer game AI
opponents are not always entertaining. An example: the AI in Empire Earth is extremely
entertaining to me, a long time RTS and Strategy game player, however it really presents no real
challenge for me to beat it. Despite the fact that it fails as a challenging or realistic or humanlike
opponent for me, it overwelmingly succeeds as being entertaining. I have no doubt that the EE
AI could be modified to the point that it would be impossible for me to beat it, and at that point,
I doubt that it would be anywhere near as entertaining as it is now.
IMHO, we (as computer game AI developers) should always remember, that our goal is to entertain
the most players possible with the behavior of our AI. That has less to do with challenge, realism
or humanlike qualities than it does with the elusive fun factor.
Eric
quote: Original post by Geta
That has less to do with challenge, realism or humanlike qualities than it does with the elusive fun factor.
I whole-heartedly agree!
Timkin
Kylotan-
But simple if else structures or even switches can''t really handle lots of decision making events. Most decision making code assumes a conditional statement that the AI agent must already have knowledge of. Also what happens when the survival needs of a unit come in conflict with orders it is given? If you have some kind of self-preservation rule implemented with AI agents, then things get very tricky. You have to be able to code the AI so that it has a set of autonomous action, but also a set of delegated orders. Sometimes these two can come into conflict. I hate playing flight simulator games with wingmen whom you order to do something hoping that they will have sense enough to live long enough to carry out their orders to the best of their ability....but they end up dying almost immediately because your order cancelled out any sort of self-preservation instinct. On the other hand, the self-preservation instinct could override orders issued....which is actually exactly what I want and others may hate.
Also, what do you do when an AI agent is faced with a problem or a data object that it has not encountered before? Without pre hardwired information, how does it make an assessment? And without a prioritization phase, what if some events occur with a greater importance, but a few miliseconds later?
Let me see if I can think of a concrete example....
Let''s say that you have a tank company nestled hull down with two companies of infantry nearby for support. Along comes a company of mechanized infantry riding in Infantry Fighting Vehicles. The tank company has no outstanding orders from the player and it looks like an easy target, so tank company looks at code and says,
//pseudocode
switch
case OrderToken=True //has unit been issued an order?
if EnemyStrength > UnitStrength && OrderPriority=0
SelfPreservationRoutine();
if EnemyStrength > UnitStrength && OrderPriority > 0
//this is where threat assesment and balancing order vs. preservation come in
else CArryOutOrder;
case OrderToken=False
if EnemyStrength <= UnitStrength
Attack();
else Retreat();
Obviously this is very simple, and there''s alot more to the function calls than this. You could for example make the Retreat() call be one of several types depending on the severity of the odds. Also, I didn''t factor in morale, unit quality or Commander quality at all. This is really just a decision loop.
But hopefully you see what I mean by needing to have an assesment of whether a unit has enough force to achieve its objective as well as determine whether its orders outweigh its instinct to live.
But simple if else structures or even switches can''t really handle lots of decision making events. Most decision making code assumes a conditional statement that the AI agent must already have knowledge of. Also what happens when the survival needs of a unit come in conflict with orders it is given? If you have some kind of self-preservation rule implemented with AI agents, then things get very tricky. You have to be able to code the AI so that it has a set of autonomous action, but also a set of delegated orders. Sometimes these two can come into conflict. I hate playing flight simulator games with wingmen whom you order to do something hoping that they will have sense enough to live long enough to carry out their orders to the best of their ability....but they end up dying almost immediately because your order cancelled out any sort of self-preservation instinct. On the other hand, the self-preservation instinct could override orders issued....which is actually exactly what I want and others may hate.
Also, what do you do when an AI agent is faced with a problem or a data object that it has not encountered before? Without pre hardwired information, how does it make an assessment? And without a prioritization phase, what if some events occur with a greater importance, but a few miliseconds later?
Let me see if I can think of a concrete example....
Let''s say that you have a tank company nestled hull down with two companies of infantry nearby for support. Along comes a company of mechanized infantry riding in Infantry Fighting Vehicles. The tank company has no outstanding orders from the player and it looks like an easy target, so tank company looks at code and says,
//pseudocode
switch
case OrderToken=True //has unit been issued an order?
if EnemyStrength > UnitStrength && OrderPriority=0
SelfPreservationRoutine();
if EnemyStrength > UnitStrength && OrderPriority > 0
//this is where threat assesment and balancing order vs. preservation come in
else CArryOutOrder;
case OrderToken=False
if EnemyStrength <= UnitStrength
Attack();
else Retreat();
Obviously this is very simple, and there''s alot more to the function calls than this. You could for example make the Retreat() call be one of several types depending on the severity of the odds. Also, I didn''t factor in morale, unit quality or Commander quality at all. This is really just a decision loop.
But hopefully you see what I mean by needing to have an assesment of whether a unit has enough force to achieve its objective as well as determine whether its orders outweigh its instinct to live.
The world has achieved brilliance without wisdom, power without conscience. Ours is a world of nuclear giants and ethical infants. We know more about war than we know about peace, more about killing than we know about living. We have grasped the mystery of the atom and rejected the Sermon on the Mount." - General Omar Bradley
Geta - you're right, I suppose entertainment could be a separate issue, although that was what I meant by the 'humanlike' AI, which would be designed to seem believable and thus immerse the player more.
Dauntless:
Sure they can - you just need enough of them. On a limited precision system such as a digital computer, even seemingly continuous domains can be reduced to discrete values, which in turn means you can make binary decisions at each stage.
That is being overly pedantic, as we both know, but all I am saying is that it's possible to reduce things down that far and still be 'effective'. The only cost here is developer time, and that is the tradeoff you always have to make.
Having said all that, when I tried to ask a few weeks ago about using fuzzy logic to help with almost exactly this sort of thing, I couldn't find much help. And neither Google or Usenet helped much either. I'm waiting on a book to come into my local library as I reckon fuzzy logic could provide a good system for all this.
At a very simple level, you can order the if checks accordingly. And a small step up from that, you can weight the orders according to individual importance. This is pretty trivial and yet wholly consistent with almost all psychological models.
This should never happen. If it does, you're at least one level of abstraction away from where you really need to be.
I was not saying any of your points weren't useful or valid. But if you start talking about a short list of what is needed to be 'effective', then it gets very subjective and domain specific. There are numerous game AIs where prioritisation is hardly relevant, or is implicit in the state machine (ie. not explicitly handled). Perhaps we've got different ideas of what prioritisation means though: I was thinking of storing a list of future activities, whereas you seem to be thinking of state transition thresholds.
Quick hint from the programming angle, based on looking at your code: to make your system more abstract, rather than thinking along the lines of orders or no orders, you could try working with 'default orders'. That way, every action comes from an order and you can structure it all in the same way.
Oh, and if you use a formula like "risk = EnemyStrength / UnitStrength" then you can compare that directly against some sort of order priority.
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions ]
[edited by - Kylotan on April 15, 2002 8:23:21 AM]
Dauntless:
quote: But simple if else structures or even switches can't really handle lots of decision making events.
Sure they can - you just need enough of them. On a limited precision system such as a digital computer, even seemingly continuous domains can be reduced to discrete values, which in turn means you can make binary decisions at each stage.
That is being overly pedantic, as we both know, but all I am saying is that it's possible to reduce things down that far and still be 'effective'. The only cost here is developer time, and that is the tradeoff you always have to make.
Having said all that, when I tried to ask a few weeks ago about using fuzzy logic to help with almost exactly this sort of thing, I couldn't find much help. And neither Google or Usenet helped much either. I'm waiting on a book to come into my local library as I reckon fuzzy logic could provide a good system for all this.
quote: Also what happens when the survival needs of a unit come in conflict with orders it is given?
At a very simple level, you can order the if checks accordingly. And a small step up from that, you can weight the orders according to individual importance. This is pretty trivial and yet wholly consistent with almost all psychological models.
quote: Also, what do you do when an AI agent is faced with a problem or a data object that it has not encountered before?
This should never happen. If it does, you're at least one level of abstraction away from where you really need to be.
quote: And without a prioritization phase, what if some events occur with a greater importance, but a few miliseconds later?
I was not saying any of your points weren't useful or valid. But if you start talking about a short list of what is needed to be 'effective', then it gets very subjective and domain specific. There are numerous game AIs where prioritisation is hardly relevant, or is implicit in the state machine (ie. not explicitly handled). Perhaps we've got different ideas of what prioritisation means though: I was thinking of storing a list of future activities, whereas you seem to be thinking of state transition thresholds.
Quick hint from the programming angle, based on looking at your code: to make your system more abstract, rather than thinking along the lines of orders or no orders, you could try working with 'default orders'. That way, every action comes from an order and you can structure it all in the same way.
Oh, and if you use a formula like "risk = EnemyStrength / UnitStrength" then you can compare that directly against some sort of order priority.
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions ]
[edited by - Kylotan on April 15, 2002 8:23:21 AM]
Kylotan: Mr Elusive''s paper on the Q3 bot may give you some tips on using fuzzy systems as you describe. He tweaks them using GAs which is a good idea.
You can find it here:
http://www.idsoftware.com/home/jan/q3abotai/
Stimulate
You can find it here:
http://www.idsoftware.com/home/jan/q3abotai/
Stimulate
My Website: ai-junkie.com | My Books: 'Programming Game AI by Example' & 'AI Techniques for Game Programming'
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement