Some Specifics on Military AI
Here is my attempt to move the AI approach forward towards something specific enough to start coding. It ain't there yet! But I am burnt out, and thought I would post this in rough form to get initial responses and ideas. I have left out some of the communication mechanisms that will be needed between Plans of different levels. also, I've only gotten partway up the command chain...
First, a few notes, refining what has gone before:
When Objectives are complete, plan reports this fact to parent using a TBD mechanism
Names for now are just placeholders
Specific Plan Objects have the following:
(an object whose name is pluralized implies a collection of X)
Objectives - have a
* Name (for GUI use)
* arguments passed in that are used by getValue (FE how to assess value of a mil. unit)
* getValue method that takes some object of Game State after a simulation of the Actions, and returns a value that indicates level of success of the objective.
* isAchieved method that says whether objective has been satisfied
Resources - are Clash objects of various sorts. Commands, money, Characters...
Assumptions - (I'm having trouble specing this one out for the general case, will return to it later, and you can also see some specifics below. comments welcome!)
Actions - (again, tough to put in a general fashion, see specifics associatied with different Plan objects)
a ParentPlan (object of type Plan at higher level in the hierarchy)
ChildPlans (objects of type Plan at the same or lower level in the hierarchy)
Success -
* has a compareTo function per Gary's post
* group of success values. In simulation, a number of different success values can be obtained even given identical Actions, Child Plans, etc. This saving of success values allows for assesment of ranges of results likely, characerizing riskiness.
* success as an absolute measure, rather than compared to another plan (perhaps success measures should also have an opportunity cost for Resources used). This prevents the case where marching an army a long ways off to conquer something would be preferred to conquering something of slightly less value a lot closer to home, and then freeing up the troops. Thoughts?)
Now, the first specific Plan:
AttackAreaPlan (Attack and take one or more squares)
Objectives - TakeArea, AvoidTroopLoss, EnemyTroopLoss, AchieveByTurn
Resources - Commands
Assumptions - EnemyForces
Actions - MovementPath(s), Orders specifying when to fight and when not
a ParentPlan - SectorStrategy
ChildPlans (none for now)
Success
AttackAreaPlan Object Details
Objectives -
TakeArea - Secure control of an area that is a collection of MapSquares
* Name ("Conquer Silesia")
* area - collection of squares that define area to be conquered
* value of captured square per unit economic value (may need more refinement)
* strategic value of conquered squares(when map AI functional so strategic value can be better assessed)
* getValue sums econ and strategic value over all conquered squares. Or perhaps adds for all conquered and subtracts for any lost from starting area
* isAchieved method returns true when all of area defined is conquered.
AvoidTroopLoss
* Name ("Military Losses")
* arguments passed in that are used by getValue (FE how to assess value of a mil. unit. For now we should just use creation cost as a simplification)
* getValue calculates army cost-to-build after executing Action and subtracts initial
cost-to-build.
* isAchieved method (not sure this is needed here, since everything is 'shades of gray'. If we want to add another parameter that says anything more than X is unacceptable, then this method again makes sense in this context)
EnemyTroopLoss
virtually identical to AvoidTroopLoss
AchieveByTurn
* Name ("Turn 38" or "340BC")
* parameter(s) specifying how much early or late completion affects value
* getValue returns bonus for early completion, or penalty for late.
* isAchieved is straightforward
Resources - Commands used in attack plan
Assumptions - EnemyForces for now we should just weasel on this and let the AI see everywhere. Perhaps forces just outside area should be counted also.
Actions -
*Path(s) Just path or paths attackers will follow
*Orders specifying when to fight and when not. FE "don't attack at less than 2:1 odds". Also includes other orders like leaving a garrison at a critical crossroads. More TBD
a ParentPlan - SectorStrategy
ChildPlans (none for now, although a complicated AttackAreaPlan could well be subdivided into more tractable AttackAreaPlans)
Success - use basic Success above, or something fancier depending on what we think we need.
DefendAreaPlan (defend given area)
This will have many Objectives and other objects in common with the Attack version. However, unless the area is only a few squares this one will almost certainly require child DefendAreaPlans. Now for some of the differences:
Trivially, we will have a DefendArea objective rather than an AttackArea
There could also be a ScorchedEarth Objective, and probably some more.
Assumptions - These are even more critical for good defense than they are for attack. One obvious one is enemy troops that are nearby to the area, and heading this way. Lets start with that for simplicity. Once enemy troop strength is established we need to worry about where they are going. I think we should spec this out further as we go along.
ReservePlan (reserves for undetermined future use)
The idea is that reserves can be drawn upon, giving a negative value from Success in the ReservePlan. If the Plan that wants to use the reserves has a Success gain large enough to justify the removal of the units, then the transfer will get approved (Ideally after all Plans that want them have their chance). Whether we need a method requestTransfer(Command) that returns a value, or whether this is handled some other way, I will leave to Gary's Judgment (lucky you! )
Objectives -
AvoidReserveDepletion
* Name ("Reserve Depletion")
* arguments passed in that are used by getValue (FE how to assess value of a mil. unit. in reserves. For now we should just use creation cost as a simplification, but this can be Much more nuanced later. Reserves in the right spot can have an importance Many times their base construction value.)
* getValue calculates army cost-to-build change after executing requested Action of removing the reserves.
* isAchieved method (don't know about this one here. maybe this points to us needing two high-level Objective classes, one that is Achievable and another that isn't)
Resources - Commands used in attack plan
Assumptions - N.A. or maybe this can be where the remove reserves order gets put in?
Actions - N.A. or maybe This can be where the remove reserves has its influence?
a ParentPlan - SectorStrategy
ChildPlans (none for now, although a complicated ReservePlan could well be subdivided into more tractable ReservePlans)
Success - use basic Success above.
SectorStrategy (Plan for a big chunk of the map, like a front in modern warfare)
Objectives -
TakeEnemyTerritory - accomplished thru child AttackAreaPlans
* Name ("Conquer Silesia")
* value of one point of AttackAreaPlan success (used to characterize a sector strategy's success being predicated on taking enemy ground, this might range from 0 to 1)
* getValue sums all AttackAreaPlans and multiplies by value in line above
* isAchieved method returns true when all of AttackAreaPlans completed.
DefendOurTerritory - largely analagous to TakeEnemyTerritory Except that it is mandated that all friendly area of the front Must have an associated DefendAreaPlan so that the Sector AI will get feedback on any lost territory. The DefendAreaPlan need not have any Commands allocated to it.
Other ideas?
Resources - Sum resources used in all Child plans
Assumptions - This is an Enormously complicated issue. To be done right, SectorStrategy will need to estimate enemy forces and their disposition using all info available, formulate potential enemy actions, and then see if the Child plans handle those circumstances ok. For now we will just be dumb and happy and make no Assumptions, leaving estimated enemy disposition to the Child plans to guess.
Actions -
*Mostly these are the Child plans themselves
*Orders specifying when to fight and when not. FE "don't attack at less than 2:1 odds".
Also includes other orders like leaving a garrison at a critical crossroads. More TBD
a ParentPlan - MilitaryStrategy
ChildPlans (AttackAreaPlans, etc. this is where much of the action is)
Success - use basic Success above, or something fancier depending on what we think we need.
*** Much internal machinery for formulation of good Child plans, that will be in my next extended post.
Here is my attempt to move the AI approach forward towards something specific enough to start coding. It ain't there yet! But I am burnt out, and thought I would post this in rough form to get initial responses and ideas. I have left out some of the communication mechanisms that will be needed between Plans of different levels. also, I've only gotten partway up the command chain...
First, a few notes, refining what has gone before:
When Objectives are complete, plan reports this fact to parent using a TBD mechanism
Names for now are just placeholders
Specific Plan Objects have the following:
(an object whose name is pluralized implies a collection of X)
Objectives - have a
* Name (for GUI use)
* arguments passed in that are used by getValue (FE how to assess value of a mil. unit)
* getValue method that takes some object of Game State after a simulation of the Actions, and returns a value that indicates level of success of the objective.
* isAchieved method that says whether objective has been satisfied
Resources - are Clash objects of various sorts. Commands, money, Characters...
Assumptions - (I'm having trouble specing this one out for the general case, will return to it later, and you can also see some specifics below. comments welcome!)
Actions - (again, tough to put in a general fashion, see specifics associatied with different Plan objects)
a ParentPlan (object of type Plan at higher level in the hierarchy)
ChildPlans (objects of type Plan at the same or lower level in the hierarchy)
Success -
* has a compareTo function per Gary's post
* group of success values. In simulation, a number of different success values can be obtained even given identical Actions, Child Plans, etc. This saving of success values allows for assesment of ranges of results likely, characerizing riskiness.
* success as an absolute measure, rather than compared to another plan (perhaps success measures should also have an opportunity cost for Resources used). This prevents the case where marching an army a long ways off to conquer something would be preferred to conquering something of slightly less value a lot closer to home, and then freeing up the troops. Thoughts?)
Now, the first specific Plan:
AttackAreaPlan (Attack and take one or more squares)
Objectives - TakeArea, AvoidTroopLoss, EnemyTroopLoss, AchieveByTurn
Resources - Commands
Assumptions - EnemyForces
Actions - MovementPath(s), Orders specifying when to fight and when not
a ParentPlan - SectorStrategy
ChildPlans (none for now)
Success
AttackAreaPlan Object Details
Objectives -
TakeArea - Secure control of an area that is a collection of MapSquares
* Name ("Conquer Silesia")
* area - collection of squares that define area to be conquered
* value of captured square per unit economic value (may need more refinement)
* strategic value of conquered squares(when map AI functional so strategic value can be better assessed)
* getValue sums econ and strategic value over all conquered squares. Or perhaps adds for all conquered and subtracts for any lost from starting area
* isAchieved method returns true when all of area defined is conquered.
AvoidTroopLoss
* Name ("Military Losses")
* arguments passed in that are used by getValue (FE how to assess value of a mil. unit. For now we should just use creation cost as a simplification)
* getValue calculates army cost-to-build after executing Action and subtracts initial
cost-to-build.
* isAchieved method (not sure this is needed here, since everything is 'shades of gray'. If we want to add another parameter that says anything more than X is unacceptable, then this method again makes sense in this context)
EnemyTroopLoss
virtually identical to AvoidTroopLoss
AchieveByTurn
* Name ("Turn 38" or "340BC")
* parameter(s) specifying how much early or late completion affects value
* getValue returns bonus for early completion, or penalty for late.
* isAchieved is straightforward
Resources - Commands used in attack plan
Assumptions - EnemyForces for now we should just weasel on this and let the AI see everywhere. Perhaps forces just outside area should be counted also.
Actions -
*Path(s) Just path or paths attackers will follow
*Orders specifying when to fight and when not. FE "don't attack at less than 2:1 odds". Also includes other orders like leaving a garrison at a critical crossroads. More TBD
a ParentPlan - SectorStrategy
ChildPlans (none for now, although a complicated AttackAreaPlan could well be subdivided into more tractable AttackAreaPlans)
Success - use basic Success above, or something fancier depending on what we think we need.
DefendAreaPlan (defend given area)
This will have many Objectives and other objects in common with the Attack version. However, unless the area is only a few squares this one will almost certainly require child DefendAreaPlans. Now for some of the differences:
Trivially, we will have a DefendArea objective rather than an AttackArea
There could also be a ScorchedEarth Objective, and probably some more.
Assumptions - These are even more critical for good defense than they are for attack. One obvious one is enemy troops that are nearby to the area, and heading this way. Lets start with that for simplicity. Once enemy troop strength is established we need to worry about where they are going. I think we should spec this out further as we go along.
ReservePlan (reserves for undetermined future use)
The idea is that reserves can be drawn upon, giving a negative value from Success in the ReservePlan. If the Plan that wants to use the reserves has a Success gain large enough to justify the removal of the units, then the transfer will get approved (Ideally after all Plans that want them have their chance). Whether we need a method requestTransfer(Command) that returns a value, or whether this is handled some other way, I will leave to Gary's Judgment (lucky you! )
Objectives -
AvoidReserveDepletion
* Name ("Reserve Depletion")
* arguments passed in that are used by getValue (FE how to assess value of a mil. unit. in reserves. For now we should just use creation cost as a simplification, but this can be Much more nuanced later. Reserves in the right spot can have an importance Many times their base construction value.)
* getValue calculates army cost-to-build change after executing requested Action of removing the reserves.
* isAchieved method (don't know about this one here. maybe this points to us needing two high-level Objective classes, one that is Achievable and another that isn't)
Resources - Commands used in attack plan
Assumptions - N.A. or maybe this can be where the remove reserves order gets put in?
Actions - N.A. or maybe This can be where the remove reserves has its influence?
a ParentPlan - SectorStrategy
ChildPlans (none for now, although a complicated ReservePlan could well be subdivided into more tractable ReservePlans)
Success - use basic Success above.
SectorStrategy (Plan for a big chunk of the map, like a front in modern warfare)
Objectives -
TakeEnemyTerritory - accomplished thru child AttackAreaPlans
* Name ("Conquer Silesia")
* value of one point of AttackAreaPlan success (used to characterize a sector strategy's success being predicated on taking enemy ground, this might range from 0 to 1)
* getValue sums all AttackAreaPlans and multiplies by value in line above
* isAchieved method returns true when all of AttackAreaPlans completed.
DefendOurTerritory - largely analagous to TakeEnemyTerritory Except that it is mandated that all friendly area of the front Must have an associated DefendAreaPlan so that the Sector AI will get feedback on any lost territory. The DefendAreaPlan need not have any Commands allocated to it.
Other ideas?
Resources - Sum resources used in all Child plans
Assumptions - This is an Enormously complicated issue. To be done right, SectorStrategy will need to estimate enemy forces and their disposition using all info available, formulate potential enemy actions, and then see if the Child plans handle those circumstances ok. For now we will just be dumb and happy and make no Assumptions, leaving estimated enemy disposition to the Child plans to guess.
Actions -
*Mostly these are the Child plans themselves
*Orders specifying when to fight and when not. FE "don't attack at less than 2:1 odds".
Also includes other orders like leaving a garrison at a critical crossroads. More TBD
a ParentPlan - MilitaryStrategy
ChildPlans (AttackAreaPlans, etc. this is where much of the action is)
Success - use basic Success above, or something fancier depending on what we think we need.
*** Much internal machinery for formulation of good Child plans, that will be in my next extended post.
Comment