TAI :: pt1 basic principles

TAI :: pt1 basic principles

Various things about Spring that do not fit in any of the other forums listed below, including forum rules.

Moderator: Moderators

Post Reply
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

TAI :: pt1 basic principles

Post by AF »

I was continuing with this and people where going on about thigns I ahd already written or felt where un-needed. So I rewrote what I'd done so far in parts to Address this. I'll release what I've thought through in installments rather than in one big go. As you will see I do nto think that an offensive and defencive overlay are needed afterrall they are rpetty much what the threat and strategic overlay where suggested for in the first place.

Before I start: The AI wants to lower Threat values while icnreasing the threat of ones own units. It wants to defend areas of high strategic value and lower threat values in these areas. Hence the AI wants a map of very high strategic values and very low threat values. It builds in low threat high strategic values and builds defences in high strategic and threat areas.



TAI
Part 1 General: The Agents and Basic principles

This AI uses agents that control certain aspects of the AI├óÔé¼Ôäós responsibilities or serve other agents to produce an AI that relies upon the general threats and values of what it has and what it does not have.

Threat and Strategic Overlays

I suggest a Grid Composed of Sectors, each with sub sectors. A sector would be 1024x860 hence a full screen in most games. Sub sectors would be the size of krogoth gantries.

Strategic and threat values are to be calculated every time they are requested and not every so often therefore there will be no overall arrays of values for strategic and threat values.

However, more than just these values are needed.

So I shall now define the following general functions to which I may add later on. Also note that the actual merging and unmerging of grid sectors for these functions and their calculations are provided not by the AI but the layer between the AI and the engine itself. These functions are a guide as to what I think the AI should deal with and that most other values can be derived from these. Anything that cannot be derived is simply unneeded by the AI, however when later on I say some Agents deal with particular units in a group then there is where new functions will be needed

Code: Select all

Threatval(int sector, int subsect)
Returns an integer value specifying threat value

StratVal(int Sector, int SubSect)
Returns an integer value specifying strategic value

UnitNum(int Sector, intSubSect)
Returns integer specifying how many units in that sub/sector

TerrainType(int Sector, intSubSect)
Returns a Terrain data structure with Height information and flatness.
Struct Terrain{
Int AvHeight
Int Flatness
}

SectBuilds(int Sector, intSubSect)
Returns a Boolean specifying whether there├óÔé¼Ôäós a building present at that location.

SectOwner(int Sector, intSubSect)
Returns an integer specifying the player number of the player who owns that sector. Note: 0 is unknown and ├óÔé¼ÔÇ£1 is contested/draw

SectFire(int Sector, intSubSect)
Returns an integer showing how many firing units in that sector.

AirNum(int Sector, intSubSect)
An Integer, showing how many airborne units are in that sector

GroundNum(int Sector, intSubSect)
Same as above but with ground units

HoverNum(int Sector, intSubSect)
Same as above but with hovercraft and amphibious units

SeaNum(int Sector, intSubSect)
And again but with ships

SubNum(int Sector, intSubSect)
And with submarines

ConstNum(int Sector, intSubSect)
And with construction units

Special(int Sector, intSubSect)
And again but with anything that doesn├óÔé¼Ôäót fit
The AI will deal with it├óÔé¼Ôäós own units as groups and anything else as sectors and threats.
The AI will not attack a unit or a building but rather it will tell an agent to attack the contents of a sector. That Agent will then select another Agent to carry out the attack giving it control of groups and factory groups if required.

Unit Groups.


Unlike the layer who selects large masses of troops for groups or special units, the AI will put everything into a group. The commander will have its own group, solar collectors have a shared group, and a particular swarm of units will be a group. Agents control groups. The AI will not reference a single unit; rather to do that the single unit would need to occupy a group by itself.

Rather than define functions for these unit groups I believe that they should purely be the domains of Agents. However one or two are required in conjunction with sectors.

Code: Select all

CalcThreat(int GroupID)
Calculates the threat of a unit group.

CalcStart(int GroupID)
Same but with strategic value

LocateGRP(int GroupID)
Returns the Sector + sub sector of the centre of the unit group

GRPSector(int Sector, int SubSect)
Returns the GroupID of the group in that sector if there is one

GRPNumSect(int Sector, int SubSect)
Returns the number of groups in that sector.
Agents
So now I will deal with my basic concept of how agents will work.

There will be:

Control Agents //make overall decisions such as we need to attack that player, we need to attack this nearby area, we need to stop those forces or we need more forces
Decision Agents // These Take those general wants from the control agents and find a way of doing them, they choose other agents and actually handle the processes of what they should build.
Slave Agents //These actually dothe unit per unit hard work.
Service Agents //These provide services such as information and processing

So lets deal with building

There will be a general building agent. Lets say the agent that monitors resources says that it needs more energy, suggesting fusions as the best answer. So the building Agent will take a unit group for the task base don how high a priority it is and it finds an area low in metal but with good defences and flat terrain. Then it hands the unit group and the fusion orders over to a new Agent, which will query the target area for grids to build in (sub sectors with no buildings in them. Then it will take its Unit group and query a movement Agent as to whether those units can reach the target destination receiving a yes or no. If yes then the Agent hands the unit group over to another movement agent giving ti a starting location and a finishing location. This agent moves them across using transports or whatever its programmed to do to get them there, possibly launching build queries for transport units or bridge units (zwzsg) for movement. When this agent is done it returns control and the Agent assigned to build those fusions starts micro managing the construction unit group unit by unit to build the fusion.

Lets say an attack is to be launched against sector 5 and sector 5 has a threat value of 7000 and an attack has been force of threat 5000 has been formed and assigned to an Agent. That Agent would then query the build agent for extra forces. The build agent may build a factory and use that for all further requests for such units, but otherwise it will queue up the units based on priority or wait till ti can build them or return a No to the attack agent which would then mean a fail for that Agent meaning an agent re-assignment so that another agent that requires less unit threat value overall can attack or the merging of unit groups, which would be done by the agent that chooses the agents that carry out attacks themselves.

Agents would be programs in themselves, they could be ran on different systems making up an AI that had no central location on which to lag and expanding scalability without sacrificing engine speed.. Tactics and strategies could be made in the form of hacks of agents, possibly an agent could be nothing but a script in a sandbox type interface such as java, or possibly a human being depending on the nature of the Agents function and the interfaces between the engine and the AI.

Agents such as those that take on attacks and defences themselves rather than decision making agents would return a success or fail value. These values would be totted up as a total success or fail rate used to judge the effectiveness of that tactic. These rates would have a value for each player encountered by the AI, building up a picture of the players├óÔé¼Ôäó strong and weak points.
This could all lead to a single AI that acts for every skirmish game in progress for those connected that makes simple judgements based on past events as a whole learning from each and every player. Perhaps all you have on your system is an engine interface and network Agent to route commands from agents on other systems.

But that├óÔé¼Ôäós way off, we still have to finish agents themselves.

Threat agents

Event Agents // Deal with events from the map and deciding how to react such as player 2 attacking, which would mean tell attack agent to attack those sectors or defence agents

Build Agents // Determine whether something should be built and what by and when.
Resource Agents // Determining what is needed and what would solve the shortage to maximise production.

Construction Agents // Give them a unit/building and a general area and they├óÔé¼Ôäóll build.
Factory Agents // Give them a unit to build and a GroupID target for the built unit.
Attack Agents // Dealing with attack forces

Defence build Agents //Building defences

Exploration Agents //asking for scouts and radar towers targeting facilities and jammers to be built and controlling scouts to explore and extend LOS aswell as setting patrols for scouts. Possibly, the use of stealth and spying.

WMD Agents //construction and use of WMD such as berthas intimidators buzz saws etcGroup Agents //creation merging of groups and the addition and movement of units within and between them.

Map Agents //Terrain Deformation tree reclamation etc
Movement +Transport Agents //can unit go there? Transports lasting away paths in a hillside. Building dragon teeth.

An Agent for everything that the AI would do, and then agents to decide on when and where they should be done.

So what should these Agents be aiming to do to full fill their job as the game AI? Well I believe that adherence to the Chinese military Treatise Sun Tzu├óÔé¼Ôäós the art of war would be a very good starting place. After all an AI in touch with the Tao however far the Tao is from warfare would be.

The good thing about Agents is if you don├óÔé¼Ôäót like how one is implemented and have a better idea then rewrite it! As long as it can receive and send the required commands from the other agents I don├óÔé¼Ôäót see why not. Infact why not recreate every single Agent with a new interface if you don├óÔé¼Ôäót like it? Or create abstraction layers for new engines or what not, all you├óÔé¼Ôäód need for a en game would be changes for features that aren├óÔé¼Ôäót supported and a brand new AI engine interaction layer but the agents would still work.

In the next installments of my TAI series I shall talk through the Agents themselves, or maybe something else I havent exactly decided which yet perhaps you could start posting on how these would work and the logic behind them. Note I am leaving strategies towards the end since that├óÔé¼Ôäós a variable subject where Agents would be created continuously and improved and added to over a long time as players outplay the new strategies.
User avatar
Triaxx2
Posts: 422
Joined: 29 Aug 2004, 22:24

Post by Triaxx2 »

I'll grant that you have massive control with this AI, but I don't see any kind of command structure. At the same time there is no oversight. Building fusions is great, unless you don't have the resources to do it. And what if the simplest solution is to stop producing a few units, and wait until you finish the Fusion. This AI is going to be very aggressive, and that's going to be it's trap.

At the same time, the differences in damage detection will cause it's own set of difficulties in controlling units as a group. I'm telling you they're going to end up they're own worst enemy. A Zipper will be able to cause them to wipe themselves out as the weapons destroy each other, and then the Zipper can wait until only one unit is left. As for the argument that a Zippers threat value wouldn't trigger the AI, it can be argued first that a non-cheating AI wouldn't be able to tell a Zipper from a Krogoth, and a cheating AI could be fooled by simply laying down other units to pump up the threat value, until the Zipper can crush the units sent to respond, and then the attack force sweeps in and crushes the base.

Another example, is the surround and pound method of attacking an AI. A real player will recognize what is going on, and strike out against the bases that are launching the attacks. The AI, even one as intelligent as this is still going to try and fight it's way one sector at a time outwards, while the bases continue to mass produce the the units against it. Unless you have a solution for that later on.

I personally, don't see how this is going to be any more effective than the OTA AI was, but I can't see the whole picture yet.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

An AI should eb able to keep you on your toes anyways hence agressiveness but I see your point with resources. Hence the reson I split construction up ebtween different types of Agents instead of pulling them all together. Something needs to eb built says Agent A, Agent A tells construction Agent. Construction Agent has a list of whats building and hwo much it's using and wether it can afford to build it. If ti can afford to build it then add it to a queue and build whichever ahs the highest priority in the queue then start from the beginning. If there arent enough resources, check to see if any buildings in progress can eb cancelled that are of lower priority than the request, if so check how long till they're doen and if thats smaller than 40% of the buildtime of the requested construction then keep ti going then build when it's finished, if nto cancel the build and start the requested construction. If still excess resources to build everythign in the queue and have room to spare then query construction unit groups for idle workers and assign idle groups to help.

As for your zippers, Listen carefully I will re-iterate what I said.

The AI commands an Agent to attack a Sector or subsector, hence the Agent will attack what is currently in that sector and the surrounding sectors. How and what ti atatcks however is nto upto the overral AI because that attack is now udner the control fo an Agent that has been built for that type of attack using a tactic or strategy the programmer has defined with variations based on whats happened. Zippers will nto attack and thus destroy eachover by friendly fire or any fo thsoe sorts because that would be seen as bad programmign on behalf of the person who programmed that agent. This agent is nto liek the rest. Agents that deal with the micro management of actual units wether it be ending them from one place to another, controlling construction units as in starting a build then placing them around the build startign them nanolathing or attacking, target this fire weapon etc they do nto deal with sectors ro groups in generalised terms like the overrall AI btu rather in unit by unit specifics dealign with unit references and positions and not sector or groups. It is in that agent that you can implement your method of handling an attack without friendly fire.

Also for that scenario you proposed perhaps a threat analysis routine int he decision agents that recognises that event and runs agents that where built and designed to foil such an attack? Perhaps it could make extensive use of the WMD Agents by giving them a sector to bombard and possibly a unit reference and a priority. Perhaps you could turn thsi into a porcupine player by Enhancing the defence Agents to recognise a type of unit attacking and build defences that the programmer has said are good against them, or pointing it to a file of unit names that a modder can add to.

Also Unit numbers arent the only factor in threat values, their armor and health aswell as their weapon fire rate, power, type and range.
Perhaps the building locations chosen by agents could assume an octopus style base.

And before anyone says, antimissile silos would be handled by the WMD agent or a sub agent under its control.

Also When I refer to health I do nto mean overrall health I mean overral health minus damage done so a zipper with 30/75 health will eb treated as if its health where 30 not 75
User avatar
Triaxx2
Posts: 422
Joined: 29 Aug 2004, 22:24

Post by Triaxx2 »

I see now. The threat analysis agent would be a very good idea. And I know simple numbers wouldn't be the only factor, but that wasn't the point of the argument. With those problems addressed, I don't see any further holes.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Actually how would you deal with preventing enemy fire? Perhaps I shall post another TAI thing but just outlining lots of examples of how scenarios would be enacted to get the idea across better, and feedback people feedback what do you think?!?!?! I cant rely on one person alone for feedback and opinions?!?!?!?!?!?!?
User avatar
Min3mat
Posts: 3455
Joined: 17 Nov 2004, 20:19

Post by Min3mat »

OK i am NOT a programmer or know ANYTHING anout programming none the less i think that 2 of these formulae could be improved:

SectOwner(int Sector, intSubSect)
what if the 'sector' is under a allies control? and is 1 meaning that the 'sector' is owned by the AI

TerrainType(int Sector, intSubSect
What happens if the terrain deforms? does the value change? will it use up a lot of resources? hills can form Line Of Fire problems for laser weapons etc. can u factor this in?

And what is this one for?
SectFire(int Sector, intSubSect)
Returns an integer showing how many firing units in that sector.

And will the AI forcefire WMD? bb and buzzsaws can be very useful if the player aims in front of units and keeps firing at that point, can u get the AI (for the PC only, players have force fire command right?) to aim projectiles at the right place at moving targets or mass fire at a sector if there are enough enemys in it?

just a couple of questions by a idiot! :)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

These are good questions btu they are questions that are answered not by the scope of this that I have posted btu by the question, how do I program an Agent itself? The AI would receive a player nubmer so if the AI owns sector 5 and the AI is player 2 then that function will return 2, it makes no difference for llies it's just the AI will lookup wetehr it is an ally before factorign in a decision.

Firing infront of untis and not at units for WMD would also eb an agent thing, perhaps a quick sum on the position of the target to produce the desired effect.

Showing wether there are units firing in a sector could lead to events, for example an AI may want to watch a battle from afar while amassing untis then once the battle has seemingly ended it swarms ina dn crushes the units remaining and reducing the threat. Or it could eb a useful way fo gaging which sector in an attack si posing th greatest threat by seeing which one has the firing units. Hence a huge threat that sits idly is nto as bgi a problem as a medium threat that is actively attacking you.
And yes when the terrain chanegs the values change
K-man
Posts: 27
Joined: 18 Aug 2004, 18:30

Post by K-man »

May I have a few lines on this?

Actually, I think Triaxx2 are pointing out your main problem; You are isolating and seperating -too- much, losing the overview and communication.

Many of your 'agents' will need a extensive amount of information about the worlds' state to be able to make good decisions, and also communicate it's ideas with other parts of the AI (or risk getting in conflict with those parts). This means that either you will have to deny these 'agents' this needed informtion, or you will end up with extensive interfaces and lots and lots of redudant calculations.

Think yourself into the position of one of your 'agents', and what info you - as a player - would like to know to come up with the requested decision. Being limited into a very, very small area of power, with minimalistic information, you would probably just die of frustration... (Or possibly end up in spending all your time involved in byrocratic discussions with your partners.)

You seem to enjoy the philosophy "I split it - you implement it!".

A software architecture are to implementers what hardware are to programmers; A good hardware have already solved most know problems, greatly simplifying the software development. While a over-simplified/optimized hardware are a hell for the programmers...

You need to look at it from both directions to find out a good balance, balancing out the problems between all parts of the project - not only the implementers.
User avatar
Triaxx2
Posts: 422
Joined: 29 Aug 2004, 22:24

Post by Triaxx2 »

I'm glad to see I'm not alone in my assessment. I agree with parts of his idea's, but it's overall too complex to work. I won't pump my own idea in his topic anymore, since I'm still trying to work around a single large bug in it, but I'll do my own Topic later.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

On the contrary, I have not taken the "i think it you implement it idea" This si part 1 and I have sene flaws other than those pointed out by looking at triaxx2's proposals by simply looking at dragonteeth and th building system. However I also said that what i ahve put so far is limited to what I see needed at this point in time and stated that i would add mroe functions later as and when I thought I needed them. Afterrall how will a strategy Agent dealing with unit by unit commands and directions be able to use group absed functions to get information about single units? It makes no sense to do that lol. However I think that I have actually proposed an architecture for the AI and the only other such thing said in these forums was SSAI which I'm hoping I stuck on my HD somewhere for reference. Which means I have ammendments to make on part 1 to be put in part 2 aswell as the stuff I was gonna stick in there.

I still think 5 overlays is too much though and would only consider the possibility fo adding a 3rd overlay for the moment as a temporary solution to the small build footprint problem with my proposals.

In the mean time try and list as many things an Agent or Agents would need about the world, I'm bound to miss things if I think of them all myself

And thanks for the input, I'll keep in mind how I'll implement such an AI aswella s how ti works more than I have done already.
User avatar
Triaxx2
Posts: 422
Joined: 29 Aug 2004, 22:24

Post by Triaxx2 »

I admit five is a touch excessive, but it eliminates the need for excessive processing and trying to co-ordinate between a massive number of AI agents. I'll give you mine has flaws as well, but I'm not a programmer and don't pretend to be. I've tried it, but I can't do it. That's why I rely on other people to tell me what isn't going to work.

A Build Agent will require:

Total Resources incoming
Total Resources in use
Status of all projects in progress
List of all projects in cue
List of all Factories, with projects in cue.

A Resource AI needs to know:

Total Resources incoming
Total Resources in use
Status of all Con units
Status of al Con unit order cues IE, if it's not busy now, will it be when I need it?
And Scout information reporting the locations of metal deposits.

Attack Agents need:

Average Health of attack group
Average Firepower of attack group
Average Health of enemy group
Average Firepower of enemy group
Probable location of enemy units in relation to travel of attack group IE, If it goes left, will it encounter the enemy? If it goes right, will it encounter the enemy?

That the kind of thing you wanted?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

yah thats more like what the AI agents need to knwo and what they'll eb sending eachover btu firstly I should reiterate how the Agents work which si sorta what part 2 was gonna be.

For example a build agent wouldnt know how much resources there are and wouldnt care because a build agent would request that a building be built and wouldnt deal with the decisiona ltho someone might program a new build agent that uses resources to increase the likelihood fo it's query being accepted.

Construction is nto particularly controlled by any agent in particular in terms fo what should eb built, rather it is requested by any agent in question, an attack agent may request forces be built for it's groups or a resource agent may request fusions and mexes be built.

Thus there is a central Construction Agent that makes decisions, it acts as a service to the other agents, agents say they want this or that, then they get a reply sayign eys or no, if yes then this service agent tells a slave agent that ti wants these built and that they're to be sent to here (building location ro unit group)

So a construction agent would use resource information such as how much si beign produced and what is being produced fi they should eb cancelled to make way, wether we should wait for it to happen or wetehr it's nto possible at this time, and if it is then a command is sent to an Agent giving it control of a unit group of construction untis and a task, such as build one of these here. That agent would then handle the nitty gritty action by action such as find building location, mvoe unit here then here thn here then start building then open nanolathes then start etc. Then the building or unit would be handed back to the original Agent that requested it.

In All sense this is a co-operative AI. Take away one agent and the others cant continue, so it is not fully seperated. Each AI agent is a component of the whole thing. Also a command Agent or agents will be neeeded for Directing attack and overral AI strategies and not unit by unit strategies. Afterrall every Nation has it's leader
Post Reply

Return to “General Discussion”