The first battles with the single-vehicle decision layer showed bots sensing from a stale turret direction, fixed mounts and elevation-limited guns that never got the hull turned for them, and bots braking late for vehicles and wrecks. - Perception samples the live barrel before sensing; near, mid and sight arcs are all measured from the barrel, and visible near and mid contacts in the barrel's front half are ranked with the same danger model. - The turret may swing to a contact before it is confirmed; the trigger still waits for visual confirmation. - A short halt only brakes. A fixed mount beyond its yaw span (turret.fixedMountYawSpanDeg) asks the hull to turn; an elevation-limited gun asks for a hull turn only when the stock elevation table shows the turn opens a sector that reaches the target. - Friendly and enemy vehicles and wrecks take part in front and rear dynamic braking; detours try the sides, then backing off. Builds and loads on the 2.61.0.64 lab client; played in three lab battles together with the replay trace.
495 lines
25 KiB
TypeScript
495 lines
25 KiB
TypeScript
/**
|
|
* Typed, range-validated reader for `tuning/ground-ai.jsonc`.
|
|
*/
|
|
import type { DiscoveredMod } from '@wto/mods';
|
|
import {
|
|
GROUND_AI_DRIVE_MODES,
|
|
GROUND_AI_MODES,
|
|
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';
|
|
import { TuningError, type TuningReader } from './tuning-reader.ts';
|
|
|
|
export interface GroundAiTuning extends GroundAiConfig {
|
|
/** Tank pool weights by class, used only when a custom ground AI mode is active. */
|
|
readonly lineupWeights: TankLineupWeights;
|
|
}
|
|
|
|
export function loadGroundAiTuning(
|
|
dataFolder: string | null,
|
|
report: (line: string) => void,
|
|
mods: readonly DiscoveredMod[] = [],
|
|
): GroundAiTuning {
|
|
return readGroundAiTuning(tuningFiles(dataFolder, report, undefined, mods).read('ground-ai'));
|
|
}
|
|
|
|
export function readGroundAiTuning(reader: TuningReader): GroundAiTuning {
|
|
const cadence = reader.object('cadence');
|
|
const diag = reader.object('diagnostics');
|
|
return {
|
|
mode: readMode(reader),
|
|
loadout: readLoadoutSection(reader.object('loadout')),
|
|
lineupWeights: readLineupWeights(reader.object('lineupWeights')),
|
|
cadence: {
|
|
maxBots: cadence.int('maxBots', { min: 1, max: 64 }),
|
|
macroTickSec: cadence.number('macroTickSec', { min: 0.1, max: 5 }),
|
|
tacticsTickSec: cadence.number('tacticsTickSec', { min: 0.05, max: 2 }),
|
|
navTickSec: cadence.number('navTickSec', { min: 0.05, max: 2 }),
|
|
},
|
|
commander: readCommanderSection(reader.object('commander')),
|
|
macro: readMacroSection(reader.object('macro')),
|
|
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 }),
|
|
},
|
|
};
|
|
}
|
|
|
|
function readMode(reader: TuningReader): GroundAiMode {
|
|
const mode = reader.string('mode');
|
|
const known = GROUND_AI_MODES.find((candidate) => candidate === mode);
|
|
if (known === undefined) {
|
|
throw new TuningError(`tuning file ground-ai.jsonc: mode must be one of ${GROUND_AI_MODES.map((m) => `"${m}"`).join(', ')} (found "${mode}")`);
|
|
}
|
|
return known;
|
|
}
|
|
|
|
function readLoadoutSection(loadout: TuningReader): GroundAiTuning['loadout'] {
|
|
return {
|
|
lowReadyRackThreshold: loadout.int('lowReadyRackThreshold', { min: 1, max: 60 }),
|
|
topUpAmmoCount: loadout.int('topUpAmmoCount', { min: 4, max: 80 }),
|
|
primaryAmmoPct: loadout.int('primaryAmmoPct', { min: 50, max: 100 }),
|
|
secondaryMinRounds: loadout.int('secondaryMinRounds', { min: 0, max: 20 }),
|
|
penetrationCompareDistM: loadout.int('penetrationCompareDistM', { min: 100, max: 2000 }),
|
|
};
|
|
}
|
|
|
|
function readLineupWeights(weights: TuningReader): TankLineupWeights {
|
|
const range = { min: 0.01, max: 10 };
|
|
return {
|
|
spaa: weights.number('spaa', range),
|
|
lightTank: weights.number('lightTank', range),
|
|
tankDestroyer: weights.number('tankDestroyer', range),
|
|
heavyTank: weights.number('heavyTank', range),
|
|
mediumTank: weights.number('mediumTank', range),
|
|
other: weights.number('other', range),
|
|
};
|
|
}
|
|
|
|
function readCommanderSection(cmd: TuningReader): GroundAiTuning['commander'] {
|
|
const pct = { min: 0, max: 100 };
|
|
const bttlAssaultPct = cmd.int('bttlAssaultPct', pct);
|
|
const bttlFlankPct = cmd.int('bttlFlankPct', pct);
|
|
const bttlOverwatchPct = cmd.int('bttlOverwatchPct', pct);
|
|
if (bttlAssaultPct + bttlFlankPct + bttlOverwatchPct > 100) {
|
|
throw new TuningError('tuning file ground-ai.jsonc: commander Bttl percentages must sum to <= 100');
|
|
}
|
|
const conqAssaultPct = cmd.int('conqAssaultPct', pct);
|
|
const conqFlankPct = cmd.int('conqFlankPct', pct);
|
|
if (conqAssaultPct + conqFlankPct > 100) {
|
|
throw new TuningError('tuning file ground-ai.jsonc: commander Conq assault + flank percentages must sum to <= 100');
|
|
}
|
|
const conqHoldDefendPct = cmd.int('conqHoldDefendPct', pct);
|
|
const conqHoldOverwatchPct = cmd.int('conqHoldOverwatchPct', pct);
|
|
if (conqHoldDefendPct + conqHoldOverwatchPct > 100) {
|
|
throw new TuningError('tuning file ground-ai.jsonc: commander Conq hold percentages must sum to <= 100');
|
|
}
|
|
return {
|
|
rebalanceSec: cmd.number('rebalanceSec', { min: 1.0, max: 30.0 }),
|
|
roleHoldSec: cmd.number('roleHoldSec', { min: 0.0, max: 120.0 }),
|
|
bttlAssaultPct,
|
|
bttlFlankPct,
|
|
bttlOverwatchPct,
|
|
conqAssaultPct,
|
|
conqFlankPct,
|
|
conqHoldDefendPct,
|
|
conqHoldOverwatchPct,
|
|
domAssaultPct: cmd.int('domAssaultPct', pct),
|
|
domMaxDefendersPerCap: cmd.int('domMaxDefendersPerCap', { min: 0, max: 4 }),
|
|
overwatchStandOffM: cmd.number('overwatchStandOffM', { min: 25.0, max: 350.0 }),
|
|
flankStandOffM: cmd.number('flankStandOffM', { min: 25.0, max: 300.0 }),
|
|
spaaFollowOffsetM: cmd.number('spaaFollowOffsetM', { min: 40.0, max: 500.0 }),
|
|
flankMaxLengthRatio: cmd.number('flankMaxLengthRatio', { min: 1.05, max: 3.0 }),
|
|
flankMinSeparationM: cmd.number('flankMinSeparationM', { min: 15.0, max: 200.0 }),
|
|
rallyProgressFrac: cmd.number('rallyProgressFrac', { min: 0.1, max: 0.75 }),
|
|
rallyWaitSec: cmd.number('rallyWaitSec', { min: 3.0, max: 60.0 }),
|
|
rallyMinFrac: cmd.number('rallyMinFrac', { min: 0.25, max: 1.0 }),
|
|
rallyRadiusM: cmd.number('rallyRadiusM', { min: 15.0, max: 140.0 }),
|
|
recallSafeHoldSec: cmd.number('recallSafeHoldSec', { min: 3.0, max: 60.0 }),
|
|
};
|
|
}
|
|
|
|
function readMacroSection(macro: TuningReader): GroundAiTuning['macro'] {
|
|
const recaptureMinBots = macro.int('recaptureMinBots', { min: 1, max: 8 });
|
|
const recaptureMaxBots = macro.int('recaptureMaxBots', { min: 1, max: 12 });
|
|
if (recaptureMaxBots < recaptureMinBots) {
|
|
throw new TuningError('tuning file ground-ai.jsonc: macro.recaptureMaxBots must be >= macro.recaptureMinBots');
|
|
}
|
|
return {
|
|
openingSplitSec: macro.number('openingSplitSec', { min: 0, max: 180 }),
|
|
capMaxInsiders: macro.int('capMaxInsiders', { min: 1, max: 8 }),
|
|
recaptureMinBots,
|
|
recaptureMaxBots,
|
|
capStickyBonusM: macro.number('capStickyBonusM', { min: 0, max: 800 }),
|
|
deathZoneRadiusM: macro.number('deathZoneRadiusM', { min: 10, max: 250 }),
|
|
deathZoneTtlSec: macro.number('deathZoneTtlSec', { min: 5, max: 300 }),
|
|
deathZoneMinKills: macro.int('deathZoneMinKills', { min: 1, max: 16 }),
|
|
spaaRearOffsetM: macro.number('spaaRearOffsetM', { min: 40, max: 600 }),
|
|
spaaRelocateSec: macro.number('spaaRelocateSec', { min: 5, max: 180 }),
|
|
enemySpawnAvoidM: macro.number('enemySpawnAvoidM', { min: 60, max: 600 }),
|
|
};
|
|
}
|
|
|
|
function readCrowdSection(crowd: TuningReader): GroundAiTuning['crowd'] {
|
|
return {
|
|
personalSpaceM: crowd.number('personalSpaceM', { min: 6, max: 40 }),
|
|
clusterRadiusM: crowd.number('clusterRadiusM', { min: 12, max: 80 }),
|
|
clusterMaxAllies: crowd.int('clusterMaxAllies', { min: 1, max: 10 }),
|
|
disperseStepM: crowd.number('disperseStepM', { min: 8, max: 65 }),
|
|
disperseHoldSec: crowd.number('disperseHoldSec', { min: 1, max: 15 }),
|
|
};
|
|
}
|
|
|
|
function readTerrainSection(terrain: TuningReader): GroundAiTuning['terrain'] {
|
|
return {
|
|
maxClimbSlopeDeg: terrain.number('maxClimbSlopeDeg', { min: 10, max: 42 }),
|
|
maxDropSlopeDeg: terrain.number('maxDropSlopeDeg', { min: 8, max: 40 }),
|
|
maxWaterDepthM: terrain.number('maxWaterDepthM', { min: 0.2, max: 2.5 }),
|
|
collisionMarginM: terrain.number('collisionMarginM', { min: 0.05, max: 2.0 }),
|
|
crestLookaheadM: terrain.number('crestLookaheadM', { min: 8, max: 80 }),
|
|
ridgeMaxDwellSec: terrain.number('ridgeMaxDwellSec', { min: 2, max: 60 }),
|
|
ridgeMaxShots: terrain.int('ridgeMaxShots', { min: 1, max: 10 }),
|
|
};
|
|
}
|
|
|
|
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);
|
|
if (driveMode === undefined) {
|
|
throw new TuningError(`tuning file ground-ai.jsonc: navigation.driveMode must be "vehicle_phys" or "movesys" (found "${driveModeRaw}")`);
|
|
}
|
|
const steerSign = nav.number('steerSign', { min: -1, max: 1 });
|
|
if (steerSign !== 1 && steerSign !== -1) {
|
|
throw new TuningError('tuning file ground-ai.jsonc: navigation.steerSign must be 1 or -1');
|
|
}
|
|
return {
|
|
driveMode,
|
|
maxPhysBots: nav.int('maxPhysBots', { min: 0, max: 64 }),
|
|
steerSign,
|
|
deadEchoSec: nav.number('deadEchoSec', { min: 0.3, max: 10 }),
|
|
controlTimeoutSec: nav.number('controlTimeoutSec', { min: 0.3, max: 10 }),
|
|
movingFireSpeedRampMps: nav.number('movingFireSpeedRampMps', { min: 0.2, max: 5 }),
|
|
pivotAngleDeg: nav.number('pivotAngleDeg', { min: 25, max: 150 }),
|
|
tacticalReverseDistM: nav.number('tacticalReverseDistM', { min: 10, max: 90 }),
|
|
tacticalReverseMaxSec: nav.number('tacticalReverseMaxSec', { min: 2, max: 25 }),
|
|
};
|
|
}
|
|
|
|
function readPerceptionSection(perc: TuningReader): GroundAiTuning['perception'] {
|
|
return {
|
|
foliageTransparency: perc.number('foliageTransparency', { min: 0.001, max: 1.0 }),
|
|
nearSpotRangeM: perc.number('nearSpotRangeM', { min: 20, max: 250 }),
|
|
firingSpotRangeM: perc.number('firingSpotRangeM', { min: 150, max: 1500 }),
|
|
fastSpotSec: perc.number('fastSpotSec', { min: 0.05, max: 1.5 }),
|
|
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 }),
|
|
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 }),
|
|
};
|
|
}
|
|
|
|
function readStateMachineSection(sm: TuningReader): GroundAiTuning['stateMachine'] {
|
|
const coverMinDistM = sm.number('coverMinDistM', { min: 2.0, max: 30.0 });
|
|
const coverMaxDistM = sm.number('coverMaxDistM', { min: 6.0, max: 80.0 });
|
|
if (coverMaxDistM <= coverMinDistM) {
|
|
throw new TuningError('tuning file ground-ai.jsonc: stateMachine.coverMaxDistM must be > coverMinDistM');
|
|
}
|
|
return {
|
|
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 }),
|
|
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 }),
|
|
repositionMinMoveM: sm.number('repositionMinMoveM', { min: 5.0, max: 80.0 }),
|
|
repositionStepM: sm.number('repositionStepM', { min: 15.0, max: 120.0 }),
|
|
repairSafeEnemyDistM: sm.number('repairSafeEnemyDistM', { min: 30.0, max: 400.0 }),
|
|
};
|
|
}
|
|
|
|
function readTacticsSection(tactics: TuningReader): GroundAiTuning['tactics'] {
|
|
return {
|
|
visionRangeM: tactics.number('visionRangeM', { min: 200, max: 3500 }),
|
|
engineAudioRangeM: tactics.number('engineAudioRangeM', { min: 10, max: 250 }),
|
|
shotAudioRangeM: tactics.number('shotAudioRangeM', { min: 50, max: 1200 }),
|
|
radioShareRangeM: tactics.number('radioShareRangeM', { min: 50, max: 1500 }),
|
|
memoryTtlSec: tactics.number('memoryTtlSec', { min: 1, max: 45 }),
|
|
targetStickinessSec: tactics.number('targetStickinessSec', { min: 0.5, max: 20 }),
|
|
peekCooldownSec: tactics.number('peekCooldownSec', { min: 1, max: 30 }),
|
|
};
|
|
}
|
|
|
|
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 });
|
|
if (watchMaxSec < watchMinSec) {
|
|
throw new TuningError('tuning file ground-ai.jsonc: estimation.watchMaxSec must be >= watchMinSec');
|
|
}
|
|
const velSampleMinSpanSec = est.number('velSampleMinSpanSec', { min: 0.05, max: 2.0 });
|
|
const velStableSpanSec = est.number('velStableSpanSec', { min: 0.2, max: 6.0 });
|
|
if (velStableSpanSec <= velSampleMinSpanSec) {
|
|
throw new TuningError('tuning file ground-ai.jsonc: estimation.velStableSpanSec must be > velSampleMinSpanSec');
|
|
}
|
|
return {
|
|
watchMinSec,
|
|
watchMaxSec,
|
|
velSampleMinSpanSec,
|
|
velStableSpanSec,
|
|
velJumpResetMps: est.number('velJumpResetMps', { min: 1.0, max: 20.0 }),
|
|
baseAimSigmaM: est.number('baseAimSigmaM', { min: 0.0, max: 2.0 }),
|
|
leadErrorFrac: est.number('leadErrorFrac', { min: 0.0, max: 1.0 }),
|
|
maxBiasM: est.number('maxBiasM', { min: 0.0, max: 6.0 }),
|
|
};
|
|
}
|
|
|
|
function readFireControlSection(fc: TuningReader): GroundAiTuning['fireControl'] {
|
|
const closeRangeM = fc.number('closeRangeM', { min: 30, max: 250 });
|
|
const midRangeM = fc.number('midRangeM', { min: 100, max: 600 });
|
|
const longRangeM = fc.number('longRangeM', { min: 300, max: 1500 });
|
|
if (midRangeM <= closeRangeM || longRangeM <= midRangeM) {
|
|
throw new TuningError('tuning file ground-ai.jsonc: fireControl ranges must satisfy closeRangeM < midRangeM < longRangeM');
|
|
}
|
|
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,
|
|
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 }),
|
|
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 }),
|
|
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 }),
|
|
maxPreFireChecksPerTick: fc.int('maxPreFireChecksPerTick', { min: 1, max: 16 }),
|
|
};
|
|
}
|