Files
WT-Offline/apps/launcher/src/shared/schemas/tuning.ts
T
N0VAN0M4LY 5786fee63b feat(ground-ai): add a replay trace and the AI lab viewer
Battle behaviour could only be judged by watching one bot at a time. The
AI now logs a replay trace and a local viewer plays it back on the map.

Game scripts:
- wto_ai_trace_common.das writes every diagnostics.traceIntervalSec the
  capture zones (WTO_AI|TRACE_CAP), every ground unit including players
  (TRACE_U) and each bot's decision state (TRACE_B: order, behavior,
  targets, what the turret looks at and why, barrel heading, fire denial,
  hit probability), plus part damage with its offender (HIT) and deaths
  (DEATH). It uses no engine module so a simulator can load it as is.
- The turret state records the reason and world direction of each look.
- New tuning diagnostics.trace and diagnostics.traceIntervalSec through
  server reader, patcher constants, launcher schema, fields and labels.

packages/ground-sim: readers for the baked .wtonav pack (mesh polygons,
cover points, tactical grid) and .pois.json, the trace parser and the
names of the logged codes.

apps/ai-lab: Vite viewer with a local API that lists nav packs and lab
logs and decrypts a chosen .clog with wtotools. It draws the nav mesh,
vehicles, barrels and wished turret directions, goals, target links,
shots, hits and deaths over a timeline, with per-bot strips for behavior,
fire denial and turret reason. Paths live in an untracked lab.local.json.
The lab has its own tsconfig and stays out of the root typecheck.

Root and launcher typechecks pass; the lab typechecks and replayed two
lab battles.
2026-12-06 13:53:52 +08:00

414 lines
17 KiB
TypeScript

