fix(ground-ai): finish single-vehicle combat decisions

Check the live barrel trajectory against the exposed target and shorten
fire delays. Resolve automatic and secondary guns using stock weapon data.
Keep short halts and withdrawals coherent, follow the order while engaged,
and reverse on the route with direction-aware obstacle recovery.

Verified daScript loading and native AI script readiness in the guarded
2.61.0.64 lab client. Battle behavior requires manual acceptance.
This commit is contained in:
N0VAN0M4LY committed 2026-12-06 01:51:00 +08:00
1 parent ee360a5042
commit ee7bb12092
34 files changed
+1030 -549

No files matched your search

@@ -686,7 +686,15 @@
},
"behavior": {
"scoreIntervalSec": "Behavior scoring interval",
"minHoldSec": "Minimum time a behavior is kept",
"advanceHoldSec": "Advance commitment",
"engageHoldSec": "Engage while moving commitment",
"haltHoldSec": "Short halt commitment",
"coverHoldSec": "Take cover commitment",
"repositionHoldSec": "Reposition commitment",
"postHoldSec": "Hold position commitment",
"disperseHoldSec": "Disperse commitment",
"targetValueWeight": "Weight of a viable shot while moving",
"nearThreatHaltBonus": "Short-halt bonus under a close threat",
"switchMargin": "Extra score needed to switch behavior",
"advanceScore": "Score: advance along the order route",
"engageScore": "Score: engage on the move",
@@ -704,9 +712,8 @@
"hullAngleDeg": "Hull angle to the main threat",
"faceToleranceDeg": "Facing tolerance while standing",
"faceMinDanger": "Threat danger needed to face it",
"faceHaltLimitDeg": "Facing error that turns the hull during a short halt",
"reverseTravelAngleDeg": "Threat angle off the travel direction for driving backwards",
"reverseMaxGoalDistM": "Drive backwards only toward a goal within",
"reverseMaxTurnDistM": "Max distance to the next turn or route end when reversing",
"reverseMinSpeedMps": "Lowest top reverse speed for driving backwards",
"reverseHoldSec": "Minimum time between switching forwards and backwards"
},
@@ -734,17 +741,22 @@
"enemyReloadSec": "How long a target counts as reloading after it fired",
"fleetingThresholdBonus": "Threshold drop for a target about to slip away",
"fleetingLateralMps": "Crossing speed of a slipping-away target",
"bigGunThresholdPenalty": "Threshold rise for big slow-loading guns",
"fleetingLookAheadSec": "Look-ahead for losing line of sight",
"reloadThresholdPenalty": "Fire-threshold increase for long reloads",
"longReloadSec": "Reload time for the full threshold penalty",
"lowAmmoRounds": "Ammunition count below which shots are conserved",
"lowAmmoThresholdPenalty": "Fire-threshold increase with little ammunition",
"aimSkill": "Crew skill for aiming spread",
"autocannonMinShotsPerSec": "Minimum firing rate for automatic cannons (rounds/s)",
"retreatThresholdPenalty": "Threshold rise while pulling back to cover",
"minShotIntervalSec": "Minimum main-gun shot interval",
"autocannonAimSlack": "Autocannon aim slack (times target size)",
"burstSec": "Burst length",
"burstPauseSec": "Pause between bursts",
"burstRecheckSec": "Safety re-check interval within a burst",
"autocannonReloadDetectSec": "Autocannon not-ready time that counts as a reload",
"auxWeapons": "Fire secondary and coaxial weapons",
"auxMaxRangeM": "Secondary and coaxial weapon range",
"auxFireAtArmor": "Secondary and coaxial weapons also fire at armored targets",
"auxFireAtArmor": "Coaxial weapons also fire at non-light vehicles",
"friendlyCorridorM": "Friendly fire corridor width",
"ballisticStepMaxM": "Ballistic occlusion step length",
"ballisticSweepRadiusM": "Ballistic sphere sweep radius",
@@ -686,7 +686,15 @@
},
"behavior": {
"scoreIntervalSec": "行为打分间隔",
"minHoldSec": "行为最短保持时间",
"advanceHoldSec": "??????",
"engageHoldSec": "????????",
"haltHoldSec": "????????",
"coverHoldSec": "????????",
"repositionHoldSec": "??????",
"postHoldSec": "??????",
"disperseHoldSec": "??????",
"targetValueWeight": "???????????",
"nearThreatHaltBonus": "??????????",
"switchMargin": "切换行为所需高出的分数",
"advanceScore": "得分:沿任务路线推进",
"engageScore": "得分:交战推进",
@@ -704,9 +712,8 @@
"hullAngleDeg": "车头对主威胁的倾角",
"faceToleranceDeg": "停车时朝向容差",
"faceMinDanger": "需要车头对准的威胁危险度下限",
"faceHaltLimitDeg": "短停时朝向偏差超过多少才转车体",
"reverseTravelAngleDeg": "威胁偏离行进方向多少度时倒车跟路",
"reverseMaxGoalDistM": "仅在离目的地这么近时倒车跟路",
"reverseMaxTurnDistM": "????????????????????",
"reverseMinSpeedMps": "倒车跟路所需的最低倒车极速",
"reverseHoldSec": "前进与倒车切换的最短间隔"
},
@@ -734,13 +741,18 @@
"enemyReloadSec": "目标开火后视为装填中的时长",
"fleetingThresholdBonus": "目标即将离开视线时门槛降低",
"fleetingLateralMps": "视为即将离开视线的横穿速度",
"bigGunThresholdPenalty": "大口径慢装填火炮的门槛升高",
"fleetingLookAheadSec": "?????????",
"reloadThresholdPenalty": "????????????",
"longReloadSec": "????????????",
"lowAmmoRounds": "???????????",
"lowAmmoThresholdPenalty": "????????????",
"aimSkill": "???????????",
"autocannonMinShotsPerSec": "???????????/??",
"retreatThresholdPenalty": "退入掩体途中的门槛升高",
"minShotIntervalSec": "主炮最短开火间隔",
"autocannonAimSlack": "机炮放宽倍数(目标尺寸的倍数)",
"burstSec": "点射时长",
"burstPauseSec": "点射间隔",
"burstRecheckSec": "点射中复查弹道和友军的间隔",
"autocannonReloadDetectSec": "机炮持续未就绪多久算换弹",
"auxWeapons": "使用副炮和并列武器",
"auxMaxRangeM": "副炮和并列武器的射击距离",
@@ -255,7 +255,15 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
customOnly: true,
fields: [
num('behavior', 'scoreIntervalSec', 0.1, 3, 's'),
num('behavior', 'minHoldSec', 0, 10, 's'),
num('behavior', 'advanceHoldSec', 0, 10, 's'),
num('behavior', 'engageHoldSec', 0, 10, 's'),
num('behavior', 'haltHoldSec', 0, 10, 's'),
num('behavior', 'coverHoldSec', 0, 10, 's'),
num('behavior', 'repositionHoldSec', 0, 10, 's'),
num('behavior', 'postHoldSec', 0, 10, 's'),
num('behavior', 'disperseHoldSec', 0, 10, 's'),
num('behavior', 'targetValueWeight', 0, 1),
num('behavior', 'nearThreatHaltBonus', 0, 1),
num('behavior', 'switchMargin', 0, 1),
num('behavior', 'advanceScore', 0, 1),
num('behavior', 'engageScore', 0, 1),
@@ -273,9 +281,8 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
num('behavior', 'hullAngleDeg', 0, 45, '°'),
num('behavior', 'faceToleranceDeg', 3, 60, '°'),
num('behavior', 'faceMinDanger', 0, 2),
num('behavior', 'faceHaltLimitDeg', 10, 180, '°'),
num('behavior', 'reverseTravelAngleDeg', 60, 180, '°'),
num('behavior', 'reverseMaxGoalDistM', 0, 2000, 'm'),
num('behavior', 'reverseMaxTurnDistM', 0, 200, 'm'),
num('behavior', 'reverseMinSpeedMps', 0.5, 10, 'm/s'),
num('behavior', 'reverseHoldSec', 0, 20, 's'),
],
@@ -308,13 +315,18 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
num('fireControl', 'enemyReloadSec', 0, 15, 's'),
num('fireControl', 'fleetingThresholdBonus', 0, 0.5),
num('fireControl', 'fleetingLateralMps', 0.5, 15, 'm/s'),
num('fireControl', 'bigGunThresholdPenalty', 0, 0.5),
num('fireControl', 'fleetingLookAheadSec', 0.1, 2, 's'),
num('fireControl', 'reloadThresholdPenalty', 0, 0.5),
num('fireControl', 'longReloadSec', 1, 60, 's'),
int('fireControl', 'lowAmmoRounds', 1, 60),
num('fireControl', 'lowAmmoThresholdPenalty', 0, 0.5),
num('fireControl', 'aimSkill', 0, 1),
num('fireControl', 'autocannonMinShotsPerSec', 0.5, 30),
num('fireControl', 'retreatThresholdPenalty', 0, 0.6),
num('fireControl', 'minShotIntervalSec', 0.1, 5, 's'),
num('fireControl', 'autocannonAimSlack', 1, 10),
num('fireControl', 'burstSec', 0.2, 6, 's'),
num('fireControl', 'burstPauseSec', 0, 5, 's'),
num('fireControl', 'burstRecheckSec', 0.05, 2, 's'),
num('fireControl', 'autocannonReloadDetectSec', 0.1, 3, 's'),
{ id: 'groundAi.fireControl.auxWeapons', section: 'fireControl', field: 'auxWeapons', kind: 'bool' },
num('fireControl', 'auxMaxRangeM', 30, 1500, 'm'),
+17 -5
View File
@@ -231,7 +231,15 @@ const GroundAiTurretSchema = z.object({
const GroundAiBehaviorSchema = z.object({
scoreIntervalSec: z.number().min(0.1).max(3),
minHoldSec: z.number().min(0).max(10),
advanceHoldSec: z.number().min(0).max(10),
engageHoldSec: z.number().min(0).max(10),
haltHoldSec: z.number().min(0).max(10),
coverHoldSec: z.number().min(0).max(10),
repositionHoldSec: z.number().min(0).max(10),
postHoldSec: z.number().min(0).max(10),
disperseHoldSec: z.number().min(0).max(10),
targetValueWeight: z.number().min(0).max(1),
nearThreatHaltBonus: z.number().min(0).max(1),
switchMargin: z.number().min(0).max(1),
advanceScore: z.number().min(0).max(1),
engageScore: z.number().min(0).max(1),
@@ -249,9 +257,8 @@ const GroundAiBehaviorSchema = z.object({
hullAngleDeg: z.number().min(0).max(45),
faceToleranceDeg: z.number().min(3).max(60),
faceMinDanger: z.number().min(0).max(2),
faceHaltLimitDeg: z.number().min(10).max(180),
reverseTravelAngleDeg: z.number().min(60).max(180),
reverseMaxGoalDistM: z.number().min(0).max(2000),
reverseMaxTurnDistM: z.number().min(0).max(200),
reverseMinSpeedMps: z.number().min(0.5).max(10),
reverseHoldSec: z.number().min(0).max(20),
});
@@ -291,13 +298,18 @@ const GroundAiFireControlSchema = z.object({
enemyReloadSec: z.number().min(0).max(15),
fleetingThresholdBonus: z.number().min(0).max(0.5),
fleetingLateralMps: z.number().min(0.5).max(15),
bigGunThresholdPenalty: z.number().min(0).max(0.5),
fleetingLookAheadSec: z.number().min(0.1).max(2),
reloadThresholdPenalty: z.number().min(0).max(0.5),
longReloadSec: z.number().min(1).max(60),
lowAmmoRounds: z.number().int().min(1).max(60),
lowAmmoThresholdPenalty: z.number().min(0).max(0.5),
aimSkill: z.number().min(0).max(1),
autocannonMinShotsPerSec: z.number().min(0.5).max(30),
retreatThresholdPenalty: z.number().min(0).max(0.6),
minShotIntervalSec: z.number().min(0.1).max(5),
autocannonAimSlack: z.number().min(1).max(10),
burstSec: z.number().min(0.2).max(6),
burstPauseSec: z.number().min(0).max(5),
burstRecheckSec: z.number().min(0.05).max(2),
autocannonReloadDetectSec: z.number().min(0.1).max(3),
auxWeapons: z.boolean(),
auxMaxRangeM: z.number().min(30).max(1500),
+17 -5
View File
@@ -377,7 +377,15 @@ function readTurretSection(turret: TuningReader): GroundAiTuning['turret'] {
function readBehaviorSection(bhv: TuningReader): GroundAiTuning['behavior'] {
return {
scoreIntervalSec: bhv.number('scoreIntervalSec', { min: 0.1, max: 3 }),
minHoldSec: bhv.number('minHoldSec', { min: 0, max: 10 }),
advanceHoldSec: bhv.number('advanceHoldSec', { min: 0, max: 10 }),
engageHoldSec: bhv.number('engageHoldSec', { min: 0, max: 10 }),
haltHoldSec: bhv.number('haltHoldSec', { min: 0, max: 10 }),
coverHoldSec: bhv.number('coverHoldSec', { min: 0, max: 10 }),
repositionHoldSec: bhv.number('repositionHoldSec', { min: 0, max: 10 }),
postHoldSec: bhv.number('postHoldSec', { min: 0, max: 10 }),
disperseHoldSec: bhv.number('disperseHoldSec', { min: 0, max: 10 }),
targetValueWeight: bhv.number('targetValueWeight', { min: 0, max: 1 }),
nearThreatHaltBonus: bhv.number('nearThreatHaltBonus', { min: 0, max: 1 }),
switchMargin: bhv.number('switchMargin', { min: 0, max: 1 }),
advanceScore: bhv.number('advanceScore', { min: 0, max: 1 }),
engageScore: bhv.number('engageScore', { min: 0, max: 1 }),
@@ -395,9 +403,8 @@ function readBehaviorSection(bhv: TuningReader): GroundAiTuning['behavior'] {
hullAngleDeg: bhv.number('hullAngleDeg', { min: 0, max: 45 }),
faceToleranceDeg: bhv.number('faceToleranceDeg', { min: 3, max: 60 }),
faceMinDanger: bhv.number('faceMinDanger', { min: 0, max: 2 }),
faceHaltLimitDeg: bhv.number('faceHaltLimitDeg', { min: 10, max: 180 }),
reverseTravelAngleDeg: bhv.number('reverseTravelAngleDeg', { min: 60, max: 180 }),
reverseMaxGoalDistM: bhv.number('reverseMaxGoalDistM', { min: 0, max: 2000 }),
reverseMaxTurnDistM: bhv.number('reverseMaxTurnDistM', { min: 0, max: 200 }),
reverseMinSpeedMps: bhv.number('reverseMinSpeedMps', { min: 0.5, max: 10 }),
reverseHoldSec: bhv.number('reverseHoldSec', { min: 0, max: 20 }),
};
@@ -462,13 +469,18 @@ function readFireControlSection(fc: TuningReader): GroundAiTuning['fireControl']
enemyReloadSec: fc.number('enemyReloadSec', { min: 0, max: 15 }),
fleetingThresholdBonus: fc.number('fleetingThresholdBonus', { min: 0, max: 0.5 }),
fleetingLateralMps: fc.number('fleetingLateralMps', { min: 0.5, max: 15 }),
bigGunThresholdPenalty: fc.number('bigGunThresholdPenalty', { min: 0, max: 0.5 }),
fleetingLookAheadSec: fc.number('fleetingLookAheadSec', { min: 0.1, max: 2 }),
reloadThresholdPenalty: fc.number('reloadThresholdPenalty', { min: 0, max: 0.5 }),
longReloadSec: fc.number('longReloadSec', { min: 1, max: 60 }),
lowAmmoRounds: fc.int('lowAmmoRounds', { min: 1, max: 60 }),
lowAmmoThresholdPenalty: fc.number('lowAmmoThresholdPenalty', { min: 0, max: 0.5 }),
aimSkill: fc.number('aimSkill', { min: 0, max: 1 }),
autocannonMinShotsPerSec: fc.number('autocannonMinShotsPerSec', { min: 0.5, max: 30 }),
retreatThresholdPenalty: fc.number('retreatThresholdPenalty', { min: 0, max: 0.6 }),
minShotIntervalSec: fc.number('minShotIntervalSec', { min: 0.1, max: 5 }),
autocannonAimSlack: fc.number('autocannonAimSlack', { min: 1, max: 10 }),
burstSec: fc.number('burstSec', { min: 0.2, max: 6 }),
burstPauseSec: fc.number('burstPauseSec', { min: 0, max: 5 }),
burstRecheckSec: fc.number('burstRecheckSec', { min: 0.05, max: 2 }),
autocannonReloadDetectSec: fc.number('autocannonReloadDetectSec', { min: 0.1, max: 3 }),
auxWeapons: fc.bool('auxWeapons'),
auxMaxRangeM: fc.number('auxMaxRangeM', { min: 30, max: 1500 }),
+34 -35
View File
@@ -346,24 +346,22 @@
"scanPeriodSec": 6.0
},
// Hull channel (decision layer design, section 7). Every scoreIntervalSec (at once when a target
// appears or is lost, a reload starts or ends, or the bot is hit) each behavior gets a score and
// the best runs; a running one is kept for minHoldSec, then until another scores switchMargin
// more. Scores: advance (no target in sight), engage (target in sight; +urgencyWeight when the
// order is urgent), halt (the trigger asks to stand for its shot; +urgencyWeight when not urgent,
// -crossfirePenalty per extra enemy aiming at the bot), cover (reloading with a known threat;
// +coverDangerWeight x danger, -coverOffensivePenalty on an urgent attack, not again for
// coverRetrySec after no cover was found), reposition (engagement stuck), hold (at the post,
// watching the last exit, waiting at the rally point) and disperse (crowded). Engaging on the
// move slows to the speed the trigger asks for; an urgent order keeps urgentSpeedKeep of the
// march speed. Medium and heavy tanks and tank destroyers face the most dangerous threat (danger
// at least faceMinDanger) angled by hullAngleDeg: holding within faceToleranceDeg, on a short halt
// only when more than faceHaltLimitDeg off. With that threat more than reverseTravelAngleDeg off
// the direction of travel and the goal within reverseMaxGoalDistM, a vehicle reversing at least
// reverseMinSpeedMps drives its route backwards; it switches at most every reverseHoldSec.
// Hull channel: choose a behavior by score, holding each for its configured commitment time
// unless an emergency or a large score difference interrupts it. A cover withdrawal runs
// through its arrival or timeout. A short halt lasts through the weapon's shooting window.
// Tracked tanks and tank destroyers face the main threat at the post or during a halt.
// They can reverse along a short route segment to keep their front toward that threat.
"behavior": {
"scoreIntervalSec": 0.5,
"minHoldSec": 1.5,
"advanceHoldSec": 1.5,
"engageHoldSec": 1.5,
"haltHoldSec": 3.0,
"coverHoldSec": 2.0,
"repositionHoldSec": 2.0,
"postHoldSec": 1.5,
"disperseHoldSec": 1.5,
"targetValueWeight": 0.1,
"nearThreatHaltBonus": 0.28,
"switchMargin": 0.15,
"advanceScore": 0.5,
"engageScore": 0.55,
@@ -381,9 +379,8 @@
"hullAngleDeg": 20.0,
"faceToleranceDeg": 15.0,
"faceMinDanger": 0.15,
"faceHaltLimitDeg": 60.0,
"reverseTravelAngleDeg": 110.0,
"reverseMaxGoalDistM": 200.0,
"reverseMaxTurnDistM": 45.0,
"reverseMinSpeedMps": 2.5,
"reverseHoldSec": 3.0
},
@@ -396,10 +393,9 @@
// lead uncertainty on a crossing target, with the barrel's current offset as the mean error.
// The threshold starts at fireThreshold and drops by aimingThresholdBonus when the target aims
// at the bot, by up to closeThresholdBonus inside closeRangeM, by enemyReloadThresholdBonus for
// enemyReloadSec after the target fired, and by fleetingThresholdBonus when it crosses faster
// than fleetingLateralMps partly hidden; it rises by up to bigGunThresholdPenalty for guns above
// 75 mm and by retreatThresholdPenalty while pulling back to cover, and never goes below
// minFireThreshold. Main-gun shots are at least minShotIntervalSec apart.
// enemyReloadSec after the target fired, and by fleetingThresholdBonus if its estimated motion
// will take it out of sight. Longer reloads, scarce ammunition and falling back raise the threshold.
// The pre-fire budget limits ballistic checks per frame. Every firing request gets fresh checks.
"fireControl": {
"maxEngageRangeM": 1250.0,
"closeRangeM": 100.0,
@@ -407,19 +403,19 @@
"longRangeM": 800.0,
// At or below this speed the bot counts as standing (also the answer "stop" to a speed request).
"stopSpeedMaxMps": 0.45,
"longRangeWindowSec": 4.0,
"longRangeWindowSec": 1.0,
// Fixed (casemate) guns: how far off the gun may be before the hull is asked to turn.
"baseAlignDeg": 0.42,
// Outside close range, the rate at which barrel alignment drifts relative to the aim direction.
"barrelSettleDegSec": 1.8,
"closeSettleHoldSec": 0.08,
"settleHoldSec": 0.20,
"aimErrorDeg": 0.12,
"closeSettleHoldSec": 0.06,
"settleHoldSec": 0.12,
"aimErrorDeg": 0.07,
"moveErrDegPerMps": 0.35,
"turnErrDegPerDegSec": 0.03,
"stabErrFactor": 0.2,
"targetHalfHeightM": 1.0,
"fireThreshold": 0.35,
"fireThreshold": 0.45,
"minFireThreshold": 0.1,
"aimingThresholdBonus": 0.1,
"closeThresholdBonus": 0.15,
@@ -427,20 +423,23 @@
"enemyReloadSec": 3.0,
"fleetingThresholdBonus": 0.1,
"fleetingLateralMps": 3.0,
"bigGunThresholdPenalty": 0.08,
"fleetingLookAheadSec": 0.65,
"reloadThresholdPenalty": 0.08,
"longReloadSec": 15.0,
"lowAmmoRounds": 5,
"lowAmmoThresholdPenalty": 0.08,
"aimSkill": 0.5,
"autocannonMinShotsPerSec": 1.5,
"retreatThresholdPenalty": 0.2,
"minShotIntervalSec": 0.65,
// Belt-fed autocannons (6.3): fire while within autocannonAimSlack times the target's angular
// half size, in bursts of burstSec with burstPauseSec between, checking barrel, trajectory and
// friendlies again every burstRecheckSec. Not ready for longer than autocannonReloadDetectSec
// counts as a reload.
// Automatic cannons are identified from stock belt and firing-rate data. They fire in bursts
// while within the aim slack. A longer wait between rounds counts as a reload.
"autocannonAimSlack": 3.0,
"burstSec": 1.2,
"burstPauseSec": 0.6,
"burstRecheckSec": 0.3,
"autocannonReloadDetectSec": 0.6,
// Secondary cannon and coaxial weapons (6.4) fire bursts alongside the main gun at light
// vehicles within auxMaxRangeM (at any vehicle with auxFireAtArmor).
// Secondary and coaxial guns have their own aim and ballistic checks. The armor toggle allows
// coaxial fire at vehicles outside the light-vehicle filter.
"auxWeapons": true,
"auxMaxRangeM": 300.0,
"auxFireAtArmor": false,