Research AI basics (weapon lines)

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderators: Committer, Committer

Post Reply
Message
Author
Ophiuchus
Programmer
Posts: 1158
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Research AI basics (weapon lines)

#1 Post by Ophiuchus » Thu Feb 06, 2020 1:16 pm

I want to get the gamma burst slingshot (gbs) into master and I want the AI to be able to use it efficiently.

As its tech line (GBS1 GBS2 GBS3) splits from mainline at mass drivers, usually one would not try to research GBS2/GBS3 in parallel to lasers/plasma.
For a bad pilot skill empire going GBS is always a good option, maybe research basic fighters to be able to invest in fighters as well.
There are more things to consider, but those I already can not really do with the current research AI framework.

AFAIS the research AI works by concating 5 tiers of playbooks of tech to research. Each tier has multiple options. There are two properties used for determining which option to use: aggressiveness of the AI and sparseness (yes/no) of the galaxy. I think introducing more properties like pilot skill would lead to exponential explosion of rulebooks (or rulebook decisions at least). And actually a lot of properties could be relevant: PP / RP levels (and variations thereof if you consider focus changes), pilot skill, troop skil, enemies in reach, ...
Also implemented there is a system of research type slots - playbooks differ by the number and order of techs to add.

Some of this is handled by fast-tracking certain tech. But you can not delay or skip redundant tech (e.g. hull lines, weapon lines/refinements).

I think if we have a mechanic to determine (weighted) research goals we can simply put those (with associated priority, cost, dependencies) into a planner which would spit out a reasonable research queue. Or in a first step keep the slot defined rulebooks and do the (planning for) different types of tech separately. So maybe only reason about differences of weapon types or hull lines in a subsystem.

I started coding a fuzzy logic system to make the decision which weapon line to research and mostly what weapon techs not to research.

That went OK I think (see below), but found that fuzzy logic on this level is maybe not the best abstraction. A lot of the hard work actually happens before and is actually dependend on many factors (e.g. in the beginning of the game having 10 mass drivers is 100% MANY mass drivers, but in turn 50 not so much).

Then I realised that a lot of those rules actually depend on the galaxy setup (e.g. research/production multipliers, structure multiplier, number of combat bouts). Getting all of those into a fuzzy rulebase would be crazy.

Also for finding my rules i depend on spreadsheet magic. Instead of the spreadsheet I could do that instead in the game and use the values directly.
Also for the output decisions mostly look three-valued and could be put in a simple hierarchy (HIGH beats NO beats YES). I have a feeling the fuzziness is not so helpful here.

This i think indicates I first should rather prefer a utility based crisp approach than a fuzzy one. Of course adding a fuzzy layer above the calculated utility values and mix it e.g. with AI (or species) personality is quite possible. That utility approach will also have some drawbacks, e.g. the fuzzy approach i took provides researching weapon tech in parallel, a utility based one would need extra code for that.

Anyway, if you like have a look at the rules.

Code: Select all

// shortrange_progress  mds, lasers, plasma - this highlights the currently expected technology level (this means shortly before or after being researched)
// *_fielded          NO: none  FEW: there are some  MANY: there a lot of these parts in the current fleet
// research_* HIGH means: has priority                   
//             YES means: could be researched
//              NO means: should not be researched
// For the planning this means: do research HIGH with priority, do not research NO, add the rest with low prio

RULE 100: IF best_pilot_skill IS BAAD THEN research_gbs2   IS HIGH ;
RULE 101: IF best_pilot_skill IS BAAD THEN research_laser3 IS NO   ;
RULE 110: IF best_pilot_skill IS AVRG THEN research_gbs1   IS YES  ;
RULE 120: IF best_pilot_skill IS GOOD THEN research_gbs1   IS NO  , research_gbs2 IS NO ;
RULE 121: IF best_pilot_skill IS GOOD THEN research_laser1 IS YES  ;

RULE 211: IF md_fielded    IS FEW       THEN research_md3     IS YES ;
RULE 212: IF md_fielded    IS MANY      THEN research_md4     IS YES ;
RULE 221: IF laser_fielded IS FEW       THEN research_laser3  IS YES ;
RULE 222: IF laser_fielded IS MANY      THEN research_laser4  IS YES ;

RULE 311: IF next_ship_combat IS soon  AND ( md_fielded      IS FEW  OR md_fielded    IS MANY ) THEN research_md4 IS HIGH;
RULE 322: IF next_ship_combat IS later AND ( shortrange_progress IS mds    )                    THEN research_md3 IS NO
                                                                                                   , research_md4 IS NO;
RULE 321: IF next_ship_combat IS soon  AND ( laser_fielded   IS FEW  OR laser_fielded IS MANY ) THEN research_laser4 IS HIGH;
RULE 322: IF next_ship_combat IS later AND ( shortrange_progress IS lasers )                    THEN research_laser3 IS NO
                                                                                                   , research_laser4 IS NO;
RULE 351: IF next_ship_combat IS soon  AND ( fighter_fielded IS FEW OR fighter_fielded IS MANY ) THEN research_boats IS HIGH;

RULE 420: IF shortrange_progress IS mds     THEN research_boat_tech IS boats;
RULE 421: IF shortrange_progress IS lasers  THEN research_boat_tech IS laserboats;
RULE 422: IF shortrange_progress IS plasmas THEN research_boat_tech IS plasmaboats;
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

Post Reply