import { z } from 'zod';
export const AUTO_TARGET_PICKS = ['lowestRank', 'highestRank', 'treeOrder'] as const;
export const GROUND_AI_MODES = ['stock', 'fire', 'drive', 'full'] as const;
export const GROUND_AI_DRIVE_MODES = ['vehicle_phys', 'movesys'] as const;
const GroundAiLoadoutSchema = z.object({
lowReadyRackThreshold: z.number().int().min(1).max(60),
topUpAmmoCount: z.number().int().min(4).max(80),
primaryAmmoPct: z.number().int().min(50).max(100),
secondaryMinRounds: z.number().int().min(0).max(20),
penetrationCompareDistM: z.number().int().min(100).max(2000),
});
const GroundAiLineupWeightsSchema = z.object({
spaa: z.number().min(0.01).max(10),
lightTank: z.number().min(0.01).max(10),
tankDestroyer: z.number().min(0.01).max(10),
heavyTank: z.number().min(0.01).max(10),
mediumTank: z.number().min(0.01).max(10),
other: z.number().min(0.01).max(10),
});
const GroundAiCadenceSchema = z.object({
maxBots: z.number().int().min(1).max(64),
macroTickSec: z.number().min(0.1).max(5),
tacticsTickSec: z.number().min(0.05).max(2),
navTickSec: z.number().min(0.05).max(2),
});
const GroundAiCommanderSchema = z.object({
rebalanceSec: z.number().min(1).max(30),
roleHoldSec: z.number().min(0).max(120),
bttlAssaultPct: z.number().int().min(0).max(100),
bttlFlankPct: z.number().int().min(0).max(100),
bttlOverwatchPct: z.number().int().min(0).max(100),
conqAssaultPct: z.number().int().min(0).max(100),
conqFlankPct: z.number().int().min(0).max(100),
conqHoldDefendPct: z.number().int().min(0).max(100),
conqHoldOverwatchPct: z.number().int().min(0).max(100),
domAssaultPct: z.number().int().min(0).max(100),
domMaxDefendersPerCap: z.number().int().min(0).max(4),
overwatchStandOffM: z.number().min(25).max(350),
flankStandOffM: z.number().min(25).max(300),
spaaFollowOffsetM: z.number().min(40).max(500),
flankMaxLengthRatio: z.number().min(1.05).max(3),
flankMinSeparationM: z.number().min(15).max(200),
rallyProgressFrac: z.number().min(0.1).max(0.75),
rallyWaitSec: z.number().min(3).max(60),
rallyMinFrac: z.number().min(0.25).max(1),
rallyRadiusM: z.number().min(15).max(140),
recallSafeHoldSec: z.number().min(3).max(60),
});
const GroundAiMacroSchema = z.object({
openingSplitSec: z.number().min(0).max(180),
capMaxInsiders: z.number().int().min(1).max(8),
recaptureMinBots: z.number().int().min(1).max(8),
recaptureMaxBots: z.number().int().min(1).max(12),
capStickyBonusM: z.number().min(0).max(800),
deathZoneRadiusM: z.number().min(10).max(250),
deathZoneTtlSec: z.number().min(5).max(300),
deathZoneMinKills: z.number().int().min(1).max(16),
spaaRearOffsetM: z.number().min(40).max(600),
spaaRelocateSec: z.number().min(5).max(180),
enemySpawnAvoidM: z.number().min(60).max(600),
});
const GroundAiCrowdSchema = z.object({
personalSpaceM: z.number().min(6).max(40),
clusterRadiusM: z.number().min(12).max(80),
clusterMaxAllies: z.number().int().min(1).max(10),
disperseStepM: z.number().min(8).max(65),
disperseHoldSec: z.number().min(1).max(15),
});
const GroundAiTerrainSchema = z.object({
maxClimbSlopeDeg: z.number().min(10).max(42),
maxDropSlopeDeg: z.number().min(8).max(40),
maxWaterDepthM: z.number().min(0.2).max(2.5),
collisionMarginM: z.number().min(0.05).max(2),
crestLookaheadM: z.number().min(8).max(80),
ridgeMaxDwellSec: z.number().min(2).max(60),
ridgeMaxShots: z.number().int().min(1).max(10),
});
const GroundAiNavigationSchema = z.object({
driveMode: z.enum(GROUND_AI_DRIVE_MODES),
maxPhysBots: z.number().int().min(0).max(64),
steerSign: z.union([z.literal(1), z.literal(-1)]),
deadEchoSec: z.number().min(0.3).max(10),
controlTimeoutSec: z.number().min(0.3).max(10),
movingFireSpeedRampMps: z.number().min(0.2).max(5),
pivotAngleDeg: z.number().min(25).max(150),
tacticalReverseDistM: z.number().min(10).max(90),
tacticalReverseMaxSec: z.number().min(2).max(25),
});
const GroundAiNavEngineSchema = z.object({
enabled: z.boolean(),
allowFallback: z.boolean(),
snapRadiusM: z.number().min(2).max(40),
goalSnapRadiusM: z.number().min(5).max(150),
pathBudgetMsPerFrame: z.number().min(0.05).max(5),
trafficCostPerPath: z.number().min(0).max(3),
trafficCostMaxMul: z.number().min(1).max(10),
trafficHoldSec: z.number().min(0).max(120),
cornerOffsetM: z.number().min(0).max(5),
});
const navCost = z.number().min(0.1).max(20);
const GroundAiNavCostsSchema = z.object({
road: navCost,
bridge: navCost,
ground: navCost,
rough: navCost,
forest: navCost,
crushable: navCost,
shallowWater: navCost,
chokepoint: navCost,
});
const GroundAiPathFollowSchema = z.object({
replanIntervalSec: z.number().min(1).max(15),
replanGoalMoveM: z.number().min(3).max(80),
offCorridorReplanM: z.number().min(3).max(60),
lookaheadTimeSec: z.number().min(0.3).max(5),
trackedLookaheadMinM: z.number().min(2).max(40),
trackedLookaheadMaxM: z.number().min(4).max(60),
wheeledLookaheadMinM: z.number().min(2).max(40),
wheeledLookaheadMaxM: z.number().min(4).max(60),
cornerAngleDeg: z.number().min(10).max(120),
cornerLateralAccelMps2: z.number().min(0.5).max(10),
cornerBrakeDecelMps2: z.number().min(0.5).max(10),
arriveRadiusM: z.number().min(1).max(20),
arriveMinSpeedMps: z.number().min(0.3).max(6),
narrowWallMarginM: z.number().min(0.2).max(6),
narrowSpeedMps: z.number().min(1).max(15),
bumperRayM: z.number().min(2).max(20),
bumperStopM: z.number().min(0.3).max(6),
bumperBlockSec: z.number().min(0.2).max(5),
trafficTtcSec: z.number().min(0.5).max(8),
yieldWaitMaxSec: z.number().min(0.5).max(15),
stationarySpeedMps: z.number().min(0.2).max(4),
passMarginM: z.number().min(0.2).max(4),
passSpeedMps: z.number().min(1).max(12),
blockWaitSec: z.number().min(0.5).max(15),
blockTtlSec: z.number().min(3).max(120),
contactGapM: z.number().min(0.2).max(3),
contactReverseSec: z.number().min(0.3).max(5),
contactRepeatSec: z.number().min(3).max(120),
stuckWindowSec: z.number().min(1).max(15),
stuckMinProgressM: z.number().min(0.2).max(10),
unstickReverseM: z.number().min(2).max(25),
unstickReverseSec: z.number().min(0.8).max(10),
unstickRepeatSec: z.number().min(2).max(60),
unstickMaxAttempts: z.number().int().min(1).max(10),
jamRadiusM: z.number().min(2).max(50),
jamCostMul: z.number().min(1).max(50),
jamTtlSec: z.number().min(5).max(600),
giveUpRadiusM: z.number().min(3).max(50),
giveUpCostMul: z.number().min(1).max(200),
rubbleRadiusM: z.number().min(1).max(40),
rubbleCostMul: z.number().min(1).max(50),
rubbleTtlSec: z.number().min(5).max(600),
wreckRadiusM: z.number().min(1).max(40),
wreckCostMul: z.number().min(1).max(50),
wreckTtlSec: z.number().min(5).max(600),
});
const GroundAiPerceptionSchema = z.object({
foliageTransparency: z.number().min(0.001).max(1),
nearSpotRangeM: z.number().min(20).max(250),
firingSpotRangeM: z.number().min(150).max(1500),
fastSpotSec: z.number().min(0.05).max(1.5),
normalSpotSec: z.number().min(0.1).max(3),
farSpotSec: z.number().min(0.3).max(6),
decayPerSec: z.number().min(0.2).max(10),
gunFovHalfDeg: z.number().min(5).max(90),
nearAwareM: z.number().min(30).max(400),
nearArcDeg: z.number().min(90).max(360),
midAwareM: z.number().min(100).max(1500),
nearSpotMul: z.number().min(1).max(5),
midSpotMul: z.number().min(1).max(6),
lookAroundSec: z.number().min(2).max(60),
lookAroundHoldSec: z.number().min(0.2).max(5),
discoverScore: z.number().min(0.05).max(0.95),
});
const GroundAiStateMachineSchema = z.object({
shortHaltMaxSec: z.number().min(0.5).max(12),
shortHaltCooldownSec: z.number().min(0.5).max(20),
turnLaunchSpeedMps: z.number().min(0.5).max(6),
coverMinDistM: z.number().min(2).max(30),
coverMaxDistM: z.number().min(6).max(80),
coverRetreatBudgetSec: z.number().min(1.5).max(20),
maxTotalHaltSec: z.number().min(3).max(40),
stalemateMissShots: z.number().int().min(1).max(8),
stalemateNoShotHalts: z.number().int().min(1).max(6),
repositionMinMoveM: z.number().min(5).max(80),
repositionStepM: z.number().min(15).max(120),
repairSafeEnemyDistM: z.number().min(30).max(400),
});
const GroundAiTacticsSchema = z.object({
visionRangeM: z.number().min(200).max(3500),
engineAudioRangeM: z.number().min(10).max(250),
shotAudioRangeM: z.number().min(50).max(1200),
radioShareRangeM: z.number().min(50).max(1500),
memoryTtlSec: z.number().min(1).max(45),
targetStickinessSec: z.number().min(0.5).max(20),
peekCooldownSec: z.number().min(1).max(30),
});
const GroundAiThreatSchema = z.object({
rangeScaleM: z.number().min(50).max(3000),
discoveredMul: z.number().min(0).max(1),
aimConeDeg: z.number().min(5).max(90),
notAimingMul: z.number().min(0).max(1),
unseenMul: z.number().min(0).max(1),
hitMemorySec: z.number().min(0).max(60),
hitMul: z.number().min(1).max(5),
});
const GroundAiTurretSchema = z.object({
minDwellSec: z.number().min(0).max(5),
switchMargin: z.number().min(0).max(3),
scanArcDeg: z.number().min(0).max(180),
scanPeriodSec: z.number().min(1).max(30),
fixedMountYawSpanDeg: z.number().min(0).max(180),
});
const GroundAiBehaviorSchema = z.object({
scoreIntervalSec: z.number().min(0.1).max(3),
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),
urgencyWeight: z.number().min(0).max(1),
haltScore: z.number().min(0).max(1),
crossfirePenalty: z.number().min(0).max(1),
coverScore: z.number().min(0).max(1),
coverDangerWeight: z.number().min(0).max(1),
coverOffensivePenalty: z.number().min(0).max(1),
coverRetrySec: z.number().min(0.5).max(30),
repositionScore: z.number().min(0).max(1),
holdScore: z.number().min(0).max(1),
disperseScore: z.number().min(0).max(1),
urgentSpeedKeep: z.number().min(0).max(1),
hullAngleDeg: z.number().min(0).max(45),
faceToleranceDeg: z.number().min(3).max(60),
faceMinDanger: z.number().min(0).max(2),
reverseTravelAngleDeg: z.number().min(60).max(180),
reverseMaxTurnDistM: z.number().min(0).max(200),
reverseMinSpeedMps: z.number().min(0.5).max(10),
reverseHoldSec: z.number().min(0).max(20),
});
const GroundAiEstimationSchema = z.object({
watchMinSec: z.number().min(0.5).max(10),
watchMaxSec: z.number().min(1).max(15),
velSampleMinSpanSec: z.number().min(0.05).max(2),
velStableSpanSec: z.number().min(0.2).max(6),
velJumpResetMps: z.number().min(1).max(20),
baseAimSigmaM: z.number().min(0).max(2),
leadErrorFrac: z.number().min(0).max(1),
maxBiasM: z.number().min(0).max(6),
});
const GroundAiFireControlSchema = z.object({
maxEngageRangeM: z.number().min(150).max(3000),
closeRangeM: z.number().min(30).max(250),
midRangeM: z.number().min(100).max(600),
longRangeM: z.number().min(300).max(1500),
stopSpeedMaxMps: z.number().min(0.1).max(2),
longRangeWindowSec: z.number().min(1).max(15),
baseAlignDeg: z.number().min(0.1).max(3),
barrelSettleDegSec: z.number().min(0.2).max(12),
closeSettleHoldSec: z.number().min(0.02).max(0.5),
settleHoldSec: z.number().min(0.05).max(1.5),
aimErrorDeg: z.number().min(0.01).max(2),
moveErrDegPerMps: z.number().min(0).max(3),
turnErrDegPerDegSec: z.number().min(0).max(0.5),
stabErrFactor: z.number().min(0.02).max(1),
targetHalfHeightM: z.number().min(0.3).max(2),
fireThreshold: z.number().min(0.05).max(0.95),
minFireThreshold: z.number().min(0.01).max(0.9),
aimingThresholdBonus: z.number().min(0).max(0.5),
closeThresholdBonus: z.number().min(0).max(0.5),
enemyReloadThresholdBonus: z.number().min(0).max(0.5),
enemyReloadSec: z.number().min(0).max(15),
fleetingThresholdBonus: z.number().min(0).max(0.5),
fleetingLateralMps: z.number().min(0.5).max(15),
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),
autocannonReloadDetectSec: z.number().min(0.1).max(3),
auxWeapons: z.boolean(),
auxMaxRangeM: z.number().min(30).max(1500),
auxFireAtArmor: z.boolean(),
friendlyCorridorM: z.number().min(1).max(10),
ballisticStepMaxM: z.number().min(5).max(80),
ballisticSweepRadiusM: z.number().min(0.02).max(0.5),
maxPreFireChecksPerTick: z.number().int().min(1).max(16),
});
const GroundAiDiagnosticsSchema = z.object({
telemetry: z.boolean(),
telemetryIntervalSec: z.number().min(0.5).max(60),
battleStats: z.boolean(),
statsLogIntervalSec: z.number().min(10).max(600),
statsSampleSec: z.number().min(0.2).max(5),
statsSampleRangeM: z.number().min(50).max(1000),
statsRearArcDeg: z.number().min(30).max(180),
trace: z.boolean(),
traceIntervalSec: z.number().min(0.1).max(5),
});
export const GroundAiTuningSchema = z.object({
mode: z.enum(GROUND_AI_MODES),
loadout: GroundAiLoadoutSchema,
lineupWeights: GroundAiLineupWeightsSchema,
cadence: GroundAiCadenceSchema,
commander: GroundAiCommanderSchema,
macro: GroundAiMacroSchema,
crowd: GroundAiCrowdSchema,
terrain: GroundAiTerrainSchema,
navigation: GroundAiNavigationSchema,
navEngine: GroundAiNavEngineSchema,
navCostsTracked: GroundAiNavCostsSchema,
navCostsWheeled: GroundAiNavCostsSchema,
pathFollow: GroundAiPathFollowSchema,
perception: GroundAiPerceptionSchema,
stateMachine: GroundAiStateMachineSchema,
tactics: GroundAiTacticsSchema,
estimation: GroundAiEstimationSchema,
threat: GroundAiThreatSchema,
turret: GroundAiTurretSchema,
behavior: GroundAiBehaviorSchema,
fireControl: GroundAiFireControlSchema,
diagnostics: GroundAiDiagnosticsSchema,
});
export const GroundAiTuningPatchSchema = z.object({
mode: z.enum(GROUND_AI_MODES).optional(),
loadout: GroundAiLoadoutSchema.partial().optional(),
lineupWeights: GroundAiLineupWeightsSchema.partial().optional(),
cadence: GroundAiCadenceSchema.partial().optional(),
commander: GroundAiCommanderSchema.partial().optional(),
macro: GroundAiMacroSchema.partial().optional(),
crowd: GroundAiCrowdSchema.partial().optional(),
terrain: GroundAiTerrainSchema.partial().optional(),
navigation: GroundAiNavigationSchema.partial().optional(),
navEngine: GroundAiNavEngineSchema.partial().optional(),
navCostsTracked: GroundAiNavCostsSchema.partial().optional(),
navCostsWheeled: GroundAiNavCostsSchema.partial().optional(),
pathFollow: GroundAiPathFollowSchema.partial().optional(),
perception: GroundAiPerceptionSchema.partial().optional(),
stateMachine: GroundAiStateMachineSchema.partial().optional(),
tactics: GroundAiTacticsSchema.partial().optional(),
estimation: GroundAiEstimationSchema.partial().optional(),
threat: GroundAiThreatSchema.partial().optional(),
turret: GroundAiTurretSchema.partial().optional(),
behavior: GroundAiBehaviorSchema.partial().optional(),
fireControl: GroundAiFireControlSchema.partial().optional(),
diagnostics: GroundAiDiagnosticsSchema.partial().optional(),
});
export const TuningValuesSchema = z.object({
rewardMultiplierSilverLions: z.number().min(0).max(100),
rewardMultiplierResearchPoints: z.number().min(0).max(100),
friendlyKillPenaltyMul: z.number().min(0).max(100),
maxPlayers: z.number().int().min(2).max(64),
smallTeamsMaxPlayers: z.number().int().min(2).max(64),
brSpreadMrank: z.number().int().min(0).max(12),
subModeChance: z.number().min(0).max(1),
botPoolLimitPerType: z.number().int().min(4).max(200),
tankBotRespawns: z.number().int().min(1).max(10),
airBotRespawns: z.number().int().min(1).max(10),
strikeUcavSpawnScore: z.number().int().min(1).max(10000),
nuclearEscalationStrategicBombers: z.boolean(),
silverLions: z.number().int().nonnegative(),
goldenEagles: z.number().int().min(0).max(0x7fffffff),
preferLineSuccessor: z.boolean(),
autoTargetPick: z.enum(AUTO_TARGET_PICKS),
groundAi: GroundAiTuningSchema,
});
export const TuningPatchSchema = TuningValuesSchema.omit({ groundAi: true }).partial().extend({
groundAi: GroundAiTuningPatchSchema.optional(),
});
export const TuningViewSchema = z.object({ defaults: TuningValuesSchema, effective: TuningValuesSchema });
export type GroundAiTuningValues = z.output<typeof GroundAiTuningSchema>;
export type GroundAiTuningPatch = z.output<typeof GroundAiTuningPatchSchema>;
export type TuningValues = z.output<typeof TuningValuesSchema>;
export type TuningPatch = z.output<typeof TuningPatchSchema>;
export type TuningView = z.output<typeof TuningViewSchema>;