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 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.
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.