feat(ground-ai): add the hull decision channel

Score driving behaviors and reuse the existing action handlers. Face the
main threat and support reverse travel on the navigation corridor.
This commit is contained in:
N0VAN0M4LY committed 2026-12-06 01:11:55 +08:00
1 parent 4e658cae9c
commit ee360a5042
16 files changed
+737 -269

No files matched your search

+30 -14
View File
@@ -59,6 +59,7 @@ export function readGroundAiTuning(reader: TuningReader): GroundAiTuning {
estimation: readEstimationSection(reader.object('estimation')),
threat: readThreatSection(reader.object('threat')),
turret: readTurretSection(reader.object('turret')),
behavior: readBehaviorSection(reader.object('behavior')),
fireControl: readFireControlSection(reader.object('fireControl')),
diagnostics: {
telemetry: diag.bool('telemetry'),
@@ -325,17 +326,12 @@ function readStateMachineSection(sm: TuningReader): GroundAiTuning['stateMachine
throw new TuningError('tuning file ground-ai.jsonc: stateMachine.coverMaxDistM must be > coverMinDistM');
}
return {
preaimAngleDeg: sm.number('preaimAngleDeg', { min: 1.0, max: 30.0 }),
movingShotWaitSec: sm.number('movingShotWaitSec', { min: 0.25, max: 5.0 }),
shortHaltMaxSec: sm.number('shortHaltMaxSec', { min: 0.5, max: 12.0 }),
shortHaltCooldownSec: sm.number('shortHaltCooldownSec', { min: 0.5, max: 20.0 }),
turnLaunchSpeedMps: sm.number('turnLaunchSpeedMps', { min: 0.5, max: 6.0 }),
coverMinDistM,
coverMaxDistM,
coverRetreatBudgetSec: sm.number('coverRetreatBudgetSec', { min: 1.5, max: 20.0 }),
reloadAdvanceAngleDeg: sm.number('reloadAdvanceAngleDeg', { min: 0.0, max: 45.0 }),
hullAngleTriggerDeg: sm.number('hullAngleTriggerDeg', { min: 15.0, max: 75.0 }),
hullAngleTargetDeg: sm.number('hullAngleTargetDeg', { min: 0.0, max: 35.0 }),
maxTotalHaltSec: sm.number('maxTotalHaltSec', { min: 3.0, max: 40.0 }),
stalemateMissShots: sm.int('stalemateMissShots', { min: 1, max: 8 }),
stalemateNoShotHalts: sm.int('stalemateNoShotHalts', { min: 1, max: 6 }),
@@ -378,6 +374,35 @@ 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 }),
switchMargin: bhv.number('switchMargin', { min: 0, max: 1 }),
advanceScore: bhv.number('advanceScore', { min: 0, max: 1 }),
engageScore: bhv.number('engageScore', { min: 0, max: 1 }),
urgencyWeight: bhv.number('urgencyWeight', { min: 0, max: 1 }),
haltScore: bhv.number('haltScore', { min: 0, max: 1 }),
crossfirePenalty: bhv.number('crossfirePenalty', { min: 0, max: 1 }),
coverScore: bhv.number('coverScore', { min: 0, max: 1 }),
coverDangerWeight: bhv.number('coverDangerWeight', { min: 0, max: 1 }),
coverOffensivePenalty: bhv.number('coverOffensivePenalty', { min: 0, max: 1 }),
coverRetrySec: bhv.number('coverRetrySec', { min: 0.5, max: 30 }),
repositionScore: bhv.number('repositionScore', { min: 0, max: 1 }),
holdScore: bhv.number('holdScore', { min: 0, max: 1 }),
disperseScore: bhv.number('disperseScore', { min: 0, max: 1 }),
urgentSpeedKeep: bhv.number('urgentSpeedKeep', { min: 0, max: 1 }),
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 }),
reverseMinSpeedMps: bhv.number('reverseMinSpeedMps', { min: 0.5, max: 10 }),
reverseHoldSec: bhv.number('reverseHoldSec', { min: 0, max: 20 }),
};
}
function readEstimationSection(est: TuningReader): GroundAiTuning['estimation'] {
const watchMinSec = est.number('watchMinSec', { min: 0.5, max: 10.0 });
const watchMaxSec = est.number('watchMaxSec', { min: 1.0, max: 15.0 });
@@ -408,11 +433,6 @@ function readFireControlSection(fc: TuningReader): GroundAiTuning['fireControl']
if (midRangeM <= closeRangeM || longRangeM <= midRangeM) {
throw new TuningError('tuning file ground-ai.jsonc: fireControl ranges must satisfy closeRangeM < midRangeM < longRangeM');
}
const closeRangeMaxSpeedKmh = fc.number('closeRangeMaxSpeedKmh', { min: 3.6, max: 100 });
const pointBlankMaxSpeedKmh = fc.number('pointBlankMaxSpeedKmh', { min: 3.6, max: 100 });
if (pointBlankMaxSpeedKmh < closeRangeMaxSpeedKmh) {
throw new TuningError('tuning file ground-ai.jsonc: fireControl.pointBlankMaxSpeedKmh must be >= closeRangeMaxSpeedKmh');
}
const fireThreshold = fc.number('fireThreshold', { min: 0.05, max: 0.95 });
const minFireThreshold = fc.number('minFireThreshold', { min: 0.01, max: 0.9 });
if (minFireThreshold > fireThreshold) {
@@ -423,10 +443,6 @@ function readFireControlSection(fc: TuningReader): GroundAiTuning['fireControl']
closeRangeM,
midRangeM,
longRangeM,
midSlowSpeedRatio: fc.number('midSlowSpeedRatio', { min: 0.1, max: 1.0 }),
midSlowMaxMps: fc.number('midSlowMaxMps', { min: 1.0, max: 15.0 }),
closeRangeMaxSpeedKmh,
pointBlankMaxSpeedKmh,
stopSpeedMaxMps: fc.number('stopSpeedMaxMps', { min: 0.1, max: 2.0 }),
longRangeWindowSec: fc.number('longRangeWindowSec', { min: 1.0, max: 15.0 }),
baseAlignDeg: fc.number('baseAlignDeg', { min: 0.1, max: 3.0 }),