Game definition jsons - AI Profiles

Learn the .json format
used to define characteristics of units and other game elements
Post Reply
Stratego (dev)
Site Admin
Posts: 15748
Joined: Fri Apr 25, 2014 9:28 pm

Game definition jsons - AI Profiles

Post by Stratego (dev) »

This file can make the different AI-s be smarter by a little "cheating" on inventing techs or spawn buildings/units

So for instance you want eg. the "impossible" AI to
- invent industry 1 on 5th turn,
- industry II on 10th turn (if not yeet invented)
- spawn 3 engineers on 2nd turn

and so on.

Here is an example
and below the description and all possible options

Code: Select all

#REM:AI definitions;
FOR_RANDOM-AI1-RACE_ELF:ELF_WEAPON_PROFILE(70),ELF_DODGE_PROFILE(30);
##;
#REM:PROFILES;
PROFILE:ELF_WEAPON_PROFILE;
10:2-3:INVENT:[TECH_ELF_WEAPONS_1],[ONLY_AFTER_ANY_ENEMY_OWNS_IT_TOO];
20:4-5:INVENT:[TECH_ELF_BOWS_1],[];
30:9-9:INVENT:[TECH_ELF_ARMORS_1],[];
40:12-13:INVENT:[TECH_ELF_WEAPONS_2],[];
50:12-15:INVENT:[TECH_ELF_BOWS_3],[];
60:13-15:INVENT:[TECH_ELF_WEAPONS_3],[];
#X#;
#REM:PROFILES;
PROFILE:ELF_DODGE_PROFILE;
10:2-3:INVENT:[TECH_ELF_DODGE_RANGED_1],[ONLY_AFTER_ANY_ENEMY_OWNS_IT_TOO];
20:4-5:INVENT:[TECH_ELF_DODGE_MELEE_1],[];
30:9-9:INVENT:[TECH_ELF_DODGE_COUNTER_1],[];
40:12-13:INVENT:[TECH_ELF_DODGE_MELEE_2],[];
50:12-15:INVENT:[TECH_ELF_DODGE_COUNTER_2],[];
60:13-15:INVENT:[TECH_ELF_DODGE_RANGED_2],[];
Sections

#REM:AI definitions:
below this line u see which profile related to which AI in which case

- map type: FOR_RANDOM (local skirmish and multiplayer, FOR_CAMPAIGN (campaign maps)
- AI1 (Hard), AI2(Easy), AI3 (Insane), AI4 (Impossible)
- race (if not multi-raced game (AOS), leave empty)
- profiles+weight list: <profile name>(<weight>) (eg: ELF_WEAPON_PROFILE(70)) means that given profile will be used with given heith on random.
The selected profile will be stored in the game and all its items lited as doable tasks for the AI.

#REM:PROFILES;
below this line the profiles listed
profiles are separated by #X#; from each other

Each items in a profile will be checked on turn start, and if turn setup fits it will try to evecute, if fails than will remain opened, if partially successful (eg. from 5 units it spawned 3) it will be closed as it would fully success.

example line: PROFILE:ELF_DODGE_PROFILE;
- Name: PROFILE:ELF_WEAPON_PROFILE; defines the profile name

example line: 10:2-3:INVENT:[TECH_ELF_DODGE_RANGED_1],[ONLY_AFTER_ANY_ENEMY_OWNS_IT_TOO];
meaning: <ID>:<turnrandom>:<Task type>:[<unit/tech type1>,<unit/tech type2>],[<spec1><spec2>];
- ID: this ID will be used to be stored on a game within the seelcted profile - so do not change ID betweeen releases, and if was used should never be used again.
- turnrandom: 2-4 means ont turn 2 it will random between 2..4 and if turn 2 than executes, on next turn betwwen 3..4 if 3 executes, on turn 4 surely executes. if you dont want random use 2-2.
- Task type:
"INVENT": invents tech
"SPAWN": spawns unit / building (set the place where to eg.SPAWN_TC_INSIDE, that is mandatory)
- unit/tech type: list the units / techs you want to added/created.
- spec: list the specs for this setting line

Possible specs:

Code: Select all

        
        TECH_ADD_ALL_TECHS,                  // executes the Add all default techs logic (will ignore the techs given in profile line)
        ONLY_AFTER_ANY_ENEMY_OWNS_IT_TOO,      // it will only train/invent if any other human player already own the same
        ONLY_ON_FEW_TC,               //run this line only if TC set as few
        ONLY_ON_NORMAL_TC,
        ONLY_ON_MANY_TC,
        ONLY_ON_NO_TECH,              //run this line only if map setup in NO techs
        ONLY_ON_ALL_TECH,             //run this line only if map setup in ALL techs        
        SPAWN_TC_INSIDE,              // spawn inside TC
        SPAWN_TC_ADJACENT,            // spawn in range 1 from a TC
        SPAWN_TC_AROUND,              // spawn in range 3 from a TC (inside/adjacent/around can be cmobined in this order will be processed)
        SPAWN_WORKER_ADJACENT,        // spawn in range 1 from a worker
        SPAWN_TO_FRONTLINE,           // spawn close to enemies (default is farther from enemies)
        SPAWN_AS_UC,                  // spawn the building as under construction
        SPAWN_MULTIPLY_TC_AMOUNT      // spawn 2 times if game is "Few TCs" and spawn 3 times if game is "Many TCs"

Templating!
You can reference other templates as inserts to your current template using the "COPY_TEMPLATE:" line
in below example the TEMPLATE_01 will be inserted into the HUMAN_HARD_PROFILE
IMPORTANT! ID-s should still be unique in a final profile (even after inseting the referenced template)

Code: Select all

PROFILE:TEMPLATE_01;
1:1-1:SPAWN:[UNIT_BUILDING_BLACKSMITH],[SPAWN_WORKER_ADJACENT,SPAWN_AS_UC];
2:1-1:SPAWN:[UNIT_BUILDING_BARRACKS],[SPAWN_WORKER_ADJACENT,SPAWN_AS_UC];
3:1-1:SPAWN:[UNIT_BUILDING_STABLE],[SPAWN_WORKER_ADJACENT,SPAWN_AS_UC];
#X#;
PROFILE:HUMAN_HARD_PROFILE;
10:1-1:SPAWN:[UNIT_BUILDING_BLACKSMITH],[SPAWN_WORKER_ADJACENT,SPAWN_AS_UC];
COPY_TEMPLATE:TEMPLATE_01;
20:1-1:SPAWN:[UNIT_BUILDING_BARRACKS],[SPAWN_WORKER_ADJACENT,SPAWN_AS_UC];
30:1-1:SPAWN:[UNIT_BUILDING_STABLE],[SPAWN_WORKER_ADJACENT,SPAWN_AS_UC];
40:5-7:INVENT:[TECH_HUMAN_ARMORS_1,TECH_HUMAN_WEAPONS_MELEE_1,TECH_HUMAN_SHIELDS_1],[];
50:8-9:INVENT:[TECH_HUMAN_WEAPONS_RANGED_1,TECH_HUMAN_WEAPONS_THROWING_1,TECH_AMBIDEXTRIA],[];
60:10-12:INVENT:[TECH_UPGRADE_UNIT_CAVALRY_1,TECH_HUMAN_FIREBALL,TECH_FAITH_1],[];
70:13-14:INVENT:[TECH_UPGRADE_UNIT_INFANTRY_1,TECH_BLESSING,TECH_HUMAN_REACH,TECH_ARCANE_KNOWLEDGE_1],[];
80:15-17:INVENT:[TECH_HUMAN_ARMORS_2,TECH_HUMAN_WEAPONS_MELEE_2,TECH_HUMAN_SHIELDS_2],[];
90:18-19:INVENT:[TECH_HUMAN_WEAPONS_RANGED_2,TECH_HUMAN_WEAPONS_THROWING_2,TECH_ARCANE_RANGE_1],[];
100:20-22:INVENT:[TECH_UPGRADE_UNIT_CAVALRY_2,TECH_HUMAN_KNIGHTHOOD,TECH_ARCANE_KNOWLEDGE_2],[];
110:23-24:INVENT:[TECH_UPGRADE_UNIT_INFANTRY_2,TECH_FAITH_2,TECH_ARCANE_RANGE_2],[];
User avatar
v094517
Posts: 71
Joined: Fri Jun 23, 2023 1:09 am

Re: Game definition jsons - AI Profiles

Post by v094517 »

Could even have map-specific "custom ai" (own selection of traits), not just preset difficulties
Last edited by v094517 on Mon Nov 06, 2023 11:32 am, edited 1 time in total.
User avatar
v094517
Posts: 71
Joined: Fri Jun 23, 2023 1:09 am

Re: Game definition jsons - AI Profiles

Post by v094517 »

This is different from triggers in that it can be not directly deterministic/it is relative to the ai itself. Maybe triggers themselves can modify ai beyond set easy/hard? (e.g. add attribute)
Stratego (dev)
Site Admin
Posts: 15748
Joined: Fri Apr 25, 2014 9:28 pm

Re: Game definition jsons - AI Profiles

Post by Stratego (dev) »

new spec:
TECH_ADD_ALL_TECHS, // executes the Add all default techs logic (will ignore the techs given in profile line)
Stratego (dev)
Site Admin
Posts: 15748
Joined: Fri Apr 25, 2014 9:28 pm

Re: Game definition jsons - AI Profiles

Post by Stratego (dev) »

new flag options:

Code: Select all

        ONLY_ON_FEW_TC,               //run this line only if TC set as few
        ONLY_ON_NORMAL_TC,
        ONLY_ON_MANY_TC,
        ONLY_ON_NO_TECH,              //run this line only if map setup in NO techs
        ONLY_ON_ALL_TECH,             //run this line only if map setup in ALL techs

Also you can use templates! read in first post how.
Post Reply

Return to “Game Definition .JSON”