chore(repo): merge tank AI checkpoint for 0.1.6

This commit is contained in:
N0VAN0M4LY committed 2026-12-06 15:47:46 +08:00
commit 710c8ecaaa
159 files changed
+35721 -1572

No files matched your search

@@ -131,6 +131,8 @@ function customBotsBlock(plan: BattleLaunchPlan): BlkBlock {
setParam(bots, 'wtoTeamACountries', text(plan.countriesAllies.join(';')));
setParam(bots, 'wtoTeamBCountries', text(plan.countriesAxis.join(';')));
if (plan.mission.groundMode !== undefined) setParam(bots, 'wtoGroundMode', text(plan.mission.groundMode));
// The battle's level file: the ground AI loads its navigation pack by this name (native local_mp_nav.c).
if (plan.level !== undefined) setParam(bots, 'wtoLevel', text(plan.level));
if (plan.maxRespawns === UNLIMITED_RESPAWNS) setParam(bots, 'wtoUnlimitedRespawns', text('1'));
setParam(bots, 'numBotRespawnsInMultiSlot', integer(plan.airBotRespawns));
setParam(bots, 'numTankBotRespawnsInMultiSlot', integer(plan.tankBotRespawns));
+204 -24
View File
@@ -8,6 +8,8 @@ import {
type GroundAiConfig,
type GroundAiDriveMode,
type GroundAiMode,
type GroundAiNavCosts,
type GroundAiPathFollow,
} from '@wto/patcher';
import type { TankLineupWeights } from '../battle/battle-ranks.ts';
import { tuningFiles } from './tuning-loader.ts';
@@ -44,14 +46,31 @@ export function readGroundAiTuning(reader: TuningReader): GroundAiTuning {
crowd: readCrowdSection(reader.object('crowd')),
terrain: readTerrainSection(reader.object('terrain')),
navigation: readNavigationSection(reader.object('navigation')),
navEngine: readNavEngineSection(reader.object('navEngine')),
navCostsTracked: readNavCosts(reader.object('navCostsTracked')),
navCostsWheeled: readNavCosts(reader.object('navCostsWheeled')),
pathFollow: readPathFollowSection(reader.object('pathFollow')),
navBake: {
crushableMaxRiExtraHp: reader.object('navBake').number('crushableMaxRiExtraHp', { min: 0, max: 1000 }),
},
perception: readPerceptionSection(reader.object('perception')),
stateMachine: readStateMachineSection(reader.object('stateMachine')),
tactics: readTacticsSection(reader.object('tactics')),
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'),
telemetryIntervalSec: diag.number('telemetryIntervalSec', { min: 0.5, max: 60 }),
battleStats: diag.bool('battleStats'),
statsLogIntervalSec: diag.number('statsLogIntervalSec', { min: 10, max: 600 }),
statsSampleSec: diag.number('statsSampleSec', { min: 0.2, max: 5 }),
statsSampleRangeM: diag.number('statsSampleRangeM', { min: 50, max: 1000 }),
statsRearArcDeg: diag.number('statsRearArcDeg', { min: 30, max: 180 }),
trace: diag.bool('trace'),
traceIntervalSec: diag.number('traceIntervalSec', { min: 0.1, max: 5 }),
},
};
}
@@ -173,6 +192,91 @@ function readTerrainSection(terrain: TuningReader): GroundAiTuning['terrain'] {
};
}
function readNavEngineSection(engine: TuningReader): GroundAiTuning['navEngine'] {
return {
enabled: engine.bool('enabled'),
allowFallback: engine.bool('allowFallback'),
snapRadiusM: engine.number('snapRadiusM', { min: 2, max: 40 }),
goalSnapRadiusM: engine.number('goalSnapRadiusM', { min: 5, max: 150 }),
pathBudgetMsPerFrame: engine.number('pathBudgetMsPerFrame', { min: 0.05, max: 5 }),
trafficCostPerPath: engine.number('trafficCostPerPath', { min: 0, max: 3 }),
trafficCostMaxMul: engine.number('trafficCostMaxMul', { min: 1, max: 10 }),
trafficHoldSec: engine.number('trafficHoldSec', { min: 0, max: 120 }),
cornerOffsetM: engine.number('cornerOffsetM', { min: 0, max: 5 }),
};
}
function readNavCosts(costs: TuningReader): GroundAiNavCosts {
const read = (key: keyof GroundAiNavCosts) => costs.number(key, { min: 0.1, max: 20 });
return {
road: read('road'),
bridge: read('bridge'),
ground: read('ground'),
rough: read('rough'),
forest: read('forest'),
crushable: read('crushable'),
shallowWater: read('shallowWater'),
chokepoint: read('chokepoint'),
};
}
function readPathFollowSection(pf: TuningReader): GroundAiPathFollow {
const n = (key: keyof GroundAiPathFollow, min: number, max: number) => pf.number(key, { min, max });
const lookahead = {
trackedLookaheadMinM: n('trackedLookaheadMinM', 2, 40),
trackedLookaheadMaxM: n('trackedLookaheadMaxM', 4, 60),
wheeledLookaheadMinM: n('wheeledLookaheadMinM', 2, 40),
wheeledLookaheadMaxM: n('wheeledLookaheadMaxM', 4, 60),
};
if (lookahead.trackedLookaheadMaxM < lookahead.trackedLookaheadMinM || lookahead.wheeledLookaheadMaxM < lookahead.wheeledLookaheadMinM) {
throw new TuningError('tuning file ground-ai.jsonc: pathFollow lookahead maximum must not be below its minimum');
}
return {
replanIntervalSec: n('replanIntervalSec', 1, 15),
replanGoalMoveM: n('replanGoalMoveM', 3, 80),
offCorridorReplanM: n('offCorridorReplanM', 3, 60),
lookaheadTimeSec: n('lookaheadTimeSec', 0.3, 5),
...lookahead,
cornerAngleDeg: n('cornerAngleDeg', 10, 120),
cornerLateralAccelMps2: n('cornerLateralAccelMps2', 0.5, 10),
cornerBrakeDecelMps2: n('cornerBrakeDecelMps2', 0.5, 10),
arriveRadiusM: n('arriveRadiusM', 1, 20),
arriveMinSpeedMps: n('arriveMinSpeedMps', 0.3, 6),
narrowWallMarginM: n('narrowWallMarginM', 0.2, 6),
narrowSpeedMps: n('narrowSpeedMps', 1, 15),
bumperRayM: n('bumperRayM', 2, 20),
bumperStopM: n('bumperStopM', 0.3, 6),
bumperBlockSec: n('bumperBlockSec', 0.2, 5),
trafficTtcSec: n('trafficTtcSec', 0.5, 8),
yieldWaitMaxSec: n('yieldWaitMaxSec', 0.5, 15),
stationarySpeedMps: n('stationarySpeedMps', 0.2, 4),
passMarginM: n('passMarginM', 0.2, 4),
passSpeedMps: n('passSpeedMps', 1, 12),
blockWaitSec: n('blockWaitSec', 0.5, 15),
blockTtlSec: n('blockTtlSec', 3, 120),
contactGapM: n('contactGapM', 0.2, 3),
contactReverseSec: n('contactReverseSec', 0.3, 5),
contactRepeatSec: n('contactRepeatSec', 3, 120),
stuckWindowSec: n('stuckWindowSec', 1, 15),
stuckMinProgressM: n('stuckMinProgressM', 0.2, 10),
unstickReverseM: n('unstickReverseM', 2, 25),
unstickReverseSec: n('unstickReverseSec', 0.8, 10),
unstickRepeatSec: n('unstickRepeatSec', 2, 60),
unstickMaxAttempts: pf.int('unstickMaxAttempts', { min: 1, max: 10 }),
jamRadiusM: n('jamRadiusM', 2, 50),
jamCostMul: n('jamCostMul', 1, 50),
jamTtlSec: n('jamTtlSec', 5, 600),
giveUpRadiusM: n('giveUpRadiusM', 3, 50),
giveUpCostMul: n('giveUpCostMul', 1, 200),
rubbleRadiusM: n('rubbleRadiusM', 1, 40),
rubbleCostMul: n('rubbleCostMul', 1, 50),
rubbleTtlSec: n('rubbleTtlSec', 5, 600),
wreckRadiusM: n('wreckRadiusM', 1, 40),
wreckCostMul: n('wreckCostMul', 1, 50),
wreckTtlSec: n('wreckTtlSec', 5, 600),
};
}
function readNavigationSection(nav: TuningReader): GroundAiTuning['navigation'] {
const driveModeRaw = nav.string('driveMode');
const driveMode = GROUND_AI_DRIVE_MODES.find((candidate): candidate is GroundAiDriveMode => candidate === driveModeRaw);
@@ -189,12 +293,8 @@ function readNavigationSection(nav: TuningReader): GroundAiTuning['navigation']
steerSign,
deadEchoSec: nav.number('deadEchoSec', { min: 0.3, max: 10 }),
controlTimeoutSec: nav.number('controlTimeoutSec', { min: 0.3, max: 10 }),
cornerBrakeAccel: nav.number('cornerBrakeAccel', { min: 0.5, max: 8 }),
movingFireSpeedRampMps: nav.number('movingFireSpeedRampMps', { min: 0.2, max: 5 }),
pivotAngleDeg: nav.number('pivotAngleDeg', { min: 25, max: 150 }),
stuckWindowSec: nav.number('stuckWindowSec', { min: 1, max: 15 }),
stuckMinMoveM: nav.number('stuckMinMoveM', { min: 0.5, max: 10 }),
unstickReverseSec: nav.number('unstickReverseSec', { min: 0.8, max: 10 }),
tacticalReverseDistM: nav.number('tacticalReverseDistM', { min: 10, max: 90 }),
tacticalReverseMaxSec: nav.number('tacticalReverseMaxSec', { min: 2, max: 25 }),
};
@@ -209,8 +309,15 @@ function readPerceptionSection(perc: TuningReader): GroundAiTuning['perception']
normalSpotSec: perc.number('normalSpotSec', { min: 0.1, max: 3.0 }),
farSpotSec: perc.number('farSpotSec', { min: 0.3, max: 6.0 }),
decayPerSec: perc.number('decayPerSec', { min: 0.2, max: 10.0 }),
frontConeHalfDeg: perc.number('frontConeHalfDeg', { min: 10, max: 90 }),
peripheralCloseM: perc.number('peripheralCloseM', { min: 30, max: 250 }),
gunFovHalfDeg: perc.number('gunFovHalfDeg', { min: 5, max: 90 }),
nearAwareM: perc.number('nearAwareM', { min: 30, max: 400 }),
nearArcDeg: perc.number('nearArcDeg', { min: 90, max: 360 }),
midAwareM: perc.number('midAwareM', { min: 100, max: 1500 }),
nearSpotMul: perc.number('nearSpotMul', { min: 1, max: 5 }),
midSpotMul: perc.number('midSpotMul', { min: 1, max: 6 }),
lookAroundSec: perc.number('lookAroundSec', { min: 2, max: 60 }),
lookAroundHoldSec: perc.number('lookAroundHoldSec', { min: 0.2, max: 5 }),
discoverScore: perc.number('discoverScore', { min: 0.05, max: 0.95 }),
};
}
@@ -221,17 +328,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 }),
@@ -244,8 +346,6 @@ function readStateMachineSection(sm: TuningReader): GroundAiTuning['stateMachine
function readTacticsSection(tactics: TuningReader): GroundAiTuning['tactics'] {
return {
visionRangeM: tactics.number('visionRangeM', { min: 200, max: 3500 }),
visionFovDeg: tactics.number('visionFovDeg', { min: 40, max: 180 }),
peripheralRangeM: tactics.number('peripheralRangeM', { min: 30, max: 800 }),
engineAudioRangeM: tactics.number('engineAudioRangeM', { min: 10, max: 250 }),
shotAudioRangeM: tactics.number('shotAudioRangeM', { min: 50, max: 1200 }),
radioShareRangeM: tactics.number('radioShareRangeM', { min: 50, max: 1500 }),
@@ -255,6 +355,64 @@ function readTacticsSection(tactics: TuningReader): GroundAiTuning['tactics'] {
};
}
function readThreatSection(threat: TuningReader): GroundAiTuning['threat'] {
return {
rangeScaleM: threat.number('rangeScaleM', { min: 50, max: 3000 }),
discoveredMul: threat.number('discoveredMul', { min: 0, max: 1 }),
aimConeDeg: threat.number('aimConeDeg', { min: 5, max: 90 }),
notAimingMul: threat.number('notAimingMul', { min: 0, max: 1 }),
unseenMul: threat.number('unseenMul', { min: 0, max: 1 }),
hitMemorySec: threat.number('hitMemorySec', { min: 0, max: 60 }),
hitMul: threat.number('hitMul', { min: 1, max: 5 }),
};
}
function readTurretSection(turret: TuningReader): GroundAiTuning['turret'] {
return {
minDwellSec: turret.number('minDwellSec', { min: 0, max: 5 }),
switchMargin: turret.number('switchMargin', { min: 0, max: 3 }),
scanArcDeg: turret.number('scanArcDeg', { min: 0, max: 180 }),
scanPeriodSec: turret.number('scanPeriodSec', { min: 1, max: 30 }),
fixedMountYawSpanDeg: turret.number('fixedMountYawSpanDeg', { min: 0, max: 180 }),
};
}
function readBehaviorSection(bhv: TuningReader): GroundAiTuning['behavior'] {
return {
scoreIntervalSec: bhv.number('scoreIntervalSec', { min: 0.1, max: 3 }),
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 }),
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 }),
reverseTravelAngleDeg: bhv.number('reverseTravelAngleDeg', { min: 60, max: 180 }),
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 }),
};
}
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 });
@@ -285,29 +443,51 @@ 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) {
throw new TuningError('tuning file ground-ai.jsonc: fireControl.minFireThreshold must be <= fireThreshold');
}
return {
maxEngageRangeM: fc.number('maxEngageRangeM', { min: 150, max: 3000 }),
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 }),
closeHitRadiusM: fc.number('closeHitRadiusM', { min: 0.25, max: 2.2 }),
barrelSettleDegSec: fc.number('barrelSettleDegSec', { min: 0.2, max: 12.0 }),
closeSettleHoldSec: fc.number('closeSettleHoldSec', { min: 0.02, max: 0.5 }),
settleHoldSec: fc.number('settleHoldSec', { min: 0.05, max: 1.5 }),
unstabilizedStopSpeedMps: fc.number('unstabilizedStopSpeedMps', { min: 0.1, max: 3.0 }),
stabilizedCreepSpeedMps: fc.number('stabilizedCreepSpeedMps', { min: 1.5, max: 15.0 }),
aimErrorDeg: fc.number('aimErrorDeg', { min: 0.01, max: 2 }),
moveErrDegPerMps: fc.number('moveErrDegPerMps', { min: 0, max: 3 }),
turnErrDegPerDegSec: fc.number('turnErrDegPerDegSec', { min: 0, max: 0.5 }),
stabErrFactor: fc.number('stabErrFactor', { min: 0.02, max: 1 }),
targetHalfHeightM: fc.number('targetHalfHeightM', { min: 0.3, max: 2 }),
fireThreshold,
minFireThreshold,
aimingThresholdBonus: fc.number('aimingThresholdBonus', { min: 0, max: 0.5 }),
closeThresholdBonus: fc.number('closeThresholdBonus', { min: 0, max: 0.5 }),
enemyReloadThresholdBonus: fc.number('enemyReloadThresholdBonus', { min: 0, max: 0.5 }),
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 }),
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 }),
autocannonReloadDetectSec: fc.number('autocannonReloadDetectSec', { min: 0.1, max: 3 }),
auxWeapons: fc.bool('auxWeapons'),
auxMaxRangeM: fc.number('auxMaxRangeM', { min: 30, max: 1500 }),
auxFireAtArmor: fc.bool('auxFireAtArmor'),
friendlyCorridorM: fc.number('friendlyCorridorM', { min: 1.0, max: 10.0 }),
ballisticStepMaxM: fc.number('ballisticStepMaxM', { min: 5.0, max: 80.0 }),
ballisticSweepRadiusM: fc.number('ballisticSweepRadiusM', { min: 0.02, max: 0.5 }),