ORIGINAL: SamuraiProgrammer
<breathes into a paper bag to stop hyperventilating>
Does this mean that we (the community) might be able to write our own AIs?
<breathes into a paper bag to stop hyperventilating>
My offer to help with the documentation (if needed) still stands, though I won't be able to spend much time on it for a couple of months due to deadline pressure at work.
Dean
Here is the primary routine for AI decision making. It is called by Game Control at numerous places in the sequence of play - basically whenever a decision needs to be made by the AIO. The task index determines which decision the AIO needs to make.
=============
// ****************************************************************************
procedure TDecisionMaker.Decide(const TaskIndex: Integer);
// ****************************************************************************
// This is the universal routine for processing AI decisions by a decision maker
// ****************************************************************************
var
GS: TGrandStrategist;
MC: TManufacturingCouncil;
CIC: TCommanderInChief;
FL: TForeignLiaison;
JCS: TJointChiefsOfStaff;
AD: TAdmiralty;
AM: TAirMarshal;
FM: TFieldMarshal;
begin
case DMType of
// ****************************************************************************
// Grand Strategist decisions
// ****************************************************************************
dmtGS:
begin
GS := TGrandStrategist(Self);
case TaskIndex of
1: GS.DecStrategicPlan;
2: GS.DecUSEntryOption;
3: GS.DecInitiative;
4: GS.DecUSEntryMarkers;
5: GS.DecOffDefMarkers;
6: GS.DecUSSRMarkerBP;
7: GS.DecIntelligence;
8: GS.DecDestroyFactories;
9: GS.DecHomeCountry;
end;
end;
// ****************************************************************************
// Manufacturing Council decisions
// ****************************************************************************
dmtMC:
begin
MC := TManufacturingCouncil(Self);;
case TaskIndex of
1: MC.EvalUSEntryOptions;
2: MC.DecProductionPlan;
3: MC.DecProduction;
4: MC.DecForcePool;
5: MC.DecMoveFactory;
6: MC.DecBuildFactory;
7: MC.DecRepairFactory;
8: MC.DecBuildAhead;
9: MC.DecConvoys;
10: MC.DecResourceRoutes;
11: MC.DecDefStratBombing;
12: MC.DecGearingLimits;
end;
end;
// ****************************************************************************
// Commander in Chief decisions
// ****************************************************************************
dmtCIC:
begin
CIC := TCommanderInChief(Self);;
case TaskIndex of
1: CIC.EvalUSEntryOptions;
2: CIC.DecDOW;
3: CIC.DecPeaceUSSRJapan;
4: CIC.DecMutualPeace;
.
.
.
.
=============
This, in turn, calls the routines for each specific decision maker. For instance:
=============
// ****************************************************************************
// Class TGrandStrategist
// ****************************************************************************
TGrandStrategist = class(TDecisionMaker)
private
// CurrentSP: TStrategicPlan; // Modified/In progress
public
constructor Create; // DMType := dmtGS;
destructor Destroy; override;
procedure DecStrategicPlan;
procedure DecUSEntryOption;
procedure DecInitiative;
procedure DecUSEntryMarkers;
procedure DecOffDefMarkers;
procedure DecUSSRMarkerBP;
procedure DecIntelligence;
procedure DecDestroyFactories;
procedure DecHomeCountry;
end;
=============
I intend for each of these procedures to be based on rules written in the AIO rules language (plain text) that gets parsed and stored in internal data structures (the program will parse the rules only once).
1 - The plain text is parsed and stored in internal data structures.
2 - The program calls a decision maker's procedure when a decision needs to be made.
3 - The program uses the stored version of the rule to make the decision. There will often be references to dynamic game state varaibles (e.g., weather, impulse #).
It is very likely that each decision will have its own data strucutre, though obviously I will try to use a general/standard structure(s) whenever possible.
Parsing means that there is a language being used. For my own purposes I will document the language. I have no interest at this time is making that documentation any more elbaorate that absolutely necessary - for me to write the AIO rules.
If the player decides to write his own rules but wht heee wroten nto bye transssssslationableing. Boom![X(] Perfection or explosion. No sympathy.[:-]