I'm working on understanding and improving the AI. My intention is to make the AI act like a good human opponent and provide a base of knowledge so others can tweak the AI as they see fit. This means my own modded AI files (Better AI) will make the campaign much harder, and even possibly unbalanced without further modification to enemy force size and composition. As with any mod, use at your own risk and backup your files. HBS, feel free to crib any of my values or settings. I'd be glad if this mod was made obsolete by a professional deadly AI setting.
Better AI
Better AI 2.0.0 - For BATTLETECH 1.9.1
D/L at /BattletechModders/BetterAI/releases on GitHub
[Mod edit: No unapproved links]
Link to Stock+Modded AI Variables Google Sheet
Better AI is a ModTek mod that improves the enemy AI and acts similar to a human player. The AI can reserve, will use cover/terrain more intelligently and utilize the dynamic roles to a greater extent. The AI will pose a greater challenge than stock, but not insurmountable in our experience. I've done my best to make the AI as tactically proficient as I can. It should make less dumb moves overall. I'm always looking for suggestions on how to make it better, please post your opinions in this thread.
Mpstark, the creator of ModTek, is helping me with that side of the mod. Currently, other than the behaviorVariables folder the AI's .jsons reside in, the mod also edits some of the mechdef files to reassign dynamic role tags (like setting the UrbanMech from Brawler to Sniper) for better unit profiling. Going forward I'm excited to be working with him in exploring how far we can change the AI.
Better AI Add-Ons
Permanent Evasion Add-On:
Download Better AI - Permanent Evasion Add On 1.9.1 (For BATTLETECH 1.9.1 +)
On github @ Amechwarrior/BetterAI-Permanent-Evasion-Add-On/releases
This optional build is for the Permanent Evasion mod, forks of that mod and modpacks that use them. It changes the "k" : "Float_PipStripAttackProbabilityThreshold", variable that lets the AI know if an attack with strip a Pip or not, set to "1.0" or false. It also removes the threshold for conservative shots threshold.
This add-on is setup as an advanced JSON merge to Better AI and should not need to be updated along side the base mod any longer.
AI Modding Help:
Link to Stock+Modded AI Variables Google Sheet
I've listed every single variable in the behaviorVariables folder along with HBS's comments and arranged the active and inactive files beside the default global.json and unused.json. Feel free to copy or download this file for your own AI modding needs. I plan to use it by inserting a new column for a modded global.json next to the stock so I can easily compare my changes to the default and any other files.
global.json + global_def.json
The global.json describes the default decision weights for all AI. When the AI is in a defensive mood (see moods below) it will pull on the global_def changes before the base global.json. Below in the spoiler field are my notes on the variables in beta, while the values have been changed and a lot have been removed, most of this still applies.
unused.json
This is a listing of unused variables that can be pasted in to the global, or another valid behavior file and once set to a non-zero value, become an active weight in the system. I'd like to thank HBS for including these as it greatly expands our modding potential.
role_XXXX.json
There are at least 6 active dynamic 'Mech role files in the game, each with its own defensive mood file ending in "_def" which is a blank file. These roles can be adjusted on the fly, changing as needed based on the unit_role_xxxx tag. Each mechdef contains just one role, and all units can pull brawler if others are filled. The Brawler role is effectively the default role of the AI and the global.json has been setup to reflect the Brawler fighting style with wanting to enter melee range and other adjustments. This ensures in a fallback situation, the AI will hunt down the players units and engage.
For example, in the Atlas' mechdef there is a listing of its tags:
"MechTags": {
"items": [
"unit_indirectFire",
"unit_mech",
"unit_assault",
"unit_release",
"unit_ready",
"unit_lance_tank",
"unit_role_brawler"
],
The "unit_role_brawler" is the tag to let the game know to use the role_brawler.json to before default values. In this case, the file is blank. The default global.json is effectively the brawler role and brawler is also the default role mechs fall back to. Some roles also have a limit to how many units may pull a certain role. For Brawlers and Snipers, this is found at the end of the CombatGameConstants.json:
"DynamicAIRoleConstants":
{
"hysteresis": 0.1,
"brawlerMinAbs": 0,
"brawlerMaxFrac": 1.0,
"brawlerTagMultiplier": 2.0,
"sniperMinAbs": 0,
"sniperMaxFrac": 0.75,
"sniperTagMultiplier": 2.0
}
We can see that anything tagged brawler or sniper has those tag weights doubled, where the "scout" role isn't managed by this multiplier system. The min/max should mean that no more than 3/4 of an enemy force can be using role_sniper.json at any one time. This means even if the entire enemy force is GRF-1N's, they won't all jump away and PPC snipe you forever, as one of them will pull brawler and close to contact.
The scout role emphasizes skirting the edges and surrounding the enemy, while lowering the values for melee related variables. The sniper role emphasizes staying put and shooting targets over the default closing to melee range. You can have up to 3 Scouts in a Lance, but 4 will force them all in to Brawlers and almost never return.
AI PERSONALITY + FACTION
These AIPersonality .jsons seem to be active but unused at this time. All faction files are empty and I do not know the variable needed to declare them. The AI Personality variable can been seen in the pilotdefs:
"AIPersonality": "Undefined",
I have not done any testing with either factions or personalities. I'd expect personalities to work if declared.
AI MOODS
The five moods are:
Better AI
Better AI 2.0.0 - For BATTLETECH 1.9.1
D/L at /BattletechModders/BetterAI/releases on GitHub
[Mod edit: No unapproved links]
Better AI is a ModTek based mod. Simple ModTek Install Guide. ModTek is found in the BT Modders Collective here: /BattletechModders/ModTek/releases on GitHub
[Mod edit: No unapproved links]
UPDATE INSTRUCTIONS
[Mod edit: No unapproved links]
UPDATE INSTRUCTIONS
- Delete Better AI folder from your BATTLETECH\Mods folder
- Unzip Better AI in to BATTLETECH\Mods
2.0.0 Changelog:
For BATTLETECH 1.9.1
Uses ModTek 0.7.7.4
Better AI can be used with the HBS mod loader, however DLC content will not be corrected. It's recommended to use this mod with ModTek.
Release Notes:
Better AI 2.0 is a clean slate rewrite using the AI diagnostic tools developed by mpstark and input from Koztaz of "Relentless AI" to further improve the tactical challenge in a stock environment. It's more aggressive, keeps Lances cohesive and is more capable in reserve play with numbers. This mod has been built for and tested with the stock game mechanics. The Better AI Permanent Evasion Add On will still be needed for mods and modpacks that use it. If you are using the BT: Extended, BT: Advanced, please wait for the modpack curators to update to this version. BT: Revised users now have "Relentless AI" from Koztaz already tuned to their modpack.
Feedback is greatly appreciated either in this thread or the various BT discords.
Modpack users: AT YOUR OWN RISK - Copying only the "\data\behaviorVariables" folder from Better AI 2.0 in to your modpacks existing Better AI folder should work with minimal interference. However, this is not recommended.
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 2.0.0 automatically
For BATTLETECH 1.9.1
Uses ModTek 0.7.7.4
Better AI can be used with the HBS mod loader, however DLC content will not be corrected. It's recommended to use this mod with ModTek.
Release Notes:
Better AI 2.0 is a clean slate rewrite using the AI diagnostic tools developed by mpstark and input from Koztaz of "Relentless AI" to further improve the tactical challenge in a stock environment. It's more aggressive, keeps Lances cohesive and is more capable in reserve play with numbers. This mod has been built for and tested with the stock game mechanics. The Better AI Permanent Evasion Add On will still be needed for mods and modpacks that use it. If you are using the BT: Extended, BT: Advanced, please wait for the modpack curators to update to this version. BT: Revised users now have "Relentless AI" from Koztaz already tuned to their modpack.
Feedback is greatly appreciated either in this thread or the various BT discords.
Modpack users: AT YOUR OWN RISK - Copying only the "\data\behaviorVariables" folder from Better AI 2.0 in to your modpacks existing Better AI folder should work with minimal interference. However, this is not recommended.
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 2.0.0 automatically
1.7.0.0 Changelog:
global.json, role_activeprobe.json and role_ecmcarrier added new variables and stock adjustments to ECM field weights.
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 1.7.0.0 automatically
1.6.2.2 Changelog:
global.json
Float_ExistingTargetDamageForOverheatAttack 0.90 from 90.0 - Bug, thanks Dra9o!
Float_MeleeDamageMultiplier 2.75 from 3.0 - Slightly less punchy base AI
Float_EvasiveToHitFloor 30.0 from 40.0 - AI much better at heat control, players more evasive
Float_CenterTorsoRearArmorMultiplier 5 from 10 - slightly higher chance to attack rear
Float_PreferAttackFromBehindHostileFactorWeight 0.5 from 0.4 - slightly higher chance to attack rear
role_meleeonly.json
Float_DFADamageMultiplier 8 from 6 - slightly higher chance to DFA in meleeonly
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 1.6.2.2 automatically.
Changelog for 1.6.2.1:
global.json
Changelog for 1.6.1.2:
global.json
role_activeprobe.json
Changelog for 1.6.0.1:
global.json
1.5.1.1 Change Log -
LanceDef's have been partially optimized to fit the appropriate types of pilots in to the best suited 'Mechs. I'm limiting this to two units per Lance to preserve variety. You should see more of the heaviest unit pulling Bulwark in mixed tonnage Lances, more Gunners and Defenders in Battle Lances and at least one Tactician in a Scout Lance. All vehicles have had their potential pilots culled of skill sets they cannot use, primarily the Guts track.
Massive credit goes to scJazz who came upon the initial idea.
Minor New Feature:
This mod now loads after cFixes and Z_Sab_JK_RarityTables to allow them to apply their basic JSON overwrites first and then Better AI's Lance and 'Mech Tags on top of the modified files. If you encounter any merging issues with these or other mods, let me know.
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 1.5.1.1 automatically.
1.5.0.1 Change Log -
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 1.5.0.1 automatically.
1.4.1 Change Log:
New ModTek Features:
1.4.0 Full Change Log -
HBS Dev Comments added to all files
Removed blank files to minimize mod footprint
CombatGameConstants.json - ADDED
global.json
1.3.3 Release Notes:
1.3.0 Release Notes:
1.2.0 Release Notes:
Initial 1.0 Release
Major changes to these behavior .jsons:
Massive thanks to Mpstark for making ModTek and helping me with that side of the mod. Also, a thank you to everyone who has helped provide feedback along the way here going back to beta!
global.json, role_activeprobe.json and role_ecmcarrier added new variables and stock adjustments to ECM field weights.
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 1.7.0.0 automatically
1.6.2.2 Changelog:
global.json
Float_ExistingTargetDamageForOverheatAttack 0.90 from 90.0 - Bug, thanks Dra9o!
Float_MeleeDamageMultiplier 2.75 from 3.0 - Slightly less punchy base AI
Float_EvasiveToHitFloor 30.0 from 40.0 - AI much better at heat control, players more evasive
Float_CenterTorsoRearArmorMultiplier 5 from 10 - slightly higher chance to attack rear
Float_PreferAttackFromBehindHostileFactorWeight 0.5 from 0.4 - slightly higher chance to attack rear
role_meleeonly.json
Float_DFADamageMultiplier 8 from 6 - slightly higher chance to DFA in meleeonly
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 1.6.2.2 automatically.
Changelog for 1.6.2.1:
global.json
- Float_ConfidenceInSignificantDamageWhileGhostedLevel - Added for 1.6.2
- Float_WeaponDamageSpreadLerpValue- Added for 1.6.2
- Float_StructuralDamagePercentageMultiplier- Added for 1.6.2
- Float_ExpectedAndMaxDamageShootingInGhostStateLerp- Added for 1.6.2
- Float_GhostStateHysteresisMultiplierTurnIncrease- Added for 1.6.2
- Bool_ExpectedDamageAccuracyIncrease - Added, set to true
- Bool_EnableLongRangePathfindingBeActorAware- Added, set to true
- Float_LongRangeToShortRangeDistanceThreshold- Added for 1.6.2
- Changed role to unit_role_sniper from brawler to "AC/20 Snipe" like the CP-10-Z
Changelog for 1.6.1.2:
global.json
- Float_SprintPreferInsideMeleeRangeFactorWeight -1.0 from -1.5 eagerness to close increased
- Float_SprintExclusionRadius 120.0 from 200.0 eagerness to close increased
- Float_PreferHostileECMFields 5.0 from 1.5 eagerness to pop ECM bubble greatly increased
- Float_SprintPreferHostileECMFields 5.0 from 0.5 eagerness to pop ECM bubble greatly increased when sprinting
- Int_MinimumECMGhostedPipsToFire 1 from 2 allows firing from inside ECM bubble
- Bool_EnableUrbanBiomeNavigationEverywhere true from false to allow better pathfinding
- Float_PreferFriendlyECMFields 1.75 added
- Float_SprintPreferFriendlyECMFields 1.0 added
- Float_PreferHostileECMFields 0.0 added to null out wanting to stay in hostile bubble while defensive
- Float_SprintPreferHostileECMFields 0.0 added to null out wanting to stay in hostile bubble while defensive
- Int_MinimumECMGhostedPipsToFire 2 added and set to stock value to keep stealth when defensive
role_activeprobe.json
- Reordered listing to flow in global.json order
- Int_MinimumECMGhostedPipsToFire 2 added and set to stock value to keep stealth when defensive
- Reordered listing to flow in global.json order
- Int_MinimumECMGhostedPipsToFire 2 added and set to stock value to keep stealth when defensive
- Reordered listing to flow in global.json order
- Int_MinimumECMGhostedPipsToFire 2 added and set to stock value to keep stealth when defensive
- Float_SprintExclusionRadius 196.0 from 244.0 eagerness to close increased
- Int_MinimumECMGhostedPipsToFire 2 added and set to stock value to keep stealth when defensive
Changelog for 1.6.0.1:
global.json
- Float_PreferInsideMeleeRangeFactorWeight -0.5 from -1 to allow easier entry to close combat
- Float_PreferSurroundingHostileUnitsFactorWeight 0.7 from 0.5 to allow better flanking now that "buddy" variables control lance cohesion
- Float_PreferHostileECMFields 1.5 from 0.3 to increase chance of entering ECM bubble to provide LoS
- Float_SprintPreferHostileECMFields 0.5 from 0.2 to increase chance of entering ECM bubble to provide LoS
- Float_PreferInsideMeleeRangeFactorWeight -0.1 from 0.1 slightly less melee range for AP vehicle
- Float_PreferLocationsThatGrantGuardFactorWeight 1.5 from 0.5 to match other modded global.json
- Float_PreferNotSurroundedByHostileUnitsFactorWeight 0.1 added to allow AP unit to enter hostile area to use ping
- Float_SprintPreferNotSurroundedByHostileUnitsFactorWeight 0.1 added to allow AP unit to enter hostile area to use ping
- Float_AlonePreferenceWeight -0.8 added and returned to stock value to allow AP carrier to reach enemy to ping
- Float_PreferActiveProbePositions 1 from 0.5 increase weight to positions they can use ping
- Float_PreferNoCloserThanMinDistToHostileFactorWeight 0.0 added to allow closer regardless of weapons
- Float_SprintPreferNoCloserThanMinDistToHostileFactorWeight 0.0 added to allow closer regardless of weapons
- Float_SprintPreferLowerMovementFactorWeight -1.0 from 0.0 to match other modded global.json
- Float_PreferLocationsThatGrantGuardFactorWeight 1.5 from 0.5 to match other modded global.json
- Float_PreferFriendlyECMFields 1.5 from 0.75 to stack tokens
- Float_SprintPreferFriendlyECMFields 0.5 added to stack tokens
- Float_SprintPreferHostileECMFields -0.1 added to prevent entering hostile LoS
- Float_SprintPreferLOSToFewestHostileFactorWeight 0.2 added to prevent entering hostile LoS
- Float_PreferLowerMovementFactorWeight -0.9 added to match other modded global.json
- Float_PreferHigherExpectedDamageToHostileFactorWeight 2.0 from 0.8 to match other modded scale
- Float_PreferInsideMeleeRangeFactorWeight -1.0 from 0.0 to prevent enemy entering bubble
- Float_PreferLocationsThatGrantGuardFactorWeight 1.5 from 0.5 to match other modded global.json
- Float_AppetitivePreferApproachingRearArcOfHostileFactorWeight 0.1 added to increase weights of staying with Lance
- Float_SprintAppetitivePreferApproachingRearArcOfHostileFactorWeight 0.0 added to increase weights of staying with Lance
- Float_AppetitivePreferIdealWeaponRangeToHostileFactorWeight 0.1 added to increase weights of staying with Lance
- Float_PreferSurroundingHostileUnitsFactorWeight 0.1 added to increase weights of staying with Lance
- Float_PreferLOSToFewestHostileFactorWeight 1.75 added to keep EWE out of direct fire
- Float_SprintPreferLOSToFewestHostileFactorWeight 0.2 added to keep EWE out of direct fire
- Float_PreferHigherExpectedDamageToHostileFactorWeight 4.5 from 3.8 for more aggressive vehicles
- unit_role_sniper from unit_role_brawler
1.5.1.1 Change Log -
- No Behavior Variables Adjusted
- LanceDefs Optimized
LanceDef's have been partially optimized to fit the appropriate types of pilots in to the best suited 'Mechs. I'm limiting this to two units per Lance to preserve variety. You should see more of the heaviest unit pulling Bulwark in mixed tonnage Lances, more Gunners and Defenders in Battle Lances and at least one Tactician in a Scout Lance. All vehicles have had their potential pilots culled of skill sets they cannot use, primarily the Guts track.
Massive credit goes to scJazz who came upon the initial idea.
Minor New Feature:
This mod now loads after cFixes and Z_Sab_JK_RarityTables to allow them to apply their basic JSON overwrites first and then Better AI's Lance and 'Mech Tags on top of the modified files. If you encounter any merging issues with these or other mods, let me know.
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 1.5.1.1 automatically.
1.5.0.1 Change Log -
- Removed Sniper Dynamic max of 75% (This is now the stock value, thanks HBS!)
- Aligned merge files to "mergeDef" format and folder structure
Better AI Permanent Evasion Add On - No update of Add-On required, will work with 1.5.0.1 automatically.
1.4.1 Change Log:
New ModTek Features:
- Optional Dependency - Thanks to the ModTek crew for implementing my request for Optional Dependencies. Better AI can now detect if cFixes is in your Mods folder and will automatically load after cFixes has been applied.
- Advanced JSON Merges - Allows Better AI to replace the single unit_role entries inside the mechdef's unit tags. Previously, the entire array had to be overwritten, causing issues with cFixes and other mods.
- Float_PreferHigherExpectedDamageToHostileFactorWeight 3.8 from 3.25 - Less afraid base AI
- Float_PreferInsideMeleeRangeFactorWeight -1.0 from -1.25 Less afraid of melee ranges
- Float_MeleeBonusMultiplierWhenAttackingEvasiveTargets - Greater multiplier to attacking evasive units with Melee
- Float_PreferHigherDistanceFromClosestHostileFactorWeight 1.25 from 1.5 - Less retreating when in defensive mode
- Float_DFADamageMultiplier 3.0 from 2.75 - Slightly more chance to DFA when all is lost
- Float_PreferInsideMeleeRangeFactorWeight 0.0 From global -1.0 - Last Man isn't afraid to enter melee
- Float_MeleeDamageMultiplier 0.75 from 0.5 - Slightly more weight to punch, I still want snipers to try and run from close combat
- Float_DFADamageMultiplier 2.0 from 1.75 - Higher weight to just DFA when rushed in to melee range by player units
- Float_PreferHigherExpectedDamageToHostileFactorWeight 3.8 from 3.5 - Matches new global
- Float_OptimalAllyDistance 120.0 from 96.0 - Vee's sticking too closely
- Float_PreferNotLethalPositionFactorWeight 0.7 from 0.8 - Less afraid Vee's
- Float_BuddyAloneFiringSolutionPreferenceWeight -1.0 From global -0.8 - Gave them the role_sniper weight for seeking lines of fire
1.4.0 Full Change Log -
HBS Dev Comments added to all files
Removed blank files to minimize mod footprint
- role_brawler_def
- role_lastmanstanding_def.json
- role_meleeonly_def
- role_noncombatant
- role_noncombatant_def
- role_scout_def
- role_sniper_def
- role_turret
- role_turret_def
- skill_reckless
- skill_reckless_def
CombatGameConstants.json - ADDED
- "AICritChanceBaseMultiplier": 1.0 from Stock = 0.2 - AI has same Crit Chance as Player
- "sniperMaxFrac": 0.75 from Stock = 0.5 - Lance can have 3/4th Snipers or 2/3rd Snipers instead of only 2/4 and 1/3
global.json
- Float_ExistingTargetDamageForOverheatAttack 90.0 from 0.0 - HBS fixed overheating and I didn't have to change this one much from stock
- Float_PreferLowerMovementFactorWeight -0.9 from -0.7 - Greater Pip building for 1.3 Evasion
- Float_PreferHigherExpectedDamageToHostileFactorWeight 3.25 from 4.0 - Lowered aggression to increase defensive positioning
- Float_VentCoolantHeatThreshold 1.99 from 2.1 - Trigger Coolant Vent slightly sooner
- Int_VentCoolantHealthThreshold 1 from 2 - Old value from when it caused injury, set it to 1 just in case
- Float_PreferInsideMeleeRangeFactorWeight -1.25 from -0.5 - AI needs to fear a player operated HTC
- Float_SprintPreferInsideMeleeRangeFactorWeight -1.5 from -0.7 - AI needs to fear a player operated HTC
- Float_PreferLocationsThatGrantGuardFactorWeight 1.5 from 1.4 - Greater tree hugging for 1.3 damage reduction
- Float_SprintPreferLocationsThatGrantGuardFactorWeight 1.5 from 1.25 - Greater tree hugging for 1.3 damage reduction
- Float_BulwarkThresholdPercentage 0.0 from 80 - Nullified old Bulwark logic
- Float_OverkillThresholdLowForRearArcPositionFactor 40 from 50 - Lowered acceptable levels to promote rear protection
- Float_OverkillThresholdHighForRearArcPositionFactor 60 from 75 - Lowered acceptable levels to promote rear protection
- Float_PreferLethalDamageToRearArcFromHostileFactorWeight -2.0 from -1.75 - Increased fear of units behind AI
- Float_MinimumSensorLockQuality 55.0 from 60.0 - Slightly larger chance for non-scouts to Lock
- Float_OpportunityFireExceedsDesignatedTargetByPercentage 20.0 from 25.0 - Returned to Stock value
- Float_PreferStationaryWhenHostilesInMeleeRangeFactorWeight -0.75 from -0.5- AI needs to fear a player operated HTC
- Float_PreferAttackFromBehindHostileFactorWeight 0.4 from 0.3 - Small bump to attacking the rear arc
- Float_SprintPreferLOSToMostHostilesFactorWeight 0.2 from 0.3 - Small dip to lower being an easy sprint target
- Float_PreferLowerMovementFactorWeight -1.0 from -0.5 - Greater Pip building for 1.3 Evasion
- Float_CoolDownRange 200.0 from 100m - Get further away before trying to cool down
- Float_PreferInsideMeleeRangeFactorWeight -1.3 from -1.0 - AI needs to fear a player operated HTC
- Float_SprintPreferInsideMeleeRangeFactorWeight -1.75 from -1.0 - AI needs to fear a player operated HTC
- Float_PreferLocationsThatGrantGuardFactorWeight 1.8 from 1.5 - Greater tree hugging for 1.3 damage reduction
- Float_SprintPreferLocationsThatGrantGuardFactorWeight 1.5 from 1.25 - Greater tree hugging for 1.3 damage reduction
- Float_BulwarkThresholdPercentage 0.0 from 85 - Nullified old Bulwark logic
- Float_PreferLethalDamageToRearArcFromHostileFactorWeight -2.5 from -2.0 - Increased fear of units behind AI
- Float_SprintPreferLethalDamageToRearArcFromHostileFactorWeight -2.5 from -2.0 - Increased fear of units behind AI
- Float_PreferLOSToFewestHostileFactorWeight 0.6 from 0.5 - Increase LoS break while defensive
- Float_SprintPreferLOSToFewestHostileFactorWeight 0.8 from 0.6 - Increase LoS break while defensive
- Float_PriorityMovePercentage 0.0 from global = 100.0 - ADDED - Trying to let Lock pilots move where it is safe, not rush at the target
- Float_PreferInsideMeleeRangeFactorWeight -1.3 from -1.0- AI needs to fear a player operated HTC
- Float_SprintPreferInsideMeleeRangeFactorWeight -1.75 from -1.0 - AI needs to fear a player operated HTC
- Float_SprintPreferLocationsThatGrantGuardFactorWeight 1.5 from 1.0 - Greater tree hugging for 1.3 damage reduction
- Float_PreferHigherDamageReductionLocationsFactorWeight 1.0 from global = 0.5 - ADDED - Greater tree hugging for 1.3 damage reduction
- Float_SprintPreferHigherDamageReductionLocationsFactorWeight 1.0 from global = 0.5 - ADDED - Greater tree hugging for 1.3 damage reduction
- Float_OwnMaxLegDamageForDFAAttack 0.99 from 0.9 - Slightly larger DFA window
- Float_DFADamageMultiplier 2.75 from 2.0 - Slightly higher chance of DFA
- Float_PreferNotSurroundedByHostileUnitsFactorWeight 0.4 from 0.5 - Slightly less afraid of being surrounded and fleeing
- Float_SprintPreferNotSurroundedByHostileUnitsFactorWeight 0.4 from 0.5 - Slightly less afraid of being surrounded and fleeing
- Float_PreferLOSToMostHostilesFactorWeight 0.2 from 0.0 - Slightly less afraid of being surrounded and fleeing
- Float_SprintPreferLOSToMostHostilesFactorWeight 0.1 from 0.0 - Slightly less afraid of being surrounded and fleeing
- Float_SprintExclusionRadius 96.0 from global = 200 - ADDED - Lets AI sprint to melee
- Float_PreferInsideSprintExclusionRadiusHostileFactorWeight 1.0 from global = 0.0 - ADDED - Lets AI sprint to melee
- Float_PreferHigherExpectedDamageToHostileFactorWeight 3.0 from 2.0 - Less afraid behavior
- Float_PreferOptimalDistanceToAllyFactorWeight 0.2 from 0.1 - Stay slightly closer to Lancemates
- Float_MeleeBonusMultiplierWhenAttackingEvasiveTargets 0.5 from 0.0 - Slightly more likely to punch opposing scout units
- Float_BulwarkThresholdPercentage 0.0 from 30 - Nullified old Bulwark logic
- Float_OverkillThresholdHighForLethalPositionFactor 95.0 from 90.0 - Less afraid behavior
- Float_OverkillFactorForReserve 60.0 from 50.0 - Greater chance to reserve
- Float_PreferSurroundingHostileUnitsFactorWeight 1.25 from 1.5 - Stay slightly closer to Lancemates
- Float_SprintPreferSurroundingHostileUnitsFactorWeight 1.5 from 1.75 - Stay slightly closer to Lancemates
- Float_PreferNotSurroundedByHostileUnitsFactorWeight 0.3 from 0.5 - Less afraid behavior
- Float_SprintHysteresisRecoveryTurns 2.0 from 1.0 - Less afraid behavior and chained sprinting away from combat, returned to Stock value
- Float_PreferStayInsideFenceNegativeLogicFactorWeight -5.0 from -3.0 - Stay slightly closer to Lancemates
- Float_SprintPreferStayInsideFenceNegativeLogicFactorWeight -1.0 from -0.5 - Stay slightly closer to Lancemates, returned to Stock value
- Float_FenceRadius 120.0 from 168.0 - Tighter Fence to enforce staying close to Lancemates
- Float_MinimumSensorLockQuality 25.0 from 30.0 - More frequent Sensor Locks
- Float_BuddyAloneFiringSolutionPreferenceWeight -0.8 from -0.4 - Stay slightly closer to Lancemates, returned to Stock value
- Float_BuddyAloneMoveNearbyPreferenceWeight -1.2 from -0.6 - Stay slightly closer to Lancemates, returned to Stock value
- Float_SprintBuddyAloneMoveNearbyPreferenceWeight -0.8 from -0.4 - Stay slightly closer to Lancemates, returned to Stock value
- Float_SprintPreferHigherDistanceFromClosestHostileFactorWeight 0.3 from 0.5 - Less afraid behavior
- Float_PreferLOSToFewestHostileFactorWeight 0.2 from 0.4 - Less afraid behavior
- Float_SprintPreferLOSToFewestHostileFactorWeight 0.4 from 0..5 - Less afraid behavior
- Float_PreferLowerMovementFactorWeight 0.8 from 0.0 - Greater Pip building for 1.3 Evasion
- Float_DFADamageMultiplier 1.75 from global = 1.4 - Greater chance of sniper "freaking out" and DFA when rushed, still pretty rare
- Float_PreferInsideMeleeRangeFactorWeight -1.5 from -1.0 - AI needs to fear a player operated HTC
- Float_BulwarkThresholdPercentage 0.0 from 80 - Nullified old Bulwark logic
- Float_PreferStayInsideFenceNegativeLogicFactorWeight -4.0 from -3.0 - Stay slightly closer to Lancemates
- Float_FenceRadius 168.0 from 192.0 - Tighter Fence to enforce staying close to Lancemates
- Float_PreferHigherRangedDefenseBonusLocationsFactorWeight 0.0 from global = 1.0 - ADDED - Stay out of shot killing Crystal Fields and other tiles
- Float_BuddyAloneFiringSolutionPreferenceWeight -1.0 from 0.0 - Increase odds of return fire from beyond LoS to support Lancemates
- Float_BuddyAloneMoveNearbyPreferenceWeight -0.6 from -0.8 - Lower odds to enter LoS in support of Lancemates
- Float_PreferAttackFromBehindHostileFactorWeight 0.2 from 0.1 - Slightly higher odds for rear attack
- Float_PreferLowerRangedToHitPenaltyLocationsFactorWeight 1.0 from global = 0.0 - ADDED - Try to avoid shot ruining tiles like Crystal Fields
- Float_PreferLowerMovementFactorWeight 0.9 from 0.7 - Greater Pip building for 1.3 Evasion
- Float_PreferHigherExpectedDamageToHostileFactorWeight 3.5 from 2.5 - Less afraid behavior
- Float_OptimalAllyDistance 96.0 from global = 168.0 - ADDED - Vehicles stick to Lancemates tighter
- Float_PreferOptimalDistanceToAllyFactorWeight 0.3 from 0.2 - Vehicles stick to Lancemates tighter
- Float_PreferLethalDamageToRearArcFromHostileFactorWeight -2.0 from -0.5 - Increased fear of units behind AI
- Float_SprintPreferLethalDamageToRearArcFromHostileFactorWeight -2.0 from -0.5 - Increased fear of units behind AI
- Float_SprintPreferHigherDistanceFromClosestHostileFactorWeight 0.4 from 0.3 - Stay out of melee Range
- Float_PreferLOSToFewestHostileFactorWeight 0.1 from global = 0.0 - ADDED - Small bump to stay out of LoS
- Float_SprintPreferLOSToFewestHostileFactorWeight 0.3 from global = 0.0 - ADDED - Small bump to stay out of LoS
- Float_PreferLowerMovementFactorWeight -1.0 from -0.8 - Greater Pip building for 1.3 Evasion
1.3.3 Release Notes:
- For BATTLETECH 1.3.2
- Global -
- Added new 1.3 variables, kept levels stock for now
- Adjusted overheat threshold to stock (Stock is now 1.99 from 2.6, Better AI was 1.9)
- Made some Reserve weight adjustments to let near dead units reserve less
1.3.0 Release Notes:
- For BATTLETECH 1.3.0
- Global - Added "k" : "Bool_AllowAttack", to allow 1.2.0 compliance
1.2.0 Release Notes:
- For BATTLETECH 1.1.2
- Float_FenceRadius adjusted to increments of 24 to match dot pitch across all files
- Global -
- Increased protecting rear arc from -1.5 to -1.75 and -1.5 to -2.0 sprint, slightly less chance of moving where rear is exposed
- Lowered point multiplier for rear armor counting from 15 to 10, more rear seeking attack weight
- Increased melee multipliers from 2.5 to 3 for normal and braced targets
- Bulwark % increased from 75% to 80%
- Lowered opportunity fire chance from 30% to 25% (20% stock) to let AI take more opportunity shots on vulnerable, but not primary targets
- Increased need to not be alone from -0.8 to -1.2 for slightly better chance lone unit will fall back and regroup with Lance
- Defensive Mood -
- Lowered overkill threshold for reserve from 90 to 80, defensive units less likely to reserve if expecting heavy fire
- Increased Melee Damage Multi from 2.5 to 3.0
- Last Man Standing -
- Increased Melee Damage Multi from 3.0 to 3.5
- Scout -
- Bulwark allowed, if rarely, set to 30%
- Increased fear of melee range from -0.8 to -1.0
- Enabled Melee Bonus Multiplier when attacking Braced targets, from 0.0 to 1.0, overall Scouts should still not want to melee, but can break Brace a little more frequently
- Lowered overkill threshold for reserve from 100 to 80, Scouts less likely to reserve if expecting heavy fire
- Set sprint hysteresis recovery from 0.0 to 1.0 (2.0 stock) to allow on/off sprint and deny endless sprinting
- Vehicles -
- Bool_RewriteNonAttackMoves reverted to stock "True" as precaution against stuck convoys, not like they can Brace anyway
- For BATTLETECH 1.1.1
- Overheat levels rebalanced - Lets more units fire up to heat capacity with enough restraint for sensible overheat/shutdown on vulnerable targets, overall more dmg/round
- Sensor Lock vs. firing adjusted toward fire by 5 across the board, global to 60, scout to 30 (global stock = 35)
- Bulwark up by 5 to 75 global
- Defensive Mood - Increased fear of heat generating dots from -0.3 to -0.6, AI was sheltering in Rad.Crystals on Lunar, lowered sprint exclusion radius to 100m and increased melee damage weight from 2 to 2.5
- Scout - Increased base reserve by 5 to 80, increased likelihood to move less from -0.9 to -1.5
- Vehicle - Defensive mood tuned for vehicle specific considerations
- Lastman - Added lowered conservative shot value for more "panicked" firing
Initial 1.0 Release
Major changes to these behavior .jsons:
- global/brawler - Wants to grant LoS to many enemies, deal damage and break Bulwark with melee
- global_def - Defensive mood for all units, should be more aggressive than stock
- sniper - Wants to stay high and out of sight for fire support, will DFA more readily if closed on
- scout - Flanks to the sides and seeks out rear arcs, provides Sensor Lock if able
- sensorlock - Mood sets defensive posturing when using Sensor Lock
- vehicle - Flee from melee range, deal damage, not able to reserve by default
- meleeonly - Amped up stock config that seeks out melee attacks
- lastmanstanding - Will do anything to take someone down with it and moves to more defensive areas
- AWS-8Q - Sniper changed to Brawler
- ENF-4R - Brawler changed to Sniper
- LCT-1M - Scout changed to Sniper
- QKD-4G+5A - Both Brawlers changed to Scouts
- SHD-2D - Brawler changed to Scout
- UM-R60 - Brawler changed to Sniper
- ZEU-6S - Brawler changed to Sniper
Massive thanks to Mpstark for making ModTek and helping me with that side of the mod. Also, a thank you to everyone who has helped provide feedback along the way here going back to beta!
Better AI is a ModTek mod that improves the enemy AI and acts similar to a human player. The AI can reserve, will use cover/terrain more intelligently and utilize the dynamic roles to a greater extent. The AI will pose a greater challenge than stock, but not insurmountable in our experience. I've done my best to make the AI as tactically proficient as I can. It should make less dumb moves overall. I'm always looking for suggestions on how to make it better, please post your opinions in this thread.
Mpstark, the creator of ModTek, is helping me with that side of the mod. Currently, other than the behaviorVariables folder the AI's .jsons reside in, the mod also edits some of the mechdef files to reassign dynamic role tags (like setting the UrbanMech from Brawler to Sniper) for better unit profiling. Going forward I'm excited to be working with him in exploring how far we can change the AI.
Better AI Add-Ons
Permanent Evasion Add-On:
Download Better AI - Permanent Evasion Add On 1.9.1 (For BATTLETECH 1.9.1 +)
On github @ Amechwarrior/BetterAI-Permanent-Evasion-Add-On/releases
This optional build is for the Permanent Evasion mod, forks of that mod and modpacks that use them. It changes the "k" : "Float_PipStripAttackProbabilityThreshold", variable that lets the AI know if an attack with strip a Pip or not, set to "1.0" or false. It also removes the threshold for conservative shots threshold.
This add-on is setup as an advanced JSON merge to Better AI and should not need to be updated along side the base mod any longer.
AI Modding Help:
Most, but not all of the AI's behavior variables are stored in the folder:
"BATTLETECH\BattleTech_Data\StreamingAssets\data\behaviorVariables"
These .json files can be read and edited in nearly any text editor, but I would recommend Notepad++ with some kind of compare feature added on.
[Mod edit: No unapproved links]
Most of the variables are defined as either "float ," integer," or "Boolean" value and changing them will affect how the AI weighs that variable.
/* Influence Factor Weight for preferring moving less. */
"k" : "Float_PreferLowerMovementFactorWeight",
"v" : {
"type" : "Float",
"floatVal" : -0.5,
This float variable is the weight of how much the AI will want to move less. Making the number a larger negative value will give more weight to moves that go farther, and thus generate more Evasive Pips. Making the number a positive value will do the opposite and make the AI want to stay closer to where it is. Setting any value to 0.0 may cause it to be ignored entirely by default.
Usually, most values will be somewhere between 0.1 and 1. A +/- 1 is usually a very strong value, very few values reach as high as +2. Some variables work in meters or as a percentage out of 100 and they are noted in the comments.
"BATTLETECH\BattleTech_Data\StreamingAssets\data\behaviorVariables"
These .json files can be read and edited in nearly any text editor, but I would recommend Notepad++ with some kind of compare feature added on.
[Mod edit: No unapproved links]
Most of the variables are defined as either "float ," integer," or "Boolean" value and changing them will affect how the AI weighs that variable.
- Float - A numerical value with decimal point "1.1"
- Integer - A numerical value with no decimal points, a whole number. "1"
- Boolean - True or False
/* Influence Factor Weight for preferring moving less. */
"k" : "Float_PreferLowerMovementFactorWeight",
"v" : {
"type" : "Float",
"floatVal" : -0.5,
This float variable is the weight of how much the AI will want to move less. Making the number a larger negative value will give more weight to moves that go farther, and thus generate more Evasive Pips. Making the number a positive value will do the opposite and make the AI want to stay closer to where it is. Setting any value to 0.0 may cause it to be ignored entirely by default.
Usually, most values will be somewhere between 0.1 and 1. A +/- 1 is usually a very strong value, very few values reach as high as +2. Some variables work in meters or as a percentage out of 100 and they are noted in the comments.
Link to Stock+Modded AI Variables Google Sheet
I've listed every single variable in the behaviorVariables folder along with HBS's comments and arranged the active and inactive files beside the default global.json and unused.json. Feel free to copy or download this file for your own AI modding needs. I plan to use it by inserting a new column for a modded global.json next to the stock so I can easily compare my changes to the default and any other files.
global.json + global_def.json
The global.json describes the default decision weights for all AI. When the AI is in a defensive mood (see moods below) it will pull on the global_def changes before the base global.json. Below in the spoiler field are my notes on the variables in beta, while the values have been changed and a lot have been removed, most of this still applies.
unused.json
This is a listing of unused variables that can be pasted in to the global, or another valid behavior file and once set to a non-zero value, become an active weight in the system. I'd like to thank HBS for including these as it greatly expands our modding potential.
role_XXXX.json
There are at least 6 active dynamic 'Mech role files in the game, each with its own defensive mood file ending in "_def" which is a blank file. These roles can be adjusted on the fly, changing as needed based on the unit_role_xxxx tag. Each mechdef contains just one role, and all units can pull brawler if others are filled. The Brawler role is effectively the default role of the AI and the global.json has been setup to reflect the Brawler fighting style with wanting to enter melee range and other adjustments. This ensures in a fallback situation, the AI will hunt down the players units and engage.
- role_brawler (blank)
- role_scout
- role_sniper
- role_meleeonly
- role_noncombatant (blank)
- role_lastmanstanding (blank)
For example, in the Atlas' mechdef there is a listing of its tags:
"MechTags": {
"items": [
"unit_indirectFire",
"unit_mech",
"unit_assault",
"unit_release",
"unit_ready",
"unit_lance_tank",
"unit_role_brawler"
],
The "unit_role_brawler" is the tag to let the game know to use the role_brawler.json to before default values. In this case, the file is blank. The default global.json is effectively the brawler role and brawler is also the default role mechs fall back to. Some roles also have a limit to how many units may pull a certain role. For Brawlers and Snipers, this is found at the end of the CombatGameConstants.json:
"DynamicAIRoleConstants":
{
"hysteresis": 0.1,
"brawlerMinAbs": 0,
"brawlerMaxFrac": 1.0,
"brawlerTagMultiplier": 2.0,
"sniperMinAbs": 0,
"sniperMaxFrac": 0.75,
"sniperTagMultiplier": 2.0
}
We can see that anything tagged brawler or sniper has those tag weights doubled, where the "scout" role isn't managed by this multiplier system. The min/max should mean that no more than 3/4 of an enemy force can be using role_sniper.json at any one time. This means even if the entire enemy force is GRF-1N's, they won't all jump away and PPC snipe you forever, as one of them will pull brawler and close to contact.
The scout role emphasizes skirting the edges and surrounding the enemy, while lowering the values for melee related variables. The sniper role emphasizes staying put and shooting targets over the default closing to melee range. You can have up to 3 Scouts in a Lance, but 4 will force them all in to Brawlers and almost never return.
AI PERSONALITY + FACTION
These AIPersonality .jsons seem to be active but unused at this time. All faction files are empty and I do not know the variable needed to declare them. The AI Personality variable can been seen in the pilotdefs:
"AIPersonality": "Undefined",
I have not done any testing with either factions or personalities. I'd expect personalities to work if declared.
AI MOODS
The five moods are:
- Aggressive
- Defensive
- Sensor Lock
- Undefined
- Ruthless (1.1 addition)
I discovered in beta that the AI would always move units in the same order unless a unit was knocked over or shutdown. The current AI still mostly follows this, but it is able to jump queue in some situations. This is most readily apparent in Skirmish vs 4 medium 'Mechs all in Phase 3. Watch for the last one to act and strike it with everything you got and make it unsteady. It will be the first to act in the next round, if you do nothing, the round after this it will go back to moving last if it is no longer unsteady. If an AI unit is Fallen, Shutdown or Unsteady they will move first in that phase. If you have multiple AI units in those states, they will move in order of "Fallen > Shutdown > Unsteady" and multiple units in the same state will follow the normal cue as if they were standing. The AI doesn't consider being on the verge or death a condition to move first. So you can can have an AI unit with 1 CT remaining wait its turn nicely until it is time to move.
\BATTLETECH\BattleTech_Data\StreamingAssets\data\debug\settings.json
"aiLogCacheWriteImmediate": true
Will generate a ton of useful files in the "...\BATTLETECH\AI_Logs" folder in Windows. This is new to 1.1 and probably the easiest to read as the files are separated by individual turns and not one long continuous log file.
Alternate Logging:
Adding these three variables to the global.json and changing them to "true" will leave a set of AI dump files in "...\BATTLETECH\AI_Logs" for you to dig through. You can also turn on the other logging options in the debug folder, but most of that is duplicated here.
{
/* Whether to log influence map calculations. */
"k" : "Bool_LogInfluenceMapCalculations",
"v" : {
"type" : "Bool",
"boolVal" : false,
}
},
{
/* Whether to log influence map calculation profiling
information. */
"k" : "Bool_ProfileInfluenceMapCalculations",
"v" : {
"type" : "Bool",
"boolVal" : false,
}
},
{
/* Whether to log behavior tree logic. */
"k" : "Bool_LogBehaviorTreeLogic",
"v" : {
"type" : "Bool",
"boolVal" : false,
}
},
"aiLogCacheWriteImmediate": true
Will generate a ton of useful files in the "...\BATTLETECH\AI_Logs" folder in Windows. This is new to 1.1 and probably the easiest to read as the files are separated by individual turns and not one long continuous log file.
Alternate Logging:
Adding these three variables to the global.json and changing them to "true" will leave a set of AI dump files in "...\BATTLETECH\AI_Logs" for you to dig through. You can also turn on the other logging options in the debug folder, but most of that is duplicated here.
{
/* Whether to log influence map calculations. */
"k" : "Bool_LogInfluenceMapCalculations",
"v" : {
"type" : "Bool",
"boolVal" : false,
}
},
{
/* Whether to log influence map calculation profiling
information. */
"k" : "Bool_ProfileInfluenceMapCalculations",
"v" : {
"type" : "Bool",
"boolVal" : false,
}
},
{
/* Whether to log behavior tree logic. */
"k" : "Bool_LogBehaviorTreeLogic",
"v" : {
"type" : "Bool",
"boolVal" : false,
}
},
BATTLETECH\BattleTech_Data\StreamingAssets\data\debug\settings.json
add lines:
"TestToolsEnabled" : true,
"PlayerOneIsAIControlled": true,
"PlayerTwoIsAIControlled": true,
just above the
"disablePhysicsOnLoad": true,
"disableLoggingOnLoad": true,
Save the file. Big thanks to GUD and FlukeyFiddler on discord for figuring out how to get AI vs. AI in skirmish mode. This also works in PvP:
Huge thanks to Best Girl on discord! So, we did some testing and with a shared debug/settings.json the AI can play over the network. Both players need those statements and the host will automatically be controlled by their local AI files. The guest doesn't need to have altered their behaviorVariables at all. This allows two different AI to fight each other.
add lines:
"TestToolsEnabled" : true,
"PlayerOneIsAIControlled": true,
"PlayerTwoIsAIControlled": true,
just above the
"disablePhysicsOnLoad": true,
"disableLoggingOnLoad": true,
Save the file. Big thanks to GUD and FlukeyFiddler on discord for figuring out how to get AI vs. AI in skirmish mode. This also works in PvP:
Huge thanks to Best Girl on discord! So, we did some testing and with a shared debug/settings.json the AI can play over the network. Both players need those statements and the host will automatically be controlled by their local AI files. The guest doesn't need to have altered their behaviorVariables at all. This allows two different AI to fight each other.
Last edited: