chore(repo): merge tank AI checkpoint for 0.1.6
This commit is contained in:
commit
710c8ecaaa
159 files changed
+35721
-1572
No files matched your search
@@ -0,0 +1,2 @@
|
||||
lab.local.json
|
||||
.cache/
|
||||
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>WTOffline AI Lab</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"mapsDir": "J:/GAME/WTOfflineProject-tank-ai/build/nav-stage2-fix/maps",
|
||||
"geoDir": "J:/GAME/WTOfflineProject-tank-ai/build/nav-stage2-fix/work",
|
||||
"logsDir": "J:/GAME/WTLab/client-2.61.0.58/.game_logs",
|
||||
"python": "J:/GAME/WTOfflineProject/.venv/Scripts/python.exe"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "@wto/ai-lab",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Ground AI lab: replay viewer for battle traces and simulator runs.",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"typecheck": "tsc --noEmit -p tsconfig.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@wto/ground-sim": "*",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
"three": "^0.187.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.17",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@types/three": "^0.187.0",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
"vite": "^7.3.6"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* Dev-server API of the AI lab (local only):
|
||||
* GET /api/maps levels that have a navigation pack in mapsDir
|
||||
* GET /api/maps/file?name= a pack or POI file of mapsDir
|
||||
* GET /api/logs game logs (.clog) in logsDir, newest first
|
||||
* GET /api/logs/text?name= a log decrypted with wtotools (cached until the log changes)
|
||||
* GET /api/scene?name= the 3D map (.wtoscene) of a level, built from its .wtogeo in geoDir
|
||||
* (cached until the geometry changes)
|
||||
* Paths come from lab.local.json next to this app (see lab.local.example.json).
|
||||
*/
|
||||
import { execFile } from 'node:child_process';
|
||||
import { createReadStream, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
|
||||
import type { ServerResponse } from 'node:http';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { buildMapScene, encodeMapScene, readGeo } from '@wto/ground-sim';
|
||||
import type { Connect, Plugin } from 'vite';
|
||||
|
||||
interface LabConfig {
|
||||
readonly mapsDir: string;
|
||||
/** Where the navigation bake left the levels' .wtogeo geometry. */
|
||||
readonly geoDir: string;
|
||||
readonly logsDir: string;
|
||||
readonly python: string;
|
||||
}
|
||||
|
||||
const APP_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const CACHE_DIR = path.join(APP_DIR, '.cache');
|
||||
const SAFE_NAME = /^[\w.-]+$/;
|
||||
|
||||
function loadConfig(): LabConfig {
|
||||
const file = path.join(APP_DIR, 'lab.local.json');
|
||||
const raw = existsSync(file) ? (JSON.parse(readFileSync(file, 'utf8')) as Record<string, unknown>) : {};
|
||||
const str = (key: string, fallback: string): string => (typeof raw[key] === 'string' ? (raw[key] as string) : fallback);
|
||||
const mapsDir = str('mapsDir', path.resolve(APP_DIR, '../../build/nav-stage2-fix/maps'));
|
||||
return {
|
||||
mapsDir,
|
||||
geoDir: str('geoDir', path.join(mapsDir, '..', 'work')),
|
||||
logsDir: str('logsDir', ''),
|
||||
python: str('python', 'python'),
|
||||
};
|
||||
}
|
||||
|
||||
function sendJson(res: ServerResponse, status: number, body: unknown): void {
|
||||
res.statusCode = status;
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
||||
res.end(JSON.stringify(body));
|
||||
}
|
||||
|
||||
function sendFile(res: ServerResponse, file: string, type: string): void {
|
||||
res.statusCode = 200;
|
||||
res.setHeader('Content-Type', type);
|
||||
createReadStream(file).pipe(res);
|
||||
}
|
||||
|
||||
function listMaps(cfg: LabConfig): { level: string; pois: boolean; scene: boolean }[] {
|
||||
if (!existsSync(cfg.mapsDir)) return [];
|
||||
return readdirSync(cfg.mapsDir)
|
||||
.filter((f) => f.endsWith('.wtonav'))
|
||||
.map((f) => {
|
||||
const level = f.slice(0, -'.wtonav'.length);
|
||||
return {
|
||||
level,
|
||||
pois: existsSync(path.join(cfg.mapsDir, `${level}.pois.json`)),
|
||||
scene: existsSync(path.join(cfg.geoDir, `${level}.wtogeo`)),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function listLogs(cfg: LabConfig): { name: string; size: number; mtime: number }[] {
|
||||
if (cfg.logsDir === '' || !existsSync(cfg.logsDir)) return [];
|
||||
return readdirSync(cfg.logsDir)
|
||||
.filter((f) => f.endsWith('.clog'))
|
||||
.map((name) => {
|
||||
const st = statSync(path.join(cfg.logsDir, name));
|
||||
return { name, size: st.size, mtime: st.mtimeMs };
|
||||
})
|
||||
.sort((a, b) => b.mtime - a.mtime);
|
||||
}
|
||||
|
||||
/** Decrypts `name` into the cache unless the cached text is newer than the log. */
|
||||
function decryptLog(cfg: LabConfig, name: string): Promise<string> {
|
||||
const source = path.join(cfg.logsDir, name);
|
||||
const out = path.join(CACHE_DIR, `${name}.txt`);
|
||||
mkdirSync(CACHE_DIR, { recursive: true });
|
||||
if (existsSync(out) && statSync(out).mtimeMs >= statSync(source).mtimeMs) return Promise.resolve(out);
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(cfg.python, ['-m', 'wtotools.cli', 'decrypt-clog', source, '--out', out], { timeout: 180_000 }, (err, _stdout, stderr) => {
|
||||
if (err !== null) reject(new Error(`decrypt-clog failed: ${stderr || err.message}`));
|
||||
else resolve(out);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** Builds the level's 3D map into the cache unless the cached one is newer than its geometry. */
|
||||
function sceneFile(cfg: LabConfig, level: string): string | undefined {
|
||||
const geo = path.join(cfg.geoDir, `${level}.wtogeo`);
|
||||
if (!existsSync(geo)) return undefined;
|
||||
const out = path.join(CACHE_DIR, `${level}.wtoscene`);
|
||||
if (existsSync(out) && statSync(out).mtimeMs >= statSync(geo).mtimeMs) return out;
|
||||
mkdirSync(CACHE_DIR, { recursive: true });
|
||||
writeFileSync(out, encodeMapScene(buildMapScene(readGeo(readFileSync(geo)))));
|
||||
return out;
|
||||
}
|
||||
|
||||
async function handle(cfg: LabConfig, url: URL, res: ServerResponse): Promise<boolean> {
|
||||
const name = url.searchParams.get('name') ?? '';
|
||||
if (url.pathname === '/api/maps') { sendJson(res, 200, listMaps(cfg)); return true; }
|
||||
if (url.pathname === '/api/logs') { sendJson(res, 200, listLogs(cfg)); return true; }
|
||||
const known = ['/api/maps/file', '/api/logs/text', '/api/scene'];
|
||||
if (!known.includes(url.pathname)) return false;
|
||||
if (!SAFE_NAME.test(name)) { sendJson(res, 400, { error: 'bad file name' }); return true; }
|
||||
if (url.pathname === '/api/scene') {
|
||||
const file = sceneFile(cfg, name);
|
||||
if (file === undefined) sendJson(res, 404, { error: `no ${name}.wtogeo in ${cfg.geoDir}` });
|
||||
else sendFile(res, file, 'application/octet-stream');
|
||||
return true;
|
||||
}
|
||||
if (url.pathname === '/api/maps/file') {
|
||||
const file = path.join(cfg.mapsDir, name);
|
||||
if (!existsSync(file)) sendJson(res, 404, { error: `no ${name} in ${cfg.mapsDir}` });
|
||||
else sendFile(res, file, name.endsWith('.json') ? 'application/json' : 'application/octet-stream');
|
||||
return true;
|
||||
}
|
||||
if (!name.endsWith('.clog') || !existsSync(path.join(cfg.logsDir, name))) {
|
||||
sendJson(res, 404, { error: `no log ${name}` });
|
||||
return true;
|
||||
}
|
||||
sendFile(res, await decryptLog(cfg, name), 'text/plain; charset=utf-8');
|
||||
return true;
|
||||
}
|
||||
|
||||
export function labApi(): Plugin {
|
||||
return {
|
||||
name: 'wto-ai-lab-api',
|
||||
configureServer(server) {
|
||||
const middleware: Connect.NextHandleFunction = (req, res, next) => {
|
||||
const url = new URL(req.url ?? '/', 'http://localhost');
|
||||
if (!url.pathname.startsWith('/api/')) { next(); return; }
|
||||
handle(loadConfig(), url, res)
|
||||
.then((handled) => { if (!handled) sendJson(res, 404, { error: 'unknown endpoint' }); })
|
||||
.catch((err: unknown) => sendJson(res, 500, { error: err instanceof Error ? err.message : String(err) }));
|
||||
};
|
||||
server.middlewares.use(middleware);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/** AI lab replay viewer: pick a game log, a battle in it, and play it back on the map. */
|
||||
import type { TraceBattle } from '@wto/ground-sim';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { fetchLogs, fetchMaps, loadLog, loadMap, type LogEntry, type MapData, type MapEntry } from './data.ts';
|
||||
import { sceneAt } from './frames.ts';
|
||||
import { Inspector } from './Inspector.tsx';
|
||||
import { Map3D, type MapLook } from './Map3D.tsx';
|
||||
import { buildMapLayer } from './mapLayer.ts';
|
||||
import type { ViewMode } from './three/cameraRig.ts';
|
||||
import type { Layers } from './three/overlays.ts';
|
||||
import { Timeline } from './Timeline.tsx';
|
||||
|
||||
const LAYER_LABELS: Readonly<Record<keyof Layers, string>> = {
|
||||
goals: '目标点', links: '目标连线', cones: '炮塔视野', labels: '标签', events: '开火与受击',
|
||||
};
|
||||
|
||||
const VIEW_LABELS: Readonly<Record<ViewMode, string>> = { top: '俯视', free: '自由', follow: '跟随选中车', gun: '炮口视角' };
|
||||
|
||||
function logLabel(l: LogEntry): string {
|
||||
const when = new Date(l.mtime).toLocaleString();
|
||||
return `${l.name}(${(l.size / 1e6).toFixed(1)} MB,${when})`;
|
||||
}
|
||||
|
||||
export function App(): React.JSX.Element {
|
||||
const [maps, setMaps] = useState<MapEntry[]>([]);
|
||||
const [logs, setLogs] = useState<LogEntry[]>([]);
|
||||
const [logName, setLogName] = useState('');
|
||||
const [battles, setBattles] = useState<TraceBattle[]>([]);
|
||||
const [battleIdx, setBattleIdx] = useState(0);
|
||||
const [mapData, setMapData] = useState<MapData | undefined>(undefined);
|
||||
const [exposure, setExposure] = useState(false);
|
||||
const [covers, setCovers] = useState(false);
|
||||
const [look, setLook] = useState<MapLook>({ view: 'top', navImage: true, objects: true, crushable: true });
|
||||
const [layers, setLayers] = useState<Layers>({ goals: true, links: true, cones: false, labels: false, events: true });
|
||||
const [t, setT] = useState(0);
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const [speed, setSpeed] = useState(4);
|
||||
const [selected, setSelected] = useState<string | undefined>(undefined);
|
||||
const [status, setStatus] = useState('');
|
||||
|
||||
const refreshLogs = (): void => { fetchLogs().then(setLogs).catch((e: unknown) => setStatus(String(e))); };
|
||||
useEffect(() => {
|
||||
fetchMaps().then(setMaps).catch((e: unknown) => setStatus(String(e)));
|
||||
refreshLogs();
|
||||
}, []);
|
||||
|
||||
const openLog = (name: string): void => {
|
||||
setLogName(name);
|
||||
setPlaying(false);
|
||||
setStatus('正在解密和读取日志…');
|
||||
loadLog(name).then((list) => {
|
||||
setBattles(list);
|
||||
// The longest battle that has bots in its trace; a battle left right after loading has none.
|
||||
let pick = list.length - 1;
|
||||
let best = 0;
|
||||
list.forEach((b, i) => {
|
||||
const withBots = b.frames.filter((f) => f.bots.size > 0).length;
|
||||
if (withBots > best) { best = withBots; pick = i; }
|
||||
});
|
||||
setBattleIdx(Math.max(0, pick));
|
||||
setStatus(list.length === 0 ? '这份日志里没有对局。' : '');
|
||||
}).catch((e: unknown) => setStatus(String(e)));
|
||||
};
|
||||
|
||||
const battle = battles[battleIdx];
|
||||
const level = battle?.level;
|
||||
useEffect(() => {
|
||||
setT(battle?.startT ?? 0);
|
||||
setSelected(undefined);
|
||||
}, [battle]);
|
||||
useEffect(() => {
|
||||
const entry = maps.find((m) => m.level === level);
|
||||
setMapData(undefined);
|
||||
if (entry === undefined) return;
|
||||
loadMap(entry).then(setMapData).catch((e: unknown) => setStatus(String(e)));
|
||||
}, [level, maps]);
|
||||
|
||||
const mapLayer = useMemo(
|
||||
() => (mapData === undefined ? undefined : buildMapLayer(mapData.pack, { tier: 1, exposure, covers })),
|
||||
[mapData, exposure, covers],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!playing || battle === undefined) return;
|
||||
let last = performance.now();
|
||||
let handle = requestAnimationFrame(function step(now) {
|
||||
const dt = (now - last) / 1000;
|
||||
last = now;
|
||||
setT((cur) => {
|
||||
const next = cur + dt * speed;
|
||||
if (next >= battle.endT) { setPlaying(false); return battle.endT; }
|
||||
return next;
|
||||
});
|
||||
handle = requestAnimationFrame(step);
|
||||
});
|
||||
return () => cancelAnimationFrame(handle);
|
||||
}, [playing, speed, battle]);
|
||||
|
||||
const scene = useMemo(() => (battle === undefined ? undefined : sceneAt(battle, t)), [battle, t]);
|
||||
|
||||
return (
|
||||
<div className="app">
|
||||
<header>
|
||||
<select value={logName} onChange={(e) => openLog(e.target.value)}>
|
||||
<option value="">选择游戏日志…</option>
|
||||
{logs.map((l) => <option key={l.name} value={l.name}>{logLabel(l)}</option>)}
|
||||
</select>
|
||||
<button type="button" onClick={refreshLogs}>刷新</button>
|
||||
{battles.length > 1 && (
|
||||
<select value={battleIdx} onChange={(e) => setBattleIdx(Number(e.target.value))}>
|
||||
{battles.map((b, i) => (
|
||||
<option key={i} value={i}>{`第 ${i + 1} 局 ${b.level ?? '未知地图'}(${b.frames.length} 帧)`}</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
{(Object.keys(LAYER_LABELS) as (keyof Layers)[]).map((k) => (
|
||||
<label key={k}>
|
||||
<input type="checkbox" checked={layers[k]} onChange={(e) => setLayers({ ...layers, [k]: e.target.checked })} />
|
||||
{LAYER_LABELS[k]}
|
||||
</label>
|
||||
))}
|
||||
<select value={look.view} onChange={(e) => setLook({ ...look, view: e.target.value as ViewMode })}>
|
||||
{(Object.keys(VIEW_LABELS) as ViewMode[]).map((v) => <option key={v} value={v}>{VIEW_LABELS[v]}</option>)}
|
||||
</select>
|
||||
<label><input type="checkbox" checked={look.navImage} onChange={(e) => setLook({ ...look, navImage: e.target.checked })} />导航网格</label>
|
||||
<label><input type="checkbox" checked={look.objects} onChange={(e) => setLook({ ...look, objects: e.target.checked })} />物体</label>
|
||||
<label><input type="checkbox" checked={look.crushable} onChange={(e) => setLook({ ...look, crushable: e.target.checked })} />可碾压物</label>
|
||||
<label><input type="checkbox" checked={exposure} onChange={(e) => setExposure(e.target.checked)} />暴露度</label>
|
||||
<label><input type="checkbox" checked={covers} onChange={(e) => setCovers(e.target.checked)} />掩体点</label>
|
||||
{status !== '' && <span className="status">{status}</span>}
|
||||
{battle !== undefined && battle.frames.length === 0 && <span className="status">这一局没有轨迹(游戏里没开 diagnostics.trace)。</span>}
|
||||
</header>
|
||||
<main>
|
||||
<Map3D mapScene={mapData?.scene} nav={mapLayer} battle={battle} scene={scene} selected={selected}
|
||||
layers={layers} look={look} onSelect={setSelected} />
|
||||
{battle !== undefined && <Inspector battle={battle} scene={scene} selected={selected} />}
|
||||
</main>
|
||||
{battle !== undefined && (
|
||||
<Timeline battle={battle} t={t} playing={playing} speed={speed} selected={selected}
|
||||
onSeek={setT} onPlaying={setPlaying} onSpeed={setSpeed} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/** Details of the selected vehicle at the current time, its recent log events, and the legends. */
|
||||
import type { TraceBattle, TraceEvent } from '@wto/ground-sim';
|
||||
import { eventsBetween, type SceneAt } from './frames.ts';
|
||||
import {
|
||||
BEHAVIOR_COLORS, BEHAVIOR_ZH, CLASS_ZH, COMMAND_ZH, DENY_COLORS, DENY_ZH, LANE_ZH, LOOK_COLORS, LOOK_ZH,
|
||||
STATE_ZH, URGENCY_ZH, zh,
|
||||
} from './labels.ts';
|
||||
|
||||
interface Props {
|
||||
readonly battle: TraceBattle;
|
||||
readonly scene: SceneAt | undefined;
|
||||
readonly selected: string | undefined;
|
||||
}
|
||||
|
||||
const RECENT_SEC = 20;
|
||||
|
||||
function angleDiff(a: number, b: number): number {
|
||||
return Math.abs(((((a - b) % 360) + 540) % 360) - 180);
|
||||
}
|
||||
|
||||
function involves(e: TraceEvent, eid: string): boolean {
|
||||
return e.eid === eid || e.fields['tgt'] === eid || e.fields['off'] === eid || e.fields['target'] === eid;
|
||||
}
|
||||
|
||||
function eventText(e: TraceEvent): string {
|
||||
return Object.entries(e.fields)
|
||||
.filter(([k]) => k !== 't' && k !== 'eid')
|
||||
.map(([k, v]) => `${k}=${v}`)
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
function Legend({ names, colors }: { names: readonly string[]; colors: readonly string[] }): React.JSX.Element {
|
||||
return (
|
||||
<div className="legend">
|
||||
{names.map((n, i) => (
|
||||
<span key={n}><i style={{ background: colors[i] ?? '#444' }} />{n}</span>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Row({ k, v }: { k: string; v: string }): React.JSX.Element {
|
||||
return <tr><th>{k}</th><td>{v}</td></tr>;
|
||||
}
|
||||
|
||||
export function Inspector({ battle, scene, selected }: Props): React.JSX.Element {
|
||||
const u = selected !== undefined ? scene?.units.get(selected) : undefined;
|
||||
const b = u?.bot;
|
||||
const recent = selected !== undefined && scene !== undefined
|
||||
? eventsBetween(battle, scene.t - RECENT_SEC, scene.t).filter((e) => involves(e, selected)).reverse()
|
||||
: [];
|
||||
return (
|
||||
<aside className="inspector">
|
||||
{u === undefined && <p className="hint">点击地图上的车辆查看详情。白框是玩家,黄色虚线是炮塔想看的方向,白线是实际炮管。</p>}
|
||||
{u !== undefined && (
|
||||
<table>
|
||||
<tbody>
|
||||
<Row k="编号" v={`${u.unit.eid}(${u.unit.army} 队,${u.unit.human ? '玩家' : u.unit.bot ? 'AI' : '原版 AI'})`} />
|
||||
<Row k="存活" v={u.unit.alive ? '是' : '否'} />
|
||||
<Row k="车速" v={`${u.unit.speed.toFixed(1)} m/s`} />
|
||||
{b !== undefined && <>
|
||||
<Row k="车型" v={zh(CLASS_ZH, b.vehicleClass)} />
|
||||
<Row k="任务" v={b.hasOrder ? `${zh(COMMAND_ZH, b.command)},紧迫度${zh(URGENCY_ZH, b.urgency)},点 ${b.capIdx},${zh(LANE_ZH, b.lane)}` : '无'} />
|
||||
<Row k="行为" v={`${zh(BEHAVIOR_ZH, b.behavior)}(分数 ${b.behaviorScore.toFixed(2)})`} />
|
||||
<Row k="状态" v={zh(STATE_ZH, b.state)} />
|
||||
<Row k="车速 期望/实际" v={`${b.wantSpeed.toFixed(1)} / ${b.forwardSpeed.toFixed(1)} m/s${b.reverseTravel ? ',倒车跟路' : ''}`} />
|
||||
<Row k="感知目标" v={b.target === '0' ? '无' : `${b.target}${b.targetInSight ? '(可见)' : '(不可见)'}`} />
|
||||
<Row k="威胁表" v={`${b.threatCount} 项,最高 ${b.topThreat},最高可见 ${b.topVisibleThreat}`} />
|
||||
<Row k="炮塔依据" v={`${zh(LOOK_ZH, b.lookReason)}${b.lookAt !== '0' ? ` → ${b.lookAt}` : ''}`} />
|
||||
<Row k="炮塔偏差" v={b.gunYaw === undefined ? '—' : `离想看的方向 ${angleDiff(b.gunYaw, b.wishYaw).toFixed(0)}°,离车头 ${angleDiff(b.gunYaw, u.yaw).toFixed(0)}°`} />
|
||||
<Row k="主炮" v={b.reloading ? '装填中' : b.gunReady ? '就绪' : '未就绪'} />
|
||||
<Row k="开火判定" v={`${zh(DENY_ZH, b.deny)},命中概率 ${(b.hitProb * 100).toFixed(0)}% / 门槛 ${(b.threshold * 100).toFixed(0)}%`} />
|
||||
<Row k="扳机要求车速" v={b.requestedSpeed >= 99 ? '不限' : `${b.requestedSpeed.toFixed(1)} m/s`} />
|
||||
</>}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
{recent.length > 0 && (
|
||||
<div className="events">
|
||||
<h4>最近 {RECENT_SEC} 秒的日志</h4>
|
||||
{recent.map((e, i) => (
|
||||
<div key={`${e.t}-${i}`}><b>{e.t.toFixed(1)}</b> {e.kind} <span>{eventText(e)}</span></div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<h4>行为</h4>
|
||||
<Legend names={BEHAVIOR_ZH} colors={BEHAVIOR_COLORS} />
|
||||
<h4>拒绝开火</h4>
|
||||
<Legend names={DENY_ZH} colors={DENY_COLORS} />
|
||||
<h4>炮塔依据</h4>
|
||||
<Legend names={LOOK_ZH} colors={LOOK_COLORS} />
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* The battle in 3D: terrain and object collision shapes of the level, vehicles as simple shapes,
|
||||
* and the replay's lines and markers. Left drag pans, right drag turns (except top-down), wheel
|
||||
* zooms; a click on a vehicle selects it.
|
||||
*/
|
||||
import { BEHAVIOR_NAMES, type MapScene, type TraceBattle } from '@wto/ground-sim';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { AmbientLight, Color, DirectionalLight, HemisphereLight, Raycaster, Scene, Vector2, WebGLRenderer } from 'three';
|
||||
import { CSS2DRenderer } from 'three/addons/renderers/CSS2DRenderer.js';
|
||||
import type { SceneAt, UnitAt } from './frames.ts';
|
||||
import type { MapLayer } from './mapLayer.ts';
|
||||
import { CameraRig, type ViewMode } from './three/cameraRig.ts';
|
||||
import { buildMapMeshes, setTerrainImage, type MapMeshes } from './three/mapMeshes.ts';
|
||||
import { Overlays, type Layers } from './three/overlays.ts';
|
||||
import { TankPool } from './three/tanks.ts';
|
||||
|
||||
export interface MapLook {
|
||||
readonly view: ViewMode;
|
||||
/** Drape the navigation mesh image over the terrain instead of height colours. */
|
||||
readonly navImage: boolean;
|
||||
readonly objects: boolean;
|
||||
readonly crushable: boolean;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
readonly mapScene: MapScene | undefined;
|
||||
readonly nav: MapLayer | undefined;
|
||||
readonly battle: TraceBattle | undefined;
|
||||
readonly scene: SceneAt | undefined;
|
||||
readonly selected: string | undefined;
|
||||
readonly layers: Layers;
|
||||
readonly look: MapLook;
|
||||
readonly onSelect: (eid: string | undefined) => void;
|
||||
}
|
||||
|
||||
interface World {
|
||||
readonly renderer: WebGLRenderer;
|
||||
readonly labels: CSS2DRenderer;
|
||||
readonly scene: Scene;
|
||||
readonly rig: CameraRig;
|
||||
map: MapMeshes | undefined;
|
||||
tanks: TankPool;
|
||||
overlays: Overlays;
|
||||
selected: string | undefined;
|
||||
}
|
||||
|
||||
const CRUSHABLE_KIND = 3;
|
||||
const CLICK_PX = 4;
|
||||
|
||||
function labelOf(u: UnitAt): string {
|
||||
const name = u.bot !== undefined ? (BEHAVIOR_NAMES[u.bot.behavior] ?? '?') : u.unit.human ? 'player' : '';
|
||||
return `${u.unit.eid.replace(/^0x/, '')} ${name}`;
|
||||
}
|
||||
|
||||
function createWorld(host: HTMLDivElement): World {
|
||||
const renderer = new WebGLRenderer({ antialias: true, logarithmicDepthBuffer: true });
|
||||
renderer.setPixelRatio(window.devicePixelRatio);
|
||||
host.appendChild(renderer.domElement);
|
||||
const labels = new CSS2DRenderer();
|
||||
labels.domElement.className = 'labels3d';
|
||||
host.appendChild(labels.domElement);
|
||||
const scene = new Scene();
|
||||
scene.background = new Color(0x0b0c0d);
|
||||
scene.add(new HemisphereLight(0xdfe8ff, 0x3a3326, 1.4), new AmbientLight(0xffffff, 0.25));
|
||||
const sun = new DirectionalLight(0xffffff, 1.6);
|
||||
sun.position.set(0.5, 1, 0.3);
|
||||
scene.add(sun);
|
||||
const tanks = new TankPool(undefined);
|
||||
const overlays = new Overlays(tanks);
|
||||
scene.add(tanks.group, overlays.group);
|
||||
return { renderer, labels, scene, rig: new CameraRig(renderer.domElement), map: undefined, tanks, overlays, selected: undefined };
|
||||
}
|
||||
|
||||
function replaceMap(w: World, mapScene: MapScene | undefined, nav: MapLayer | undefined): void {
|
||||
if (w.map !== undefined) { w.scene.remove(w.map.group); w.map.dispose(); }
|
||||
w.scene.remove(w.tanks.group, w.overlays.group);
|
||||
w.tanks.dispose();
|
||||
w.overlays.dispose();
|
||||
w.map = mapScene === undefined ? undefined : buildMapMeshes(mapScene, nav);
|
||||
w.tanks = new TankPool(mapScene?.terrain);
|
||||
w.overlays = new Overlays(w.tanks);
|
||||
if (w.map !== undefined) w.scene.add(w.map.group);
|
||||
w.scene.add(w.tanks.group, w.overlays.group);
|
||||
if (mapScene !== undefined) {
|
||||
const t = mapScene.terrain;
|
||||
let sum = 0;
|
||||
for (const h of t.heights) sum += h;
|
||||
w.rig.fit(mapScene.boundsMin[0], mapScene.boundsMin[1], mapScene.boundsMax[0], mapScene.boundsMax[1], sum / Math.max(1, t.heights.length));
|
||||
}
|
||||
}
|
||||
|
||||
export function Map3D({ mapScene, nav, battle, scene, selected, layers, look, onSelect }: Props): React.JSX.Element {
|
||||
const hostRef = useRef<HTMLDivElement>(null);
|
||||
const worldRef = useRef<World | undefined>(undefined);
|
||||
const onSelectRef = useRef(onSelect);
|
||||
onSelectRef.current = onSelect;
|
||||
|
||||
useEffect(() => {
|
||||
const host = hostRef.current;
|
||||
if (host === null) return;
|
||||
const w = createWorld(host);
|
||||
worldRef.current = w;
|
||||
const resize = (): void => {
|
||||
const r = host.getBoundingClientRect();
|
||||
w.renderer.setSize(r.width, r.height);
|
||||
w.labels.setSize(r.width, r.height);
|
||||
w.rig.resize(r.width, r.height);
|
||||
};
|
||||
const obs = new ResizeObserver(resize);
|
||||
obs.observe(host);
|
||||
resize();
|
||||
w.renderer.setAnimationLoop(() => {
|
||||
w.rig.tick(w.selected === undefined ? undefined : w.tanks.get(w.selected));
|
||||
w.renderer.render(w.scene, w.rig.camera);
|
||||
w.labels.render(w.scene, w.rig.camera);
|
||||
});
|
||||
const down = new Vector2();
|
||||
const el = w.renderer.domElement;
|
||||
const onDown = (e: PointerEvent): void => { down.set(e.clientX, e.clientY); };
|
||||
const onUp = (e: PointerEvent): void => {
|
||||
if (e.button !== 0 || Math.hypot(e.clientX - down.x, e.clientY - down.y) > CLICK_PX) return;
|
||||
const r = el.getBoundingClientRect();
|
||||
const ray = new Raycaster();
|
||||
ray.setFromCamera(new Vector2(((e.clientX - r.left) / r.width) * 2 - 1, -((e.clientY - r.top) / r.height) * 2 + 1), w.rig.camera);
|
||||
const hit = ray.intersectObjects(w.tanks.pickables(), false)[0];
|
||||
onSelectRef.current(hit?.object.userData['eid'] as string | undefined);
|
||||
};
|
||||
el.addEventListener('pointerdown', onDown);
|
||||
el.addEventListener('pointerup', onUp);
|
||||
return () => {
|
||||
obs.disconnect();
|
||||
el.removeEventListener('pointerdown', onDown);
|
||||
el.removeEventListener('pointerup', onUp);
|
||||
w.renderer.setAnimationLoop(null);
|
||||
replaceMap(w, undefined, undefined);
|
||||
w.rig.dispose();
|
||||
w.renderer.dispose();
|
||||
host.replaceChildren();
|
||||
worldRef.current = undefined;
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const w = worldRef.current;
|
||||
if (w !== undefined) replaceMap(w, mapScene, nav);
|
||||
// The navigation image is applied by the effect below; only a new level rebuilds the map.
|
||||
}, [mapScene]);
|
||||
|
||||
useEffect(() => {
|
||||
const w = worldRef.current;
|
||||
if (w?.map !== undefined) setTerrainImage(w.map, look.navImage ? nav : undefined);
|
||||
}, [nav, look.navImage, mapScene]);
|
||||
|
||||
useEffect(() => {
|
||||
const w = worldRef.current;
|
||||
if (w?.map === undefined) return;
|
||||
w.map.kinds.forEach((g, k) => { g.visible = look.objects && (k !== CRUSHABLE_KIND || look.crushable); });
|
||||
}, [look.objects, look.crushable, mapScene]);
|
||||
|
||||
useEffect(() => {
|
||||
worldRef.current?.rig.setMode(look.view);
|
||||
}, [look.view]);
|
||||
|
||||
useEffect(() => {
|
||||
const w = worldRef.current;
|
||||
if (w === undefined) return;
|
||||
w.selected = selected;
|
||||
w.rig.refollow();
|
||||
}, [selected]);
|
||||
|
||||
useEffect(() => {
|
||||
const w = worldRef.current;
|
||||
if (w === undefined || battle === undefined || scene === undefined) return;
|
||||
w.tanks.update(scene.units, selected, (u) => (layers.labels && u.unit.alive ? labelOf(u) : undefined));
|
||||
w.overlays.update(battle, scene, layers);
|
||||
}, [battle, scene, selected, layers, mapScene]);
|
||||
|
||||
return <div ref={hostRef} className="map3d" />;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Playback controls and, for the selected bot, three strips over the whole battle: its behavior,
|
||||
* the reason it did not fire, and why its turret pointed where it did. Click a strip to seek.
|
||||
*/
|
||||
import type { TraceBattle } from '@wto/ground-sim';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { BEHAVIOR_COLORS, DENY_COLORS, LOOK_COLORS } from './labels.ts';
|
||||
|
||||
interface Props {
|
||||
readonly battle: TraceBattle;
|
||||
readonly t: number;
|
||||
readonly playing: boolean;
|
||||
readonly speed: number;
|
||||
readonly selected: string | undefined;
|
||||
readonly onSeek: (t: number) => void;
|
||||
readonly onPlaying: (playing: boolean) => void;
|
||||
readonly onSpeed: (speed: number) => void;
|
||||
}
|
||||
|
||||
const SPEEDS = [0.5, 1, 2, 4, 8, 16];
|
||||
const STRIP_H = 10;
|
||||
|
||||
function drawStrips(canvas: HTMLCanvasElement, battle: TraceBattle, eid: string | undefined, t: number): void {
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (ctx === null) return;
|
||||
const w = canvas.width;
|
||||
const span = Math.max(1, battle.endT - battle.startT);
|
||||
ctx.fillStyle = '#16181a';
|
||||
ctx.fillRect(0, 0, w, canvas.height);
|
||||
if (eid !== undefined) {
|
||||
const frames = battle.frames;
|
||||
for (let i = 0; i < frames.length; i++) {
|
||||
const f = frames[i];
|
||||
const bot = f?.bots.get(eid);
|
||||
if (f === undefined || bot === undefined) continue;
|
||||
const x0 = ((f.t - battle.startT) / span) * w;
|
||||
const x1 = (((frames[i + 1]?.t ?? f.t + 0.5) - battle.startT) / span) * w;
|
||||
const bw = Math.max(1, x1 - x0);
|
||||
ctx.fillStyle = BEHAVIOR_COLORS[bot.behavior] ?? '#444';
|
||||
ctx.fillRect(x0, 0, bw, STRIP_H);
|
||||
ctx.fillStyle = DENY_COLORS[bot.deny] ?? '#444';
|
||||
ctx.fillRect(x0, STRIP_H + 2, bw, STRIP_H);
|
||||
ctx.fillStyle = LOOK_COLORS[bot.lookReason] ?? '#444';
|
||||
ctx.fillRect(x0, 2 * (STRIP_H + 2), bw, STRIP_H);
|
||||
}
|
||||
}
|
||||
const cx = ((t - battle.startT) / span) * w;
|
||||
ctx.fillStyle = '#fff';
|
||||
ctx.fillRect(cx - 1, 0, 2, canvas.height);
|
||||
}
|
||||
|
||||
export function Timeline({ battle, t, playing, speed, selected, onSeek, onPlaying, onSpeed }: Props): React.JSX.Element {
|
||||
const stripRef = useRef<HTMLCanvasElement>(null);
|
||||
useEffect(() => {
|
||||
const c = stripRef.current;
|
||||
if (c === null) return;
|
||||
c.width = Math.max(1, Math.floor(c.getBoundingClientRect().width));
|
||||
drawStrips(c, battle, selected, t);
|
||||
}, [battle, selected, t]);
|
||||
|
||||
return (
|
||||
<div className="timeline">
|
||||
<div className="controls">
|
||||
<button type="button" onClick={() => onPlaying(!playing)}>{playing ? '暂停' : '播放'}</button>
|
||||
<select value={speed} onChange={(e) => onSpeed(Number(e.target.value))}>
|
||||
{SPEEDS.map((s) => <option key={s} value={s}>{s}×</option>)}
|
||||
</select>
|
||||
<span className="time">{t.toFixed(1)} s / {battle.endT.toFixed(0)} s</span>
|
||||
<input
|
||||
type="range" min={battle.startT} max={battle.endT} step={0.1} value={t}
|
||||
onChange={(e) => onSeek(Number(e.target.value))}
|
||||
/>
|
||||
</div>
|
||||
<div className="strip-labels"><span>行为</span><span>拒绝开火</span><span>炮塔依据</span></div>
|
||||
<canvas
|
||||
ref={stripRef}
|
||||
className="strips"
|
||||
height={3 * (STRIP_H + 2)}
|
||||
onClick={(e) => {
|
||||
const w = e.currentTarget.width;
|
||||
onSeek(battle.startT + (e.nativeEvent.offsetX / w) * (battle.endT - battle.startT));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/** Loading maps and logs through the lab's dev-server API (server/lab-api.ts). */
|
||||
import {
|
||||
decodeMapScene, parsePois, parseTraceLog, readNavPack, type MapPois, type MapScene, type NavPack, type TraceBattle,
|
||||
} from '@wto/ground-sim';
|
||||
|
||||
export interface LogEntry {
|
||||
readonly name: string;
|
||||
readonly size: number;
|
||||
readonly mtime: number;
|
||||
}
|
||||
|
||||
export interface MapEntry {
|
||||
readonly level: string;
|
||||
readonly pois: boolean;
|
||||
/** The level's geometry is there, so it has a 3D map. */
|
||||
readonly scene: boolean;
|
||||
}
|
||||
|
||||
export interface MapData {
|
||||
readonly pack: NavPack;
|
||||
readonly pois: MapPois | undefined;
|
||||
readonly scene: MapScene | undefined;
|
||||
}
|
||||
|
||||
async function get(url: string): Promise<Response> {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) {
|
||||
const body = await res.text();
|
||||
throw new Error(`${url}: ${res.status} ${body}`);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function fetchMaps(): Promise<MapEntry[]> {
|
||||
return (await (await get('/api/maps')).json()) as MapEntry[];
|
||||
}
|
||||
|
||||
export async function fetchLogs(): Promise<LogEntry[]> {
|
||||
return (await (await get('/api/logs')).json()) as LogEntry[];
|
||||
}
|
||||
|
||||
export async function loadLog(name: string): Promise<TraceBattle[]> {
|
||||
const text = await (await get(`/api/logs/text?name=${encodeURIComponent(name)}`)).text();
|
||||
return parseTraceLog(text);
|
||||
}
|
||||
|
||||
export async function loadMap(entry: MapEntry): Promise<MapData> {
|
||||
const bytes = new Uint8Array(await (await get(`/api/maps/file?name=${encodeURIComponent(`${entry.level}.wtonav`)}`)).arrayBuffer());
|
||||
const pois = entry.pois
|
||||
? parsePois(await (await get(`/api/maps/file?name=${encodeURIComponent(`${entry.level}.pois.json`)}`)).text())
|
||||
: undefined;
|
||||
const scene = entry.scene
|
||||
? decodeMapScene(new Uint8Array(await (await get(`/api/scene?name=${encodeURIComponent(entry.level)}`)).arrayBuffer()))
|
||||
: undefined;
|
||||
return { pack: readNavPack(bytes), pois, scene };
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/** Looking up the battle state at any time between two trace samples. */
|
||||
import type { BotSample, CapSample, TraceBattle, TraceEvent, UnitSample } from '@wto/ground-sim';
|
||||
|
||||
export interface UnitAt {
|
||||
readonly unit: UnitSample;
|
||||
/** Interpolated position, hull heading, pitch and roll. */
|
||||
readonly x: number;
|
||||
readonly y: number;
|
||||
readonly z: number;
|
||||
readonly yaw: number;
|
||||
readonly hullPitch: number;
|
||||
readonly hullRoll: number;
|
||||
/** Interpolated gun world yaw and pitch; from the bot line, or the hull, when the unit line has none. */
|
||||
readonly gunYaw: number;
|
||||
readonly gunPitch: number;
|
||||
/** Decision state of the sample at or before the time; undefined for players. */
|
||||
readonly bot: BotSample | undefined;
|
||||
}
|
||||
|
||||
export interface SceneAt {
|
||||
readonly t: number;
|
||||
readonly units: Map<string, UnitAt>;
|
||||
readonly caps: CapSample[];
|
||||
}
|
||||
|
||||
/** Index of the last frame at or before `t` (-1 before the first). */
|
||||
export function frameIndexAt(battle: TraceBattle, t: number): number {
|
||||
let lo = 0;
|
||||
let hi = battle.frames.length - 1;
|
||||
let found = -1;
|
||||
while (lo <= hi) {
|
||||
const mid = (lo + hi) >> 1;
|
||||
if ((battle.frames[mid]?.t ?? Infinity) <= t) { found = mid; lo = mid + 1; } else hi = mid - 1;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
function lerpYaw(a: number, b: number, k: number): number {
|
||||
const d = ((((b - a) % 360) + 540) % 360) - 180;
|
||||
return a + d * k;
|
||||
}
|
||||
|
||||
function lerp(a: number, b: number | undefined, k: number): number {
|
||||
return a + ((b ?? a) - a) * k;
|
||||
}
|
||||
|
||||
function gunOf(u: UnitSample, bot: BotSample | undefined): [number, number] {
|
||||
return [u.gunYaw ?? bot?.gunYaw ?? u.yaw, u.gunPitch ?? 0];
|
||||
}
|
||||
|
||||
export function sceneAt(battle: TraceBattle, t: number): SceneAt {
|
||||
const i = Math.max(0, frameIndexAt(battle, t));
|
||||
const a = battle.frames[i];
|
||||
const b = battle.frames[i + 1];
|
||||
const units = new Map<string, UnitAt>();
|
||||
if (a === undefined) return { t, units, caps: [] };
|
||||
const k = b !== undefined && b.t > a.t ? Math.min(1, Math.max(0, (t - a.t) / (b.t - a.t))) : 0;
|
||||
for (const [eid, ua] of a.units) {
|
||||
const ub = b?.units.get(eid);
|
||||
const move = ub !== undefined && ua.alive && ub.alive ? k : 0;
|
||||
const bot = a.bots.get(eid);
|
||||
const [gyA, gpA] = gunOf(ua, bot);
|
||||
const [gyB, gpB] = ub !== undefined ? gunOf(ub, b?.bots.get(eid)) : [gyA, gpA];
|
||||
units.set(eid, {
|
||||
unit: ua,
|
||||
x: lerp(ua.x, ub?.x, move),
|
||||
y: lerp(ua.y, ub?.y, move),
|
||||
z: lerp(ua.z, ub?.z, move),
|
||||
yaw: lerpYaw(ua.yaw, ub?.yaw ?? ua.yaw, move),
|
||||
hullPitch: lerp(ua.hullPitch ?? 0, ub?.hullPitch, move),
|
||||
hullRoll: lerp(ua.hullRoll ?? 0, ub?.hullRoll, move),
|
||||
gunYaw: lerpYaw(gyA, gyB, move),
|
||||
gunPitch: lerp(gpA, gpB, move),
|
||||
bot,
|
||||
});
|
||||
}
|
||||
return { t, units, caps: a.caps };
|
||||
}
|
||||
|
||||
/** Events with time in [from, to], from the sorted event list. */
|
||||
export function eventsBetween(battle: TraceBattle, from: number, to: number): TraceEvent[] {
|
||||
let lo = 0;
|
||||
let hi = battle.events.length;
|
||||
while (lo < hi) {
|
||||
const mid = (lo + hi) >> 1;
|
||||
if ((battle.events[mid]?.t ?? Infinity) < from) lo = mid + 1; else hi = mid;
|
||||
}
|
||||
const out: TraceEvent[] = [];
|
||||
for (let i = lo; i < battle.events.length; i++) {
|
||||
const e = battle.events[i];
|
||||
if (e === undefined || e.t > to) break;
|
||||
out.push(e);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/** Chinese display names for the trace codes (the codes themselves are in @wto/ground-sim). */
|
||||
|
||||
export const BEHAVIOR_ZH = ['推进', '交战推进', '短停', '回掩体', '换位', '守位', '疏散', '撤回', '维修'] as const;
|
||||
|
||||
export const BEHAVIOR_COLORS = ['#6c8ebf', '#e0884a', '#e5d34a', '#8fbf6c', '#b07cc6', '#5fb8b0', '#9a9a9a', '#c65f5f', '#7a5a3a'] as const;
|
||||
|
||||
export const STATE_ZH: Readonly<Record<number, string>> = {
|
||||
0: '行军', 1: '行进交战', 3: '短停', 4: '退入掩体', 5: '掩体装填', 7: '原地守位', 8: '换位',
|
||||
9: '失能', 10: '疏散', 11: '坡脊撤回',
|
||||
};
|
||||
|
||||
export const DENY_ZH = [
|
||||
'放行', '无目标', '炮未就绪', '命中概率不足', '远距窗口不足', '瞄准误差', '等待炮管稳定', '检查预算',
|
||||
'炮口有硬物', '弹道有硬物', '友军', '多炮检查', '射界外', '点射间歇',
|
||||
] as const;
|
||||
|
||||
export const DENY_COLORS = [
|
||||
'#4caf50', '#333', '#666', '#e53935', '#8e24aa', '#fb8c00', '#fdd835', '#90a4ae',
|
||||
'#6d4c41', '#795548', '#03a9f4', '#9e9e9e', '#d81b60', '#26a69a',
|
||||
] as const;
|
||||
|
||||
export const LOOK_ZH = ['—', '交战目标', '威胁', '目标消失处', '记忆位置', '线索', '扫视'] as const;
|
||||
|
||||
export const LOOK_COLORS = ['#333', '#e53935', '#fb8c00', '#fdd835', '#8e24aa', '#03a9f4', '#607d8b'] as const;
|
||||
|
||||
export const COMMAND_ZH = ['主攻', '侧翼', '架枪', '防守', '预备', '防空'] as const;
|
||||
|
||||
export const URGENCY_ZH = ['低', '中', '高'] as const;
|
||||
|
||||
export const LANE_ZH = ['中路', '左翼', '右翼'] as const;
|
||||
|
||||
export const CLASS_ZH = ['中坦', '轻坦', '重坦', '歼击车', '防空'] as const;
|
||||
|
||||
export function zh(names: readonly string[] | Readonly<Record<number, string>>, code: number): string {
|
||||
const name = Array.isArray(names) ? names[code] : (names as Readonly<Record<number, string>>)[code];
|
||||
return name ?? String(code);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { StrictMode } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { App } from './App.tsx';
|
||||
import './style.css';
|
||||
|
||||
const root = document.getElementById('root');
|
||||
if (root !== null) createRoot(root).render(<StrictMode><App /></StrictMode>);
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* The navigation image draped over the 3D terrain, drawn once into an offscreen canvas: walkable polygons of one mesh tier coloured
|
||||
* by surface, optionally the tactical grid's exposure and the baked cover points.
|
||||
*/
|
||||
import { NAV_AREA_NAMES, type NavPack } from '@wto/ground-sim';
|
||||
|
||||
export interface MapLayer {
|
||||
readonly canvas: HTMLCanvasElement;
|
||||
/** World x of the canvas's left edge and world z of its top edge. */
|
||||
readonly x0: number;
|
||||
readonly z1: number;
|
||||
readonly pxPerM: number;
|
||||
}
|
||||
|
||||
export interface MapLayerOptions {
|
||||
readonly tier: number;
|
||||
readonly exposure: boolean;
|
||||
readonly covers: boolean;
|
||||
}
|
||||
|
||||
const AREA_COLORS: Readonly<Record<string, string>> = {
|
||||
road: '#77786a', bridge: '#a0a090', ground: '#3d4a33', rough: '#5a4d34', forest: '#29402a',
|
||||
crushable: '#4f5f35', shallowWater: '#35607a', chokepoint: '#7a6a35', exposed: '#5f5f33',
|
||||
deepWater: '#1d3a66', noGo: '#3a2626',
|
||||
};
|
||||
|
||||
export function buildMapLayer(pack: NavPack, opts: MapLayerOptions): MapLayer {
|
||||
const [x0, , z0] = pack.header.bmin;
|
||||
const [x1, , z1] = pack.header.bmax;
|
||||
const pxPerM = Math.min(2, 4096 / Math.max(x1 - x0, z1 - z0));
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = Math.ceil((x1 - x0) * pxPerM);
|
||||
canvas.height = Math.ceil((z1 - z0) * pxPerM);
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (ctx === null) return { canvas, x0, z1, pxPerM };
|
||||
// Off the mesh (buildings, steep or blocked ground) when draped over the 3D terrain.
|
||||
ctx.fillStyle = '#55584f';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
const tier = pack.tiers[opts.tier] ?? pack.tiers[1];
|
||||
if (tier !== undefined) {
|
||||
for (let area = 1; area < NAV_AREA_NAMES.length; area++) {
|
||||
ctx.beginPath();
|
||||
for (let i = 0; i < tier.polyCount; i++) {
|
||||
if (tier.areas[i] !== area) continue;
|
||||
const ring = tier.rings[i];
|
||||
if (ring === undefined) continue;
|
||||
for (let k = 0; k < ring.length; k += 2) {
|
||||
const px = ((ring[k] ?? 0) - x0) * pxPerM;
|
||||
const py = (z1 - (ring[k + 1] ?? 0)) * pxPerM;
|
||||
if (k === 0) ctx.moveTo(px, py);
|
||||
else ctx.lineTo(px, py);
|
||||
}
|
||||
ctx.closePath();
|
||||
}
|
||||
ctx.fillStyle = AREA_COLORS[NAV_AREA_NAMES[area] ?? ''] ?? '#444';
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
if (opts.exposure) drawExposure(ctx, pack, x0, z1, pxPerM);
|
||||
if (opts.covers) drawCovers(ctx, pack, x0, z1, pxPerM);
|
||||
return { canvas, x0, z1, pxPerM };
|
||||
}
|
||||
|
||||
function drawExposure(ctx: CanvasRenderingContext2D, pack: NavPack, x0: number, z1: number, pxPerM: number): void {
|
||||
const g = pack.tactical;
|
||||
const cell = g.cellM * pxPerM;
|
||||
for (let r = 0; r < g.rows; r++) {
|
||||
for (let c = 0; c < g.cols; c++) {
|
||||
const e = g.exposure[r * g.cols + c] ?? 0;
|
||||
if (e < 16) continue;
|
||||
ctx.fillStyle = `rgba(255, 80, 40, ${(e / 255) * 0.45})`;
|
||||
const wx = g.origin[0] + c * g.cellM;
|
||||
const wz = g.origin[1] + r * g.cellM;
|
||||
ctx.fillRect((wx - x0) * pxPerM, (z1 - wz - g.cellM) * pxPerM, cell, cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawCovers(ctx: CanvasRenderingContext2D, pack: NavPack, x0: number, z1: number, pxPerM: number): void {
|
||||
for (const cv of pack.covers) {
|
||||
const px = (cv.pos[0] - x0) * pxPerM;
|
||||
const py = (z1 - cv.pos[2]) * pxPerM;
|
||||
ctx.strokeStyle = cv.kind === 1 ? 'rgba(120, 220, 255, 0.8)' : 'rgba(255, 230, 120, 0.8)';
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(px, py);
|
||||
ctx.lineTo(px + cv.coverDir[0] * 6 * pxPerM, py - cv.coverDir[1] * 6 * pxPerM);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
* { box-sizing: border-box; }
|
||||
html, body, #root { margin: 0; height: 100%; background: #0b0c0d; color: #ddd; font: 13px/1.4 system-ui, 'Microsoft YaHei', sans-serif; }
|
||||
.app { display: flex; flex-direction: column; height: 100%; }
|
||||
header { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 6px 10px; background: #16181a; border-bottom: 1px solid #2a2d30; }
|
||||
header select { max-width: 420px; }
|
||||
header label { display: inline-flex; align-items: center; gap: 3px; }
|
||||
.status { color: #ffb74d; }
|
||||
main { flex: 1; display: flex; min-height: 0; }
|
||||
.map3d { flex: 1; min-width: 0; height: 100%; position: relative; overflow: hidden; }
|
||||
.map3d canvas { display: block; }
|
||||
.labels3d { position: absolute; inset: 0; pointer-events: none; }
|
||||
.tank-label { color: rgba(255,255,255,0.9); font-size: 11px; text-shadow: 0 0 3px #000; white-space: nowrap; }
|
||||
.tank-label.human { color: #ffe14a; }
|
||||
.inspector { width: 360px; overflow-y: auto; padding: 8px 10px; background: #121416; border-left: 1px solid #2a2d30; }
|
||||
.inspector table { width: 100%; border-collapse: collapse; }
|
||||
.inspector th { text-align: left; color: #999; font-weight: normal; padding: 2px 8px 2px 0; white-space: nowrap; vertical-align: top; }
|
||||
.inspector td { padding: 2px 0; }
|
||||
.inspector h4 { margin: 12px 0 4px; color: #aaa; font-weight: normal; }
|
||||
.hint { color: #999; }
|
||||
.events { font-size: 12px; }
|
||||
.events div { padding: 1px 0; border-bottom: 1px solid #1d2023; word-break: break-all; }
|
||||
.events span { color: #999; }
|
||||
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
|
||||
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 3px; vertical-align: -1px; }
|
||||
.timeline { padding: 6px 10px; background: #16181a; border-top: 1px solid #2a2d30; }
|
||||
.controls { display: flex; gap: 8px; align-items: center; }
|
||||
.controls input[type='range'] { flex: 1; }
|
||||
.time { min-width: 120px; font-variant-numeric: tabular-nums; }
|
||||
.strip-labels { display: flex; gap: 12px; font-size: 11px; color: #888; margin-top: 4px; }
|
||||
canvas.strips { width: 100%; height: 36px; display: block; cursor: pointer; }
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* The 3D view's cameras: a top-down orthographic map view (world +z up the screen, like the old
|
||||
* flat map), a free perspective view, a view that follows the selected vehicle, and a view out of
|
||||
* its muzzle along the barrel.
|
||||
*/
|
||||
import { OrthographicCamera, PerspectiveCamera, Quaternion, Vector3, type Camera } from 'three';
|
||||
import { MapControls } from 'three/addons/controls/MapControls.js';
|
||||
import type { Tank } from './tanks.ts';
|
||||
|
||||
export type ViewMode = 'top' | 'free' | 'follow' | 'gun';
|
||||
|
||||
const TOP_HEIGHT = 3000;
|
||||
/** Top-down camera sits this far south of its target, so the controls keep north up. */
|
||||
const TOP_SOUTH = 0.01;
|
||||
const FREE_MAX_POLAR = Math.PI * 0.49;
|
||||
|
||||
export class CameraRig {
|
||||
readonly persp = new PerspectiveCamera(50, 1, 0.5, 20000);
|
||||
readonly ortho = new OrthographicCamera(-1, 1, 1, -1, 1, 10000);
|
||||
readonly controls: MapControls;
|
||||
private mode: ViewMode = 'top';
|
||||
private aspect = 1;
|
||||
private readonly lastFollow = new Vector3();
|
||||
private following = false;
|
||||
|
||||
constructor(dom: HTMLElement) {
|
||||
this.controls = new MapControls(this.ortho, dom);
|
||||
this.controls.enableDamping = true;
|
||||
this.controls.dampingFactor = 0.15;
|
||||
this.controls.screenSpacePanning = true;
|
||||
this.limitTilt();
|
||||
}
|
||||
|
||||
/** Top-down stays straight down; the other views may tilt down to just above the horizon. */
|
||||
private limitTilt(): void {
|
||||
this.controls.maxPolarAngle = this.mode === 'top' ? 0 : FREE_MAX_POLAR;
|
||||
}
|
||||
|
||||
get camera(): Camera {
|
||||
return this.mode === 'top' ? this.ortho : this.persp;
|
||||
}
|
||||
|
||||
resize(w: number, h: number): void {
|
||||
this.aspect = w / Math.max(1, h);
|
||||
this.persp.aspect = this.aspect;
|
||||
this.persp.updateProjectionMatrix();
|
||||
const half = (this.ortho.top - this.ortho.bottom) / 2;
|
||||
this.ortho.left = -half * this.aspect;
|
||||
this.ortho.right = half * this.aspect;
|
||||
this.ortho.updateProjectionMatrix();
|
||||
}
|
||||
|
||||
/** Frames the world rectangle (x, z) in both cameras. */
|
||||
fit(minX: number, minZ: number, maxX: number, maxZ: number, groundY: number): void {
|
||||
const cx = (minX + maxX) / 2;
|
||||
const cz = -(minZ + maxZ) / 2;
|
||||
const half = (Math.max((maxX - minX) / this.aspect, maxZ - minZ) / 2) * 1.05;
|
||||
Object.assign(this.ortho, { left: -half * this.aspect, right: half * this.aspect, top: half, bottom: -half, zoom: 1 });
|
||||
this.ortho.updateProjectionMatrix();
|
||||
this.ortho.position.set(cx, groundY + TOP_HEIGHT, cz + TOP_SOUTH);
|
||||
this.persp.position.set(cx, groundY + half * 0.9, cz + half * 1.1);
|
||||
this.controls.target.set(cx, groundY, cz);
|
||||
this.ortho.lookAt(this.controls.target);
|
||||
this.persp.lookAt(this.controls.target);
|
||||
this.controls.update();
|
||||
}
|
||||
|
||||
setMode(mode: ViewMode): void {
|
||||
if (mode === this.mode) return;
|
||||
const target = this.controls.target.clone();
|
||||
if (this.mode === 'top' && mode !== 'gun') {
|
||||
const span = (this.ortho.top - this.ortho.bottom) / this.ortho.zoom;
|
||||
this.persp.position.set(target.x, target.y + span * 0.6, target.z + span * 0.6);
|
||||
}
|
||||
if (mode === 'top') this.ortho.position.set(target.x, target.y + TOP_HEIGHT, target.z + TOP_SOUTH);
|
||||
this.mode = mode;
|
||||
this.limitTilt();
|
||||
this.following = false;
|
||||
this.controls.object = this.camera;
|
||||
this.controls.enableRotate = mode !== 'top';
|
||||
this.controls.enabled = mode !== 'gun';
|
||||
this.camera.lookAt(target);
|
||||
this.controls.update();
|
||||
}
|
||||
|
||||
/** The next follow frame starts over around the (newly) selected vehicle. */
|
||||
refollow(): void {
|
||||
this.following = false;
|
||||
}
|
||||
|
||||
/** Per frame: keeps the followed vehicle centred, or puts the camera at the muzzle. */
|
||||
tick(tank: Tank | undefined): void {
|
||||
if (this.mode === 'follow' && tank !== undefined && tank.root.visible) {
|
||||
const at = tank.root.position;
|
||||
if (!this.following) {
|
||||
this.controls.target.copy(at);
|
||||
this.persp.position.set(at.x - 25, at.y + 15, at.z + 25);
|
||||
this.following = true;
|
||||
} else {
|
||||
const d = at.clone().sub(this.lastFollow);
|
||||
this.controls.target.add(d);
|
||||
this.persp.position.add(d);
|
||||
}
|
||||
this.lastFollow.copy(at);
|
||||
} else if (this.mode === 'gun' && tank !== undefined && tank.root.visible) {
|
||||
const q = tank.barrel.getWorldQuaternion(new Quaternion());
|
||||
const dir = new Vector3(1, 0, 0).applyQuaternion(q);
|
||||
const tip = tank.barrel.getWorldPosition(new Vector3()).addScaledVector(dir, tank.length * 0.8);
|
||||
this.persp.position.copy(tip);
|
||||
this.persp.lookAt(tip.clone().add(dir));
|
||||
return;
|
||||
}
|
||||
if (this.controls.enabled) this.controls.update();
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.controls.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Game world to three.js: Dagor is left-handed with Y up, three.js right-handed, so world z is
|
||||
* mirrored (three z = -world z). A world heading (degrees of atan2(z, x)) then becomes the same
|
||||
* angle of rotation about three's +Y, and a model's local +X is its front, +Y up, -Z its left.
|
||||
*/
|
||||
import { Vector3 } from 'three';
|
||||
|
||||
export const DEG = Math.PI / 180;
|
||||
|
||||
export function toThree(x: number, y: number, z: number, out: Vector3 = new Vector3()): Vector3 {
|
||||
return out.set(x, y, -z);
|
||||
}
|
||||
|
||||
/** Three.js direction of a world heading and pitch, in degrees. */
|
||||
export function dirOf(yawDeg: number, pitchDeg: number, out: Vector3 = new Vector3()): Vector3 {
|
||||
const c = Math.cos(pitchDeg * DEG);
|
||||
return out.set(Math.cos(yawDeg * DEG) * c, Math.sin(pitchDeg * DEG), -Math.sin(yawDeg * DEG) * c);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* The static 3D map: lit terrain (coloured by height, or draped with the navigation mesh image),
|
||||
* the collision shapes of placed objects coloured by kind, and the water plane.
|
||||
*/
|
||||
import type { MapScene, SceneTerrain } from '@wto/ground-sim';
|
||||
import {
|
||||
BufferAttribute, BufferGeometry, CanvasTexture, Color, DoubleSide, Group, Mesh, MeshLambertMaterial,
|
||||
PlaneGeometry, SRGBColorSpace, type Material,
|
||||
} from 'three';
|
||||
import type { MapLayer } from '../mapLayer.ts';
|
||||
|
||||
/** Colour and opacity per SCENE_KIND_NAMES entry. */
|
||||
const KIND_LOOK: readonly (readonly [number, number])[] = [
|
||||
[0xb9b2a3, 1], [0x7d7a74, 1], [0x9a7b55, 1], [0xe09a4a, 0.4], [0x4f8a3c, 1], [0x6f8aa0, 1],
|
||||
];
|
||||
|
||||
const LOW = new Color(0x3c4a32);
|
||||
const HIGH = new Color(0x9b9171);
|
||||
|
||||
export interface MapMeshes {
|
||||
readonly group: Group;
|
||||
readonly terrain: Mesh<BufferGeometry, MeshLambertMaterial>;
|
||||
/** Objects per scene kind, to switch kinds on and off. */
|
||||
readonly kinds: Group[];
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
function terrainGeometry(t: SceneTerrain, nav: MapLayer | undefined): BufferGeometry {
|
||||
const n = t.cols * t.rows;
|
||||
const pos = new Float32Array(n * 3);
|
||||
const col = new Float32Array(n * 3);
|
||||
const uv = new Float32Array(n * 2);
|
||||
let lo = Infinity;
|
||||
let hi = -Infinity;
|
||||
for (const h of t.heights) { lo = Math.min(lo, h); hi = Math.max(hi, h); }
|
||||
const c = new Color();
|
||||
const navW = nav === undefined ? 1 : nav.canvas.width / nav.pxPerM;
|
||||
const navH = nav === undefined ? 1 : nav.canvas.height / nav.pxPerM;
|
||||
for (let r = 0; r < t.rows; r++) {
|
||||
for (let k = 0; k < t.cols; k++) {
|
||||
const i = r * t.cols + k;
|
||||
const x = t.origin[0] + k * t.cellM;
|
||||
const z = t.origin[1] + r * t.cellM;
|
||||
const h = t.heights[i] ?? 0;
|
||||
pos.set([x, h, -z], i * 3);
|
||||
c.lerpColors(LOW, HIGH, hi > lo ? (h - lo) / (hi - lo) : 0);
|
||||
col.set([c.r, c.g, c.b], i * 3);
|
||||
if (nav !== undefined) uv.set([(x - nav.x0) / navW, (z - (nav.z1 - navH)) / navH], i * 2);
|
||||
}
|
||||
}
|
||||
const idx = new Uint32Array((t.cols - 1) * (t.rows - 1) * 6);
|
||||
let at = 0;
|
||||
for (let r = 0; r + 1 < t.rows; r++) {
|
||||
for (let k = 0; k + 1 < t.cols; k++) {
|
||||
const i = r * t.cols + k;
|
||||
idx.set([i, i + 1, i + t.cols, i + 1, i + t.cols + 1, i + t.cols], at);
|
||||
at += 6;
|
||||
}
|
||||
}
|
||||
const g = new BufferGeometry();
|
||||
g.setAttribute('position', new BufferAttribute(pos, 3));
|
||||
g.setAttribute('color', new BufferAttribute(col, 3));
|
||||
g.setAttribute('uv', new BufferAttribute(uv, 2));
|
||||
g.setIndex(new BufferAttribute(idx, 1));
|
||||
g.computeVertexNormals();
|
||||
return g;
|
||||
}
|
||||
|
||||
/** Drapes the navigation image over the terrain, or goes back to height colours. */
|
||||
export function setTerrainImage(m: MapMeshes, nav: MapLayer | undefined): void {
|
||||
const mat = m.terrain.material;
|
||||
mat.map?.dispose();
|
||||
if (nav === undefined) {
|
||||
mat.map = null;
|
||||
mat.vertexColors = true;
|
||||
} else {
|
||||
const tex = new CanvasTexture(nav.canvas);
|
||||
tex.colorSpace = SRGBColorSpace;
|
||||
tex.anisotropy = 8;
|
||||
mat.map = tex;
|
||||
mat.vertexColors = false;
|
||||
}
|
||||
mat.needsUpdate = true;
|
||||
}
|
||||
|
||||
function objectKinds(scene: MapScene, materials: Material[]): Group[] {
|
||||
const kinds = KIND_LOOK.map(() => new Group());
|
||||
const mats = KIND_LOOK.map(([color, opacity]) => new MeshLambertMaterial({
|
||||
color, flatShading: true, side: DoubleSide, transparent: opacity < 1, opacity, depthWrite: opacity >= 1,
|
||||
}));
|
||||
materials.push(...mats);
|
||||
for (const m of scene.meshes) {
|
||||
const g = new BufferGeometry();
|
||||
const pos = new Float32Array(m.positions);
|
||||
for (let i = 2; i < pos.length; i += 3) pos[i] = -(pos[i] ?? 0);
|
||||
g.setAttribute('position', new BufferAttribute(pos, 3));
|
||||
g.setIndex(new BufferAttribute(m.indices, 1));
|
||||
g.computeBoundingSphere();
|
||||
const mat = mats[m.kind] ?? mats[0];
|
||||
if (mat !== undefined) kinds[m.kind]?.add(new Mesh(g, mat));
|
||||
}
|
||||
return kinds;
|
||||
}
|
||||
|
||||
export function buildMapMeshes(scene: MapScene, nav: MapLayer | undefined): MapMeshes {
|
||||
const group = new Group();
|
||||
const materials: Material[] = [];
|
||||
const terrainMat = new MeshLambertMaterial({ vertexColors: true });
|
||||
materials.push(terrainMat);
|
||||
const terrain = new Mesh(terrainGeometry(scene.terrain, nav), terrainMat);
|
||||
group.add(terrain);
|
||||
const kinds = objectKinds(scene, materials);
|
||||
for (const k of kinds) group.add(k);
|
||||
if (scene.waterLevel !== undefined) {
|
||||
const w = scene.boundsMax[0] - scene.boundsMin[0];
|
||||
const d = scene.boundsMax[1] - scene.boundsMin[1];
|
||||
const waterMat = new MeshLambertMaterial({ color: 0x2d5f8a, transparent: true, opacity: 0.55, depthWrite: false });
|
||||
materials.push(waterMat);
|
||||
const water = new Mesh(new PlaneGeometry(w, d), waterMat);
|
||||
water.rotation.x = -Math.PI / 2;
|
||||
water.position.set(scene.boundsMin[0] + w / 2, scene.waterLevel, -(scene.boundsMin[1] + d / 2));
|
||||
group.add(water);
|
||||
}
|
||||
const meshes: MapMeshes = {
|
||||
group, terrain, kinds,
|
||||
dispose() {
|
||||
group.traverse((o) => { if (o instanceof Mesh) (o.geometry as BufferGeometry).dispose(); });
|
||||
terrainMat.map?.dispose();
|
||||
for (const m of materials) m.dispose();
|
||||
},
|
||||
};
|
||||
if (nav !== undefined) setTerrainImage(meshes, nav);
|
||||
return meshes;
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* What is drawn over the map for one moment, rebuilt every update: goal, target and look lines,
|
||||
* the gun's view cone, recent shots and hits, deaths so far, and the capture zones.
|
||||
*/
|
||||
import type { TraceBattle } from '@wto/ground-sim';
|
||||
import {
|
||||
AdditiveBlending, BufferAttribute, BufferGeometry, Color, DoubleSide, Group, LineBasicMaterial,
|
||||
LineSegments, Mesh, MeshBasicMaterial, Points, PointsMaterial,
|
||||
} from 'three';
|
||||
import { eventsBetween, type SceneAt, type UnitAt } from '../frames.ts';
|
||||
import { DEG } from './coords.ts';
|
||||
import { ARMY_HEX, type TankPool } from './tanks.ts';
|
||||
|
||||
export interface Layers {
|
||||
readonly goals: boolean;
|
||||
readonly links: boolean;
|
||||
readonly cones: boolean;
|
||||
readonly labels: boolean;
|
||||
readonly events: boolean;
|
||||
}
|
||||
|
||||
const GUN_FOV_HALF_DEG = 30;
|
||||
const CONE_M = 120;
|
||||
const CONE_STEPS = 12;
|
||||
const EVENT_WINDOW_SEC = 2;
|
||||
const CAP_STEPS = 64;
|
||||
const WISH_M = 25;
|
||||
|
||||
/** Line segments with per-vertex colour, refilled from scratch on every update. */
|
||||
class Lines {
|
||||
readonly obj: LineSegments;
|
||||
private pos: number[] = [];
|
||||
private col: number[] = [];
|
||||
|
||||
constructor(opacity: number, additive = false) {
|
||||
const mat = new LineBasicMaterial({ vertexColors: true, transparent: true, opacity, depthTest: !additive });
|
||||
if (additive) mat.blending = AdditiveBlending;
|
||||
this.obj = new LineSegments(new BufferGeometry(), mat);
|
||||
this.obj.frustumCulled = false;
|
||||
}
|
||||
|
||||
add(ax: number, ay: number, az: number, bx: number, by: number, bz: number, c: Color): void {
|
||||
this.pos.push(ax, ay, -az, bx, by, -bz);
|
||||
this.col.push(c.r, c.g, c.b, c.r, c.g, c.b);
|
||||
}
|
||||
|
||||
flush(): void {
|
||||
const g = this.obj.geometry;
|
||||
g.setAttribute('position', new BufferAttribute(Float32Array.from(this.pos), 3));
|
||||
g.setAttribute('color', new BufferAttribute(Float32Array.from(this.col), 3));
|
||||
g.computeBoundingSphere();
|
||||
this.pos = [];
|
||||
this.col = [];
|
||||
}
|
||||
}
|
||||
|
||||
const C = {
|
||||
goal: new Color(0x9aa4ad), target: new Color(0xff4646), targetLost: new Color(0x803030),
|
||||
look: new Color(0xffa028), wish: new Color(0xffe14a), shot: new Color(0xffff78), dead1: new Color(ARMY_HEX[1]),
|
||||
dead2: new Color(ARMY_HEX[2]), cap: new Color(0xdddddd),
|
||||
};
|
||||
|
||||
export class Overlays {
|
||||
readonly group = new Group();
|
||||
private readonly faint = new Lines(0.35);
|
||||
private readonly bold = new Lines(0.9);
|
||||
private readonly shots = new Lines(1, true);
|
||||
private readonly cones: Mesh;
|
||||
private readonly hits: Points;
|
||||
|
||||
constructor(private readonly tanks: TankPool) {
|
||||
this.cones = new Mesh(new BufferGeometry(), new MeshBasicMaterial({
|
||||
color: 0xffffc8, transparent: true, opacity: 0.08, side: DoubleSide, depthWrite: false,
|
||||
}));
|
||||
this.cones.frustumCulled = false;
|
||||
this.hits = new Points(new BufferGeometry(), new PointsMaterial({ size: 6, sizeAttenuation: false, vertexColors: true }));
|
||||
this.hits.frustumCulled = false;
|
||||
this.group.add(this.faint.obj, this.bold.obj, this.shots.obj, this.cones, this.hits);
|
||||
}
|
||||
|
||||
/** Height where lines leave a vehicle: its turret top. */
|
||||
private eye(u: UnitAt): number {
|
||||
return this.tanks.groundY(u.x, u.y, u.z) + (this.tanks.get(u.unit.eid)?.eyeY ?? 2);
|
||||
}
|
||||
|
||||
update(battle: TraceBattle, scene: SceneAt, layers: Layers): void {
|
||||
const cone: number[] = [];
|
||||
for (const u of scene.units.values()) this.botLines(u, scene, layers, cone);
|
||||
if (layers.events) this.events(battle, scene);
|
||||
this.deaths(battle, scene.t);
|
||||
this.caps(scene);
|
||||
const g = this.cones.geometry;
|
||||
g.setAttribute('position', new BufferAttribute(Float32Array.from(cone), 3));
|
||||
this.faint.flush();
|
||||
this.bold.flush();
|
||||
this.shots.flush();
|
||||
}
|
||||
|
||||
private botLines(u: UnitAt, scene: SceneAt, layers: Layers, cone: number[]): void {
|
||||
const bot = u.bot;
|
||||
if (bot === undefined || !u.unit.alive) return;
|
||||
const y = this.eye(u);
|
||||
if (layers.goals && bot.hasOrder) this.faint.add(u.x, y, u.z, bot.goalX, this.tanks.terrainY(bot.goalX, bot.goalZ) + 1, bot.goalZ, C.goal);
|
||||
const wy = bot.wishYaw * DEG;
|
||||
this.bold.add(u.x, y, u.z, u.x + Math.cos(wy) * WISH_M, y, u.z + Math.sin(wy) * WISH_M, C.wish);
|
||||
if (layers.cones) {
|
||||
for (let i = 0; i < CONE_STEPS; i++) {
|
||||
const a = (u.gunYaw - GUN_FOV_HALF_DEG + (2 * GUN_FOV_HALF_DEG * i) / CONE_STEPS) * DEG;
|
||||
const b = (u.gunYaw - GUN_FOV_HALF_DEG + (2 * GUN_FOV_HALF_DEG * (i + 1)) / CONE_STEPS) * DEG;
|
||||
cone.push(u.x, y, -u.z, u.x + Math.cos(a) * CONE_M, y, -(u.z + Math.sin(a) * CONE_M),
|
||||
u.x + Math.cos(b) * CONE_M, y, -(u.z + Math.sin(b) * CONE_M));
|
||||
}
|
||||
}
|
||||
if (!layers.links) return;
|
||||
const target = scene.units.get(bot.target);
|
||||
if (target !== undefined && bot.target !== '0') {
|
||||
(bot.targetInSight ? this.bold : this.faint).add(u.x, y, u.z, target.x, this.eye(target), target.z,
|
||||
bot.targetInSight ? C.target : C.targetLost);
|
||||
}
|
||||
const look = scene.units.get(bot.lookAt);
|
||||
if (look !== undefined && bot.lookAt !== bot.target) this.bold.add(u.x, y, u.z, look.x, this.eye(look), look.z, C.look);
|
||||
}
|
||||
|
||||
private events(battle: TraceBattle, scene: SceneAt): void {
|
||||
const pos: number[] = [];
|
||||
const col: number[] = [];
|
||||
const c = new Color();
|
||||
for (const e of eventsBetween(battle, scene.t - EVENT_WINDOW_SEC, scene.t)) {
|
||||
const fade = 1 - (scene.t - e.t) / EVENT_WINDOW_SEC;
|
||||
if (e.kind === 'SHOT' && e.eid !== undefined) {
|
||||
const from = scene.units.get(e.eid);
|
||||
const to = scene.units.get(e.fields['tgt'] ?? '');
|
||||
if (from === undefined || to === undefined) continue;
|
||||
this.shots.add(from.x, this.eye(from), from.z, to.x, this.eye(to) - 1, to.z, c.copy(C.shot).multiplyScalar(fade));
|
||||
} else if (e.kind === 'HIT') {
|
||||
const x = Number(e.fields['x']);
|
||||
const z = Number(e.fields['z']);
|
||||
pos.push(x, this.tanks.terrainY(x, z) + 1.5, -z);
|
||||
c.set(e.fields['drop'] === '1' ? 0xff3c3c : 0xc8c8c8).multiplyScalar(fade);
|
||||
col.push(c.r, c.g, c.b);
|
||||
}
|
||||
}
|
||||
this.hits.geometry.setAttribute('position', new BufferAttribute(Float32Array.from(pos), 3));
|
||||
this.hits.geometry.setAttribute('color', new BufferAttribute(Float32Array.from(col), 3));
|
||||
}
|
||||
|
||||
private deaths(battle: TraceBattle, t: number): void {
|
||||
for (const e of eventsBetween(battle, battle.startT, t)) {
|
||||
if (e.kind !== 'DEATH') continue;
|
||||
const x = Number(e.fields['x']);
|
||||
const z = Number(e.fields['z']);
|
||||
const y = this.tanks.terrainY(x, z) + 0.5;
|
||||
const c = e.fields['army'] === '1' ? C.dead1 : C.dead2;
|
||||
this.faint.add(x - 4, y, z - 4, x + 4, y, z + 4, c);
|
||||
this.faint.add(x - 4, y, z + 4, x + 4, y, z - 4, c);
|
||||
}
|
||||
}
|
||||
|
||||
private caps(scene: SceneAt): void {
|
||||
for (const cap of scene.caps) {
|
||||
const c = new Color(ARMY_HEX[cap.owner] ?? C.cap.getHex());
|
||||
for (let i = 0; i < CAP_STEPS; i++) {
|
||||
const a = (i / CAP_STEPS) * Math.PI * 2;
|
||||
const b = ((i + 1) / CAP_STEPS) * Math.PI * 2;
|
||||
const ax = cap.x + Math.cos(a) * cap.r;
|
||||
const az = cap.z + Math.sin(a) * cap.r;
|
||||
const bx = cap.x + Math.cos(b) * cap.r;
|
||||
const bz = cap.z + Math.sin(b) * cap.r;
|
||||
this.bold.add(ax, this.tanks.terrainY(ax, az) + 0.8, az, bx, this.tanks.terrainY(bx, bz) + 0.8, bz, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.group.traverse((o) => {
|
||||
if (o instanceof Mesh || o instanceof LineSegments || o instanceof Points) {
|
||||
o.geometry.dispose();
|
||||
(o.material as { dispose(): void }).dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* Every vehicle as simple shapes: a hull box tilted by the hull's pitch and roll, a turret box
|
||||
* turned to the gun's heading, and a barrel at the gun's pitch. Sizes come from the bot's vehicle
|
||||
* class (players: light or medium).
|
||||
*/
|
||||
import { sceneHeightAt, type SceneTerrain } from '@wto/ground-sim';
|
||||
import {
|
||||
BoxGeometry, Color, CylinderGeometry, Group, Mesh, MeshLambertMaterial, type Object3D,
|
||||
} from 'three';
|
||||
import { CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js';
|
||||
import type { UnitAt } from '../frames.ts';
|
||||
import { DEG } from './coords.ts';
|
||||
|
||||
/** Length, width, hull height per vehicle class (medium, light, heavy, tank destroyer, SPAA). */
|
||||
const SIZES: readonly (readonly [number, number, number])[] = [
|
||||
[7, 3.4, 1.3], [6, 3, 1.1], [7.6, 3.6, 1.4], [7, 3.3, 1.2], [6.5, 3.1, 1.2],
|
||||
];
|
||||
|
||||
export const ARMY_HEX: Readonly<Record<number, number>> = { 1: 0x4aa3ff, 2: 0xff5c5c };
|
||||
const DEAD = new Color(0x4a4a4a);
|
||||
const SELECTED = new Color(0x6a5200);
|
||||
const NONE = new Color(0);
|
||||
|
||||
/** A trace height further than this from the terrain is kept (bridge, building, platform). */
|
||||
const OFF_GROUND_M = 1.5;
|
||||
|
||||
export interface Tank {
|
||||
readonly root: Group;
|
||||
readonly turret: Group;
|
||||
readonly barrel: Group;
|
||||
readonly label: CSS2DObject;
|
||||
readonly mats: MeshLambertMaterial[];
|
||||
/** Turret top above the hull origin, where lines and the gun camera start. */
|
||||
readonly eyeY: number;
|
||||
readonly length: number;
|
||||
}
|
||||
|
||||
function sizeOf(u: UnitAt): readonly [number, number, number] {
|
||||
const cls = u.bot?.vehicleClass ?? (u.unit.light ? 1 : 0);
|
||||
return SIZES[cls] ?? SIZES[0] ?? [7, 3.4, 1.3];
|
||||
}
|
||||
|
||||
function makeTank(u: UnitAt): Tank {
|
||||
const [len, wid, hh] = sizeOf(u);
|
||||
const hullMat = new MeshLambertMaterial();
|
||||
const turretMat = new MeshLambertMaterial();
|
||||
const root = new Group();
|
||||
root.rotation.order = 'YZX';
|
||||
const hull = new Mesh(new BoxGeometry(len, hh, wid), hullMat);
|
||||
hull.position.y = hh / 2;
|
||||
const turret = new Group();
|
||||
turret.position.set(-len * 0.05, hh, 0);
|
||||
const tw = wid * 0.7;
|
||||
const th = hh * 0.65;
|
||||
const turretBox = new Mesh(new BoxGeometry(len * 0.48, th, tw), turretMat);
|
||||
turretBox.position.y = th / 2;
|
||||
const barrel = new Group();
|
||||
barrel.position.set(len * 0.2, th * 0.55, 0);
|
||||
const tube = new Mesh(new CylinderGeometry(0.09, 0.11, len * 0.75, 8), turretMat);
|
||||
tube.rotation.z = -Math.PI / 2;
|
||||
tube.position.x = len * 0.375;
|
||||
barrel.add(tube);
|
||||
turret.add(turretBox, barrel);
|
||||
root.add(hull, turret);
|
||||
const div = document.createElement('div');
|
||||
div.className = 'tank-label';
|
||||
const label = new CSS2DObject(div);
|
||||
label.position.y = hh + th + 2.5;
|
||||
root.add(label);
|
||||
for (const m of [hull, turretBox, tube]) m.userData['eid'] = u.unit.eid;
|
||||
return { root, turret, barrel, label, mats: [hullMat, turretMat], eyeY: hh + th, length: len };
|
||||
}
|
||||
|
||||
export class TankPool {
|
||||
readonly group = new Group();
|
||||
private readonly tanks = new Map<string, Tank>();
|
||||
|
||||
constructor(private readonly terrain: SceneTerrain | undefined) {}
|
||||
|
||||
get(eid: string): Tank | undefined {
|
||||
return this.tanks.get(eid);
|
||||
}
|
||||
|
||||
/** Meshes to pick with a ray. */
|
||||
pickables(): Object3D[] {
|
||||
const out: Object3D[] = [];
|
||||
for (const t of this.tanks.values()) if (t.root.visible) t.root.traverse((o) => { if (o instanceof Mesh) out.push(o); });
|
||||
return out;
|
||||
}
|
||||
|
||||
terrainY(x: number, z: number): number {
|
||||
return this.terrain === undefined ? 0 : sceneHeightAt(this.terrain, x, z);
|
||||
}
|
||||
|
||||
/** Ground height for the vehicle: the terrain unless the trace puts it clearly above or below. */
|
||||
groundY(x: number, y: number, z: number): number {
|
||||
if (this.terrain === undefined) return y;
|
||||
const g = sceneHeightAt(this.terrain, x, z);
|
||||
return Math.abs(y - g) <= OFF_GROUND_M ? g : y;
|
||||
}
|
||||
|
||||
update(units: ReadonlyMap<string, UnitAt>, selected: string | undefined, labels: (u: UnitAt) => string | undefined): void {
|
||||
for (const [eid, t] of this.tanks) if (!units.has(eid)) t.root.visible = false;
|
||||
for (const u of units.values()) {
|
||||
let t = this.tanks.get(u.unit.eid);
|
||||
if (t === undefined) {
|
||||
t = makeTank(u);
|
||||
this.tanks.set(u.unit.eid, t);
|
||||
this.group.add(t.root);
|
||||
}
|
||||
this.place(t, u, u.unit.eid === selected, labels(u));
|
||||
}
|
||||
}
|
||||
|
||||
private place(t: Tank, u: UnitAt, selected: boolean, label: string | undefined): void {
|
||||
t.root.visible = true;
|
||||
t.root.position.set(u.x, this.groundY(u.x, u.y, u.z), -u.z);
|
||||
t.root.rotation.set(u.hullRoll * DEG, u.yaw * DEG, u.hullPitch * DEG);
|
||||
const rel = ((((u.gunYaw - u.yaw) % 360) + 540) % 360) - 180;
|
||||
t.turret.rotation.y = rel * DEG;
|
||||
const hullSlope = u.hullPitch * Math.cos(rel * DEG) + u.hullRoll * Math.sin(rel * DEG);
|
||||
t.barrel.rotation.z = (u.gunPitch - hullSlope) * DEG;
|
||||
const base = u.unit.alive ? new Color(ARMY_HEX[u.unit.army] ?? 0xcccccc) : DEAD;
|
||||
t.mats.forEach((m, i) => {
|
||||
m.color.copy(base).multiplyScalar(i === 0 ? 1 : 0.8);
|
||||
m.emissive.copy(selected ? SELECTED : NONE);
|
||||
});
|
||||
t.label.visible = label !== undefined;
|
||||
if (label !== undefined) t.label.element.textContent = label;
|
||||
if (u.unit.human) t.label.element.classList.add('human');
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
for (const t of this.tanks.values()) {
|
||||
t.root.traverse((o) => { if (o instanceof Mesh) o.geometry.dispose(); });
|
||||
for (const m of t.mats) m.dispose();
|
||||
t.label.element.remove();
|
||||
}
|
||||
this.tanks.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
// The lab is a Vite page plus its dev-server API (server/), so it has its own settings and stays
|
||||
// out of the root typecheck, like the launcher.
|
||||
"compilerOptions": {
|
||||
"target": "ES2023",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
||||
"types": ["node"],
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
"exactOptionalPropertyTypes": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"useDefineForClassFields": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "server/**/*.ts", "vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { defineConfig } from 'vite';
|
||||
import { labApi } from './server/lab-api.ts';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), labApi()],
|
||||
server: { host: '127.0.0.1', port: 47180, strictPort: false },
|
||||
});
|
||||
@@ -562,12 +562,17 @@
|
||||
"loadout": "Ground AI spawn ammunition",
|
||||
"commander": "Commander & role quotas",
|
||||
"macro": "Macro capture & SPAA",
|
||||
"stateMachine": "Hull state machine & repair",
|
||||
"stateMachine": "Hull actions & repair",
|
||||
"perception": "Visual perception & exposure",
|
||||
"tactics": "Situational awareness & memory",
|
||||
"estimation": "Lead estimation & aim bias",
|
||||
"threat": "Threat assessment",
|
||||
"turret": "Turret attention",
|
||||
"behavior": "Hull behavior",
|
||||
"fireControl": "Fire control & fire gate",
|
||||
"navigation": "Driving & navigation",
|
||||
"navEngine": "Map navigation mesh & path costs",
|
||||
"pathFollow": "Path following & unstick",
|
||||
"crowd": "Spacing & crowd dispersal",
|
||||
"terrain": "Terrain & ridge limits",
|
||||
"runtime": "Tick cadence & diagnostics"
|
||||
@@ -578,12 +583,17 @@
|
||||
"loadout": "Ready-rack carry count and primary/secondary shell split",
|
||||
"commander": "Role percentages by game mode, flank lanes, rally and recall",
|
||||
"macro": "Opening split, cap occupancy, death zones and SPAA positioning",
|
||||
"stateMachine": "Short halts, reload cover retreat, angling, repositioning and repair",
|
||||
"stateMachine": "Short halts, reload cover retreat, repositioning and repair",
|
||||
"perception": "Foliage transparency, exposure accumulation and decay",
|
||||
"tactics": "Vision range, audio detection, radio sharing and target memory",
|
||||
"estimation": "Sample-based velocity lead, exit watch and natural shot spread",
|
||||
"fireControl": "Range bands, speed gates, barrel settle and ballistic safety",
|
||||
"navigation": "Drive backend, corner braking, pivot turns and unstick reverse",
|
||||
"threat": "How dangerous each discovered enemy is: distance, aim, line of sight and recent hits",
|
||||
"turret": "Where the turret looks without a target: threats, cues and scanning along the route",
|
||||
"behavior": "Scores of the hull behaviors, commitment, facing the main threat and driving backwards",
|
||||
"fireControl": "Hit probability and fire threshold, autocannon bursts, secondary weapons, barrel settle and ballistic safety",
|
||||
"navigation": "Drive backend, pivot turns and tactical reverse",
|
||||
"navEngine": "Baked map navigation packs, their fallback, and path costs per surface for tracked and wheeled vehicles",
|
||||
"pathFollow": "Replanning, lookahead steering, corner and arrival braking, narrow passages, bumper rays, passing stopped vehicles and wrecks, giving way, three-level unstick and temporary path costs",
|
||||
"crowd": "Personal space and ally cluster dispersal",
|
||||
"terrain": "Climb/drop slope limits, water depth and ridge peek caps",
|
||||
"runtime": "Script update intervals and telemetry logging"
|
||||
@@ -642,17 +652,12 @@
|
||||
"enemySpawnAvoidM": "Enemy spawn avoidance distance"
|
||||
},
|
||||
"stateMachine": {
|
||||
"preaimAngleDeg": "Moving pre-aim angle threshold",
|
||||
"movingShotWaitSec": "Time to attempt a moving shot before halting",
|
||||
"shortHaltMaxSec": "Short halt max duration",
|
||||
"shortHaltCooldownSec": "Short halt cooldown",
|
||||
"turnLaunchSpeedMps": "Turn launch target speed",
|
||||
"coverMinDistM": "Cover search min distance",
|
||||
"coverMaxDistM": "Cover search max distance",
|
||||
"coverRetreatBudgetSec": "Reload cover retreat max duration",
|
||||
"reloadAdvanceAngleDeg": "Reload zigzag advance angle",
|
||||
"hullAngleTriggerDeg": "Hull angling trigger angle",
|
||||
"hullAngleTargetDeg": "Target hull angling offset",
|
||||
"maxTotalHaltSec": "Max cumulative halt before reposition",
|
||||
"stalemateMissShots": "Ineffective shots before reposition",
|
||||
"stalemateNoShotHalts": "No-shot halts before reposition",
|
||||
@@ -668,13 +673,18 @@
|
||||
"normalSpotSec": "Normal exposure spot time",
|
||||
"farSpotSec": "Long-range exposure spot time",
|
||||
"decayPerSec": "Exposure decay rate per second",
|
||||
"frontConeHalfDeg": "Forward vision cone half-angle",
|
||||
"peripheralCloseM": "Close peripheral spot distance"
|
||||
"gunFovHalfDeg": "Gun sight half-angle",
|
||||
"nearAwareM": "Close all-round awareness range",
|
||||
"nearArcDeg": "Close awareness arc around the barrel",
|
||||
"midAwareM": "Medium awareness range (barrel front hemisphere)",
|
||||
"nearSpotMul": "Close awareness spotting time multiplier",
|
||||
"midSpotMul": "Commander awareness spotting time multiplier",
|
||||
"lookAroundSec": "Look-around interval",
|
||||
"lookAroundHoldSec": "Look-around duration",
|
||||
"discoverScore": "Exposure at which an enemy counts as discovered"
|
||||
},
|
||||
"tactics": {
|
||||
"visionRangeM": "Max visual detection range",
|
||||
"visionFovDeg": "Vision field of view",
|
||||
"peripheralRangeM": "Peripheral detection range",
|
||||
"engineAudioRangeM": "Engine audio hearing range",
|
||||
"shotAudioRangeM": "Gunshot audio hearing range",
|
||||
"radioShareRangeM": "Allied radio sharing range",
|
||||
@@ -692,24 +702,95 @@
|
||||
"leadErrorFrac": "Lead estimation error fraction",
|
||||
"maxBiasM": "Max per-opportunity aim bias"
|
||||
},
|
||||
"threat": {
|
||||
"rangeScaleM": "Distance at which danger halves",
|
||||
"discoveredMul": "Danger multiplier until seen clearly",
|
||||
"aimConeDeg": "Cone in which an enemy counts as aiming at the bot",
|
||||
"notAimingMul": "Danger multiplier when not aiming at the bot",
|
||||
"unseenMul": "Danger multiplier when the bot is out of its sight",
|
||||
"hitMemorySec": "How long a hit raises the shooter's danger",
|
||||
"hitMul": "Danger multiplier after a hit"
|
||||
},
|
||||
"turret": {
|
||||
"minDwellSec": "Minimum time on a chosen look direction",
|
||||
"switchMargin": "Extra danger needed to turn from the engaged target",
|
||||
"scanArcDeg": "Scan arc either side of the route",
|
||||
"scanPeriodSec": "Scan sweep period",
|
||||
"fixedMountYawSpanDeg": "Max yaw range for hull-mounted guns"
|
||||
},
|
||||
"behavior": {
|
||||
"scoreIntervalSec": "Behavior scoring interval",
|
||||
"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",
|
||||
"urgencyWeight": "Score shift by order urgency",
|
||||
"haltScore": "Score: short halt for a shot",
|
||||
"crossfirePenalty": "Short-halt penalty per extra enemy aiming at the bot",
|
||||
"coverScore": "Score: pull back to cover to reload",
|
||||
"coverDangerWeight": "Cover score added by threat danger",
|
||||
"coverOffensivePenalty": "Cover penalty on an urgent attack",
|
||||
"coverRetrySec": "Wait before searching for cover again after none was found",
|
||||
"repositionScore": "Score: change firing position when the engagement is stuck",
|
||||
"holdScore": "Score: hold the post, watch the last exit or wait at the rally point",
|
||||
"disperseScore": "Score: spread out of a crowd",
|
||||
"urgentSpeedKeep": "Share of march speed an urgent bot keeps when slowing for a shot",
|
||||
"hullAngleDeg": "Hull angle to the main threat",
|
||||
"faceToleranceDeg": "Facing tolerance while standing",
|
||||
"faceMinDanger": "Threat danger needed to face it",
|
||||
"reverseTravelAngleDeg": "Threat angle off the travel direction for driving backwards",
|
||||
"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"
|
||||
},
|
||||
"fireControl": {
|
||||
"maxEngageRangeM": "Max engagement range",
|
||||
"closeRangeM": "Close range band threshold",
|
||||
"midRangeM": "Mid range band threshold",
|
||||
"longRangeM": "Long range band threshold",
|
||||
"midSlowSpeedRatio": "Mid-range fire-on-move speed ratio",
|
||||
"midSlowMaxMps": "Mid-range fire-on-move speed cap",
|
||||
"closeRangeMaxSpeedKmh": "Moving-fire speed cap at the close-range boundary",
|
||||
"pointBlankMaxSpeedKmh": "Moving-fire speed cap at point blank",
|
||||
"stopSpeedMaxMps": "Stopped speed threshold",
|
||||
"longRangeWindowSec": "Long-range clear LOS window",
|
||||
"baseAlignDeg": "Base gun alignment tolerance",
|
||||
"closeHitRadiusM": "Close-range hit acceptance radius",
|
||||
"barrelSettleDegSec": "Max aim error drift outside close range",
|
||||
"closeSettleHoldSec": "Close-range settle hold time",
|
||||
"settleHoldSec": "Standard settle hold time",
|
||||
"unstabilizedStopSpeedMps": "Unstabilized stop speed cap",
|
||||
"stabilizedCreepSpeedMps": "Stabilized creep fire speed cap",
|
||||
"aimErrorDeg": "Crew aim error (spread)",
|
||||
"moveErrDegPerMps": "Aim error per m/s of own speed",
|
||||
"turnErrDegPerDegSec": "Aim error per deg/s of hull turn",
|
||||
"stabErrFactor": "Motion error factor with a stabilizer",
|
||||
"targetHalfHeightM": "Half height of a fully visible target",
|
||||
"fireThreshold": "Base hit probability needed to fire",
|
||||
"minFireThreshold": "Lowest fire threshold",
|
||||
"aimingThresholdBonus": "Threshold drop when the target aims at the bot",
|
||||
"closeThresholdBonus": "Threshold drop at point blank",
|
||||
"enemyReloadThresholdBonus": "Threshold drop after the target fired",
|
||||
"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",
|
||||
"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",
|
||||
"autocannonReloadDetectSec": "Autocannon not-ready time that counts as a reload",
|
||||
"auxWeapons": "Fire secondary and coaxial weapons",
|
||||
"auxMaxRangeM": "Secondary and coaxial weapon range",
|
||||
"auxFireAtArmor": "Coaxial weapons also fire at non-light vehicles",
|
||||
"friendlyCorridorM": "Friendly fire corridor width",
|
||||
"ballisticStepMaxM": "Ballistic occlusion step length",
|
||||
"ballisticSweepRadiusM": "Ballistic sphere sweep radius",
|
||||
@@ -721,15 +802,89 @@
|
||||
"steerSign": "Steering input polarity",
|
||||
"deadEchoSec": "Dead-echo detection timeout",
|
||||
"controlTimeoutSec": "Native control release timeout",
|
||||
"cornerBrakeAccel": "Corner braking deceleration",
|
||||
"movingFireSpeedRampMps": "Speed error for full throttle or braking while firing on the move",
|
||||
"pivotAngleDeg": "Neutral pivot turn angle threshold",
|
||||
"stuckWindowSec": "Stuck detection window",
|
||||
"stuckMinMoveM": "Stuck min movement distance",
|
||||
"unstickReverseSec": "Unstick reverse duration",
|
||||
"tacticalReverseDistM": "Tactical reverse max distance",
|
||||
"tacticalReverseMaxSec": "Tactical reverse max duration"
|
||||
},
|
||||
"navEngine": {
|
||||
"enabled": "Use map navigation packs",
|
||||
"allowFallback": "Fall back to the old pathing for the battle when a pack is missing or broken",
|
||||
"snapRadiusM": "Max distance from a path's start or goal to the mesh",
|
||||
"goalSnapRadiusM": "Max distance a path goal may be moved onto the mesh",
|
||||
"pathBudgetMsPerFrame": "Path search time per frame",
|
||||
"trafficCostPerPath": "Team traffic · extra path cost per teammate route",
|
||||
"trafficCostMaxMul": "Team traffic · max path cost multiplier",
|
||||
"trafficHoldSec": "Team traffic · how long a planned route counts",
|
||||
"cornerOffsetM": "Distance path corners keep from the walls they turn around"
|
||||
},
|
||||
"navCostsTracked": {
|
||||
"road": "Tracked · road cost",
|
||||
"bridge": "Tracked · bridge cost",
|
||||
"ground": "Tracked · open ground cost",
|
||||
"rough": "Tracked · steep or rocky ground cost",
|
||||
"forest": "Tracked · forest cost",
|
||||
"crushable": "Tracked · crushable obstacle cost",
|
||||
"shallowWater": "Tracked · shallow water cost",
|
||||
"chokepoint": "Tracked · chokepoint multiplier"
|
||||
},
|
||||
"navCostsWheeled": {
|
||||
"road": "Wheeled · road cost",
|
||||
"bridge": "Wheeled · bridge cost",
|
||||
"ground": "Wheeled · open ground cost",
|
||||
"rough": "Wheeled · steep or rocky ground cost",
|
||||
"forest": "Wheeled · forest cost",
|
||||
"crushable": "Wheeled · crushable obstacle cost",
|
||||
"shallowWater": "Wheeled · shallow water cost",
|
||||
"chokepoint": "Wheeled · chokepoint multiplier"
|
||||
},
|
||||
"pathFollow": {
|
||||
"replanIntervalSec": "Regular path replanning interval",
|
||||
"replanGoalMoveM": "Goal movement that triggers a new path",
|
||||
"offCorridorReplanM": "Distance off the path that triggers a new path",
|
||||
"lookaheadTimeSec": "Lookahead time at current speed",
|
||||
"trackedLookaheadMinM": "Tracked · min lookahead distance",
|
||||
"trackedLookaheadMaxM": "Tracked · max lookahead distance",
|
||||
"wheeledLookaheadMinM": "Wheeled · min lookahead distance",
|
||||
"wheeledLookaheadMaxM": "Wheeled · max lookahead distance",
|
||||
"cornerAngleDeg": "Path corner angle that needs slowing down",
|
||||
"cornerLateralAccelMps2": "Allowed sideways acceleration in corners",
|
||||
"cornerBrakeDecelMps2": "Braking deceleration before corners and the destination",
|
||||
"arriveRadiusM": "Arrival radius at the destination",
|
||||
"arriveMinSpeedMps": "Min speed while approaching the destination",
|
||||
"narrowWallMarginM": "Room to the mesh edge below which a passage counts as narrow",
|
||||
"narrowSpeedMps": "Speed cap in narrow passages",
|
||||
"bumperRayM": "Front corner ray length",
|
||||
"bumperStopM": "Stop distance before an obstacle hit by the front rays",
|
||||
"bumperBlockSec": "Time blocked before an obstacle is reported",
|
||||
"trafficTtcSec": "Vehicle collision look-ahead time",
|
||||
"yieldWaitMaxSec": "Max wait while giving way in narrow passages",
|
||||
"stationarySpeedMps": "Speed below which a vehicle counts as an obstacle",
|
||||
"passMarginM": "Gap kept between hulls when passing",
|
||||
"passSpeedMps": "Speed cap while passing an obstacle",
|
||||
"blockWaitSec": "Wait before a blocked passage is marked and replanned",
|
||||
"blockTtlSec": "Blocked passage cost duration",
|
||||
"contactGapM": "Gap to an obstacle that counts as contact",
|
||||
"contactReverseSec": "Time in contact before backing off",
|
||||
"contactRepeatSec": "Window in which a second contact counts as a repeat",
|
||||
"stuckWindowSec": "Stuck detection window",
|
||||
"stuckMinProgressM": "Min progress within the stuck window",
|
||||
"unstickReverseM": "Unstick reverse distance",
|
||||
"unstickReverseSec": "Unstick reverse max duration",
|
||||
"unstickRepeatSec": "Time within which a repeated stuck escalates",
|
||||
"unstickMaxAttempts": "Unstick attempts before giving up the order",
|
||||
"jamRadiusM": "Jam cost radius",
|
||||
"jamCostMul": "Jam path cost multiplier",
|
||||
"jamTtlSec": "Jam cost duration",
|
||||
"giveUpRadiusM": "Given-up place cost radius",
|
||||
"giveUpCostMul": "Given-up place path cost multiplier",
|
||||
"rubbleRadiusM": "Fresh obstacle cost radius",
|
||||
"rubbleCostMul": "Fresh obstacle path cost multiplier",
|
||||
"rubbleTtlSec": "Fresh obstacle cost duration",
|
||||
"wreckRadiusM": "Wreck cost radius",
|
||||
"wreckCostMul": "Wreck path cost multiplier",
|
||||
"wreckTtlSec": "Wreck cost duration"
|
||||
},
|
||||
"crowd": {
|
||||
"personalSpaceM": "Personal spacing distance",
|
||||
"clusterRadiusM": "Ally cluster detection radius",
|
||||
@@ -754,7 +909,14 @@
|
||||
},
|
||||
"diagnostics": {
|
||||
"telemetry": "Enable AI telemetry logs",
|
||||
"telemetryIntervalSec": "Telemetry logging interval"
|
||||
"telemetryIntervalSec": "Telemetry logging interval",
|
||||
"battleStats": "Log battle statistics for comparing builds",
|
||||
"statsLogIntervalSec": "Battle statistics logging interval",
|
||||
"statsSampleSec": "Statistics sampling interval per bot",
|
||||
"statsSampleRangeM": "Range of the nearest-enemy statistics sample",
|
||||
"statsRearArcDeg": "Rear arc counted as showing the rear",
|
||||
"trace": "Log the AI replay trace",
|
||||
"traceIntervalSec": "AI replay trace sampling interval"
|
||||
}
|
||||
},
|
||||
"shared": "These settings apply to all saves in this client.",
|
||||
|
||||
@@ -562,12 +562,17 @@
|
||||
"loadout": "陆战 AI 出生携弹",
|
||||
"commander": "指挥层与分路配额",
|
||||
"macro": "宏观占点与防空",
|
||||
"stateMachine": "单车状态机与掩体维修",
|
||||
"stateMachine": "车体动作与掩体维修",
|
||||
"perception": "视觉感知与曝光",
|
||||
"tactics": "态势感知与目标记忆",
|
||||
"estimation": "目击测速与瞄准偏差",
|
||||
"threat": "威胁评估",
|
||||
"turret": "炮塔关注方向",
|
||||
"behavior": "车体行为",
|
||||
"fireControl": "火控与开火许可",
|
||||
"navigation": "机动与寻路控制",
|
||||
"navEngine": "地图导航网格与通行代价",
|
||||
"pathFollow": "跟路驾驶与脱困",
|
||||
"crowd": "编队间距与避让",
|
||||
"terrain": "地形与棱线约束",
|
||||
"runtime": "运行频率与诊断"
|
||||
@@ -578,12 +583,17 @@
|
||||
"loadout": "待发架携弹量与主/副弹种分配",
|
||||
"commander": "各模式进攻 / 侧翼 / 架枪比例、集结与回防",
|
||||
"macro": "开局分兵、占点人数、死亡区规避与防空站位",
|
||||
"stateMachine": "短停预算、装填回缩、摆角、换位与受损维修",
|
||||
"stateMachine": "短停预算、装填回缩、换位与受损维修",
|
||||
"perception": "植被透光、曝光累计速度与衰减",
|
||||
"tactics": "视距、听觉发现范围、电台共享与记忆时长",
|
||||
"estimation": "本车目击测速、守出口时长与自然散布",
|
||||
"fireControl": "距离分档、车速门槛、稳定等待与弹道防误伤",
|
||||
"navigation": "底层驱动方式、转向刹车与脱困倒车",
|
||||
"threat": "每个已发现敌人的危险程度:距离、是否瞄着本车、视线与最近是否命中本车",
|
||||
"turret": "没有目标时炮塔看哪里:威胁、线索与沿路线扫视",
|
||||
"behavior": "车体各行为的得分、承诺时间、车头对主威胁与倒车跟路",
|
||||
"fireControl": "命中概率与开火门槛、机炮点射、副武器、炮管稳定和弹道安全",
|
||||
"navigation": "驱动方式、原地转向与战术倒车",
|
||||
"navEngine": "离线地图导航包的启用与降级,以及履带 / 轮式车在各类地表上的寻路代价",
|
||||
"pathFollow": "重新寻路、前瞻跟路、弯道与到达前减速、窄路限速、车头射线、绕过停车和残骸、会车让路、三级脱困与临时寻路代价",
|
||||
"crowd": "友军安全间距与扎堆疏散",
|
||||
"terrain": "爬坡 / 下坡角度、涉水深度与探头限制",
|
||||
"runtime": "脚本刷新间隔与调试遥测日志"
|
||||
@@ -642,17 +652,12 @@
|
||||
"enemySpawnAvoidM": "敌方出生点规避距离"
|
||||
},
|
||||
"stateMachine": {
|
||||
"preaimAngleDeg": "行进预瞄角度阈值",
|
||||
"movingShotWaitSec": "转入短停前尝试行进射击的时间",
|
||||
"shortHaltMaxSec": "单次短停最长时间",
|
||||
"shortHaltCooldownSec": "短停冷却时间",
|
||||
"turnLaunchSpeedMps": "甩弯起步目标车速",
|
||||
"coverMinDistM": "掩体搜索最小距离",
|
||||
"coverMaxDistM": "掩体搜索最大距离",
|
||||
"coverRetreatBudgetSec": "装填回缩掩体最长用时",
|
||||
"reloadAdvanceAngleDeg": "装填折线跃进偏角",
|
||||
"hullAngleTriggerDeg": "触发车体摆角阈值",
|
||||
"hullAngleTargetDeg": "车体目标摆角",
|
||||
"maxTotalHaltSec": "累计停留强制换位上限",
|
||||
"stalemateMissShots": "无伤害连射触发换位发数",
|
||||
"stalemateNoShotHalts": "未开火短停触发换位次数",
|
||||
@@ -668,13 +673,18 @@
|
||||
"normalSpotSec": "常规曝光用时",
|
||||
"farSpotSec": "远距曝光用时",
|
||||
"decayPerSec": "失联曝光每秒衰减率",
|
||||
"frontConeHalfDeg": "前向主视锥半角",
|
||||
"peripheralCloseM": "近身余光发现距离"
|
||||
"gunFovHalfDeg": "瞄准镜视野半角",
|
||||
"nearAwareM": "近距环视感知距离",
|
||||
"nearArcDeg": "以炮口为基准的近距感知角度",
|
||||
"midAwareM": "中距感知距离(炮口前半球)",
|
||||
"nearSpotMul": "近距感知看清耗时倍数",
|
||||
"midSpotMul": "车长感知看清耗时倍数",
|
||||
"lookAroundSec": "环视间隔",
|
||||
"lookAroundHoldSec": "环视持续时间",
|
||||
"discoverScore": "曝光积分达到多少算发现"
|
||||
},
|
||||
"tactics": {
|
||||
"visionRangeM": "最大视觉索敌距离",
|
||||
"visionFovDeg": "视野总张角",
|
||||
"peripheralRangeM": "外围余光索敌距离",
|
||||
"engineAudioRangeM": "引擎声听觉距离",
|
||||
"shotAudioRangeM": "炮声听觉距离",
|
||||
"radioShareRangeM": "友军电台报点共享距离",
|
||||
@@ -692,24 +702,95 @@
|
||||
"leadErrorFrac": "提前量误差比例",
|
||||
"maxBiasM": "单次射击最大偏移上限"
|
||||
},
|
||||
"threat": {
|
||||
"rangeScaleM": "危险度减半的距离",
|
||||
"discoveredMul": "尚未看清时的危险度倍数",
|
||||
"aimConeDeg": "算作对方瞄着本车的夹角范围",
|
||||
"notAimingMul": "对方没瞄着本车时的危险度倍数",
|
||||
"unseenMul": "本车不在对方视线内时的危险度倍数",
|
||||
"hitMemorySec": "被命中后提高射手危险度的时长",
|
||||
"hitMul": "被命中后的危险度倍数"
|
||||
},
|
||||
"turret": {
|
||||
"minDwellSec": "选定的观察方向至少保持的时间",
|
||||
"switchMargin": "从交战目标转向其他威胁所需高出的危险度",
|
||||
"scanArcDeg": "沿路线向两侧扫视的角度",
|
||||
"scanPeriodSec": "扫视一个来回的时长",
|
||||
"fixedMountYawSpanDeg": "判定为固定炮座时的最大水平射界"
|
||||
},
|
||||
"behavior": {
|
||||
"scoreIntervalSec": "行为打分间隔",
|
||||
"advanceHoldSec": "推进承诺时间",
|
||||
"engageHoldSec": "交战推进承诺时间",
|
||||
"haltHoldSec": "短停射击承诺时间",
|
||||
"coverHoldSec": "退入掩体承诺时间",
|
||||
"repositionHoldSec": "换位承诺时间",
|
||||
"postHoldSec": "守位承诺时间",
|
||||
"disperseHoldSec": "疏散承诺时间",
|
||||
"targetValueWeight": "运动中有机会命中的权重",
|
||||
"nearThreatHaltBonus": "近距威胁下的短停加分",
|
||||
"switchMargin": "切换行为所需高出的分数",
|
||||
"advanceScore": "得分:沿任务路线推进",
|
||||
"engageScore": "得分:交战推进",
|
||||
"urgencyWeight": "任务紧迫度对得分的影响",
|
||||
"haltScore": "得分:短停射击",
|
||||
"crossfirePenalty": "每多一个瞄着本车的敌人,短停扣分",
|
||||
"coverScore": "得分:退入掩体装填",
|
||||
"coverDangerWeight": "威胁危险度对掩体得分的加成",
|
||||
"coverOffensivePenalty": "紧急进攻时掩体扣分",
|
||||
"coverRetrySec": "找不到掩体后再次搜索的间隔",
|
||||
"repositionScore": "得分:交战僵持时换位",
|
||||
"holdScore": "得分:守位、盯出口或在集结点等待",
|
||||
"disperseScore": "得分:拥挤疏散",
|
||||
"urgentSpeedKeep": "紧急任务为射击减速时保留的行军速度比例",
|
||||
"hullAngleDeg": "车头对主威胁的倾角",
|
||||
"faceToleranceDeg": "停车时朝向容差",
|
||||
"faceMinDanger": "需要车头对准的威胁危险度下限",
|
||||
"reverseTravelAngleDeg": "威胁偏离行进方向多少度时倒车跟路",
|
||||
"reverseMaxTurnDistM": "倒车时距下一拐点或路线终点的最远距离",
|
||||
"reverseMinSpeedMps": "倒车跟路所需的最低倒车极速",
|
||||
"reverseHoldSec": "前进与倒车切换的最短间隔"
|
||||
},
|
||||
"fireControl": {
|
||||
"maxEngageRangeM": "最大交战开火距离",
|
||||
"closeRangeM": "近距交战分界距离",
|
||||
"midRangeM": "中距交战分界距离",
|
||||
"longRangeM": "远距交战分界距离",
|
||||
"midSlowSpeedRatio": "中距行进射击最高车速比",
|
||||
"midSlowMaxMps": "中距行进射击最高车速",
|
||||
"closeRangeMaxSpeedKmh": "近距分界处行进射击最高车速",
|
||||
"pointBlankMaxSpeedKmh": "贴身时行进射击最高车速",
|
||||
"stopSpeedMaxMps": "停稳判定最高车速",
|
||||
"longRangeWindowSec": "远距连续射界观察窗",
|
||||
"baseAlignDeg": "主炮对准允许角误差",
|
||||
"closeHitRadiusM": "近距命中判定半径",
|
||||
"barrelSettleDegSec": "近距以外瞄准误差最大变化速度",
|
||||
"closeSettleHoldSec": "近距稳定保持时间",
|
||||
"settleHoldSec": "常规稳定保持时间",
|
||||
"unstabilizedStopSpeedMps": "无稳定器停稳车速上限",
|
||||
"stabilizedCreepSpeedMps": "带稳定器慢速射击上限",
|
||||
"aimErrorDeg": "炮手瞄准误差(散布)",
|
||||
"moveErrDegPerMps": "本车每 m/s 车速增加的瞄准误差",
|
||||
"turnErrDegPerDegSec": "车体每 °/s 转向增加的瞄准误差",
|
||||
"stabErrFactor": "有稳定器时行进误差的倍数",
|
||||
"targetHalfHeightM": "完全露出的目标半高",
|
||||
"fireThreshold": "开火所需的基础命中概率",
|
||||
"minFireThreshold": "开火门槛下限",
|
||||
"aimingThresholdBonus": "目标瞄着本车时门槛降低",
|
||||
"closeThresholdBonus": "贴脸时门槛降低(近距内按距离过渡)",
|
||||
"enemyReloadThresholdBonus": "目标刚开过火时门槛降低",
|
||||
"enemyReloadSec": "目标开火后视为装填中的时长",
|
||||
"fleetingThresholdBonus": "目标即将离开视线时门槛降低",
|
||||
"fleetingLateralMps": "视为即将离开视线的横穿速度",
|
||||
"fleetingLookAheadSec": "预判视线遮挡的时间",
|
||||
"reloadThresholdPenalty": "装填时间长时提高开火门槛",
|
||||
"longReloadSec": "开火门槛加满时的装填时间",
|
||||
"lowAmmoRounds": "开始节省弹药的剩余发数",
|
||||
"lowAmmoThresholdPenalty": "剩余弹药少时提高开火门槛",
|
||||
"aimSkill": "影响瞄点散布的炮手技能",
|
||||
"autocannonMinShotsPerSec": "识别机炮的最低射速(发/秒)",
|
||||
"retreatThresholdPenalty": "退入掩体途中的门槛升高",
|
||||
"minShotIntervalSec": "主炮最短开火间隔",
|
||||
"autocannonAimSlack": "机炮放宽倍数(目标尺寸的倍数)",
|
||||
"burstSec": "点射时长",
|
||||
"burstPauseSec": "点射间隔",
|
||||
"autocannonReloadDetectSec": "机炮持续未就绪多久算换弹",
|
||||
"auxWeapons": "使用副炮和并列武器",
|
||||
"auxMaxRangeM": "副炮和并列武器的射击距离",
|
||||
"auxFireAtArmor": "并列武器也可以向非轻型车辆开火",
|
||||
"friendlyCorridorM": "友军弹道禁射走廊宽度",
|
||||
"ballisticStepMaxM": "弹道硬遮挡检测步长",
|
||||
"ballisticSweepRadiusM": "弹道扫掠半径",
|
||||
@@ -721,15 +802,89 @@
|
||||
"steerSign": "转向输入方向",
|
||||
"deadEchoSec": "无响应回声判定时长",
|
||||
"controlTimeoutSec": "原生控制超时归还时长",
|
||||
"cornerBrakeAccel": "弯道减速制动强度",
|
||||
"movingFireSpeedRampMps": "行进射击时全油门或全制动对应的速度差",
|
||||
"pivotAngleDeg": "原地中性转向角度阈值",
|
||||
"stuckWindowSec": "卡死检测窗口时长",
|
||||
"stuckMinMoveM": "卡死判定最小位移",
|
||||
"unstickReverseSec": "脱困倒车持续时长",
|
||||
"tacticalReverseDistM": "战术倒车最大距离",
|
||||
"tacticalReverseMaxSec": "战术倒车最长时长"
|
||||
},
|
||||
"navEngine": {
|
||||
"enabled": "启用地图导航包",
|
||||
"allowFallback": "缺少或损坏时整局退回旧寻路",
|
||||
"snapRadiusM": "起终点吸附到导航网格的最大距离",
|
||||
"goalSnapRadiusM": "目标点吸附到导航网格的最远距离",
|
||||
"pathBudgetMsPerFrame": "每帧寻路计算时间上限",
|
||||
"trafficCostPerPath": "同队分流 · 每条队友路线增加的寻路代价",
|
||||
"trafficCostMaxMul": "同队分流 · 寻路代价最高倍率",
|
||||
"trafficHoldSec": "同队分流 · 规划出的路线计入多久",
|
||||
"cornerOffsetM": "路线拐点离所绕墙角的距离"
|
||||
},
|
||||
"navCostsTracked": {
|
||||
"road": "履带车 · 道路代价",
|
||||
"bridge": "履带车 · 桥面代价",
|
||||
"ground": "履带车 · 普通地面代价",
|
||||
"rough": "履带车 · 陡坡碎石代价",
|
||||
"forest": "履带车 · 树林代价",
|
||||
"crushable": "履带车 · 可碾压障碍代价",
|
||||
"shallowWater": "履带车 · 浅滩涉水代价",
|
||||
"chokepoint": "履带车 · 窄口代价倍率"
|
||||
},
|
||||
"navCostsWheeled": {
|
||||
"road": "轮式车 · 道路代价",
|
||||
"bridge": "轮式车 · 桥面代价",
|
||||
"ground": "轮式车 · 普通地面代价",
|
||||
"rough": "轮式车 · 陡坡碎石代价",
|
||||
"forest": "轮式车 · 树林代价",
|
||||
"crushable": "轮式车 · 可碾压障碍代价",
|
||||
"shallowWater": "轮式车 · 浅滩涉水代价",
|
||||
"chokepoint": "轮式车 · 窄口代价倍率"
|
||||
},
|
||||
"pathFollow": {
|
||||
"replanIntervalSec": "定时重新寻路间隔",
|
||||
"replanGoalMoveM": "目标移动多远后重新寻路",
|
||||
"offCorridorReplanM": "偏离路线多远后重新寻路",
|
||||
"lookaheadTimeSec": "按当前车速前瞻的时间",
|
||||
"trackedLookaheadMinM": "履带车 · 最短前瞻距离",
|
||||
"trackedLookaheadMaxM": "履带车 · 最长前瞻距离",
|
||||
"wheeledLookaheadMinM": "轮式车 · 最短前瞻距离",
|
||||
"wheeledLookaheadMaxM": "轮式车 · 最长前瞻距离",
|
||||
"cornerAngleDeg": "需要减速的路线拐角角度",
|
||||
"cornerLateralAccelMps2": "过弯允许的横向加速度",
|
||||
"cornerBrakeDecelMps2": "弯前和到达前的减速度",
|
||||
"arriveRadiusM": "到达目标的判定半径",
|
||||
"arriveMinSpeedMps": "接近目标时的最低车速",
|
||||
"narrowWallMarginM": "离网格边缘小于多少算窄路",
|
||||
"narrowSpeedMps": "窄路限速",
|
||||
"bumperRayM": "车头两侧射线长度",
|
||||
"bumperStopM": "车头射线碰到障碍时的停车距离",
|
||||
"bumperBlockSec": "被挡多久后上报障碍",
|
||||
"trafficTtcSec": "车辆碰撞预判时间",
|
||||
"yieldWaitMaxSec": "窄路让路最长等待时间",
|
||||
"stationarySpeedMps": "车速低于多少算作障碍物",
|
||||
"passMarginM": "绕行时与对方车体保持的间距",
|
||||
"passSpeedMps": "绕行障碍时的限速",
|
||||
"blockWaitSec": "无路可绕时等待多久后标记并重新寻路",
|
||||
"blockTtlSec": "被堵路段代价持续时间",
|
||||
"contactGapM": "离障碍多近算作顶上",
|
||||
"contactReverseSec": "顶上多久后倒车",
|
||||
"contactRepeatSec": "多久内在同一处再顶上算作反复顶上",
|
||||
"stuckWindowSec": "卡住检测窗口时长",
|
||||
"stuckMinProgressM": "检测窗口内的最小前进距离",
|
||||
"unstickReverseM": "脱困倒车距离",
|
||||
"unstickReverseSec": "脱困倒车最长时长",
|
||||
"unstickRepeatSec": "多久内再次卡住就升级处理",
|
||||
"unstickMaxAttempts": "放弃当前任务前的脱困次数",
|
||||
"jamRadiusM": "堵车点代价半径",
|
||||
"jamCostMul": "堵车点寻路代价倍率",
|
||||
"jamTtlSec": "堵车点代价持续时间",
|
||||
"giveUpRadiusM": "放弃地点代价半径",
|
||||
"giveUpCostMul": "放弃地点寻路代价倍率",
|
||||
"rubbleRadiusM": "新障碍代价半径",
|
||||
"rubbleCostMul": "新障碍寻路代价倍率",
|
||||
"rubbleTtlSec": "新障碍代价持续时间",
|
||||
"wreckRadiusM": "残骸代价半径",
|
||||
"wreckCostMul": "残骸寻路代价倍率",
|
||||
"wreckTtlSec": "残骸代价持续时间"
|
||||
},
|
||||
"crowd": {
|
||||
"personalSpaceM": "单车安全个人空间",
|
||||
"clusterRadiusM": "扎堆检测半径",
|
||||
@@ -754,7 +909,14 @@
|
||||
},
|
||||
"diagnostics": {
|
||||
"telemetry": "输出 AI 诊断遥测日志",
|
||||
"telemetryIntervalSec": "遥测日志输出间隔"
|
||||
"telemetryIntervalSec": "遥测日志输出间隔",
|
||||
"battleStats": "输出用于版本对比的每局统计",
|
||||
"statsLogIntervalSec": "每局统计的输出间隔",
|
||||
"statsSampleSec": "每辆车的统计抽查间隔",
|
||||
"statsSampleRangeM": "统计抽查最近敌人的范围",
|
||||
"statsRearArcDeg": "算作车尾对敌的后方扇区角度",
|
||||
"trace": "输出 AI 回放轨迹",
|
||||
"traceIntervalSec": "回放轨迹的采样间隔"
|
||||
}
|
||||
},
|
||||
"shared": "这些数值适用于此客户端的全部存档。",
|
||||
|
||||
@@ -54,7 +54,7 @@ function hasValidCrossFieldRules(effective: GroundAiTuningValues, patch: TuningP
|
||||
if (est.watchMaxSec < est.watchMinSec || est.velStableSpanSec <= est.velSampleMinSpanSec) return false;
|
||||
const fc = mergeSection(effective.fireControl, patch.fireControl);
|
||||
if (fc.midRangeM <= fc.closeRangeM || fc.longRangeM <= fc.midRangeM) return false;
|
||||
return fc.pointBlankMaxSpeedKmh >= fc.closeRangeMaxSpeedKmh;
|
||||
return fc.minFireThreshold <= fc.fireThreshold;
|
||||
}
|
||||
|
||||
export function BotTuningPanel({ data, saving, onSave }: Props) {
|
||||
|
||||
@@ -68,6 +68,9 @@ function int(
|
||||
};
|
||||
}
|
||||
|
||||
/** Surfaces of the baked navigation mesh, in the order of tuning/ground-ai.jsonc navCosts*. */
|
||||
const NAV_COST_FIELDS = ['road', 'bridge', 'ground', 'rough', 'forest', 'crushable', 'shallowWater', 'chokepoint'] as const;
|
||||
|
||||
export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
|
||||
{
|
||||
id: 'general',
|
||||
@@ -155,17 +158,12 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
|
||||
defaultOpen: false,
|
||||
customOnly: true,
|
||||
fields: [
|
||||
num('stateMachine', 'preaimAngleDeg', 1, 30, '°'),
|
||||
num('stateMachine', 'movingShotWaitSec', 0.25, 5, 's'),
|
||||
num('stateMachine', 'shortHaltMaxSec', 0.5, 12, 's'),
|
||||
num('stateMachine', 'shortHaltCooldownSec', 0.5, 20, 's'),
|
||||
num('stateMachine', 'turnLaunchSpeedMps', 0.5, 6, 'm/s'),
|
||||
num('stateMachine', 'coverMinDistM', 2, 30, 'm'),
|
||||
num('stateMachine', 'coverMaxDistM', 6, 80, 'm'),
|
||||
num('stateMachine', 'coverRetreatBudgetSec', 1.5, 20, 's'),
|
||||
num('stateMachine', 'reloadAdvanceAngleDeg', 0, 45, '°'),
|
||||
num('stateMachine', 'hullAngleTriggerDeg', 15, 75, '°'),
|
||||
num('stateMachine', 'hullAngleTargetDeg', 0, 35, '°'),
|
||||
num('stateMachine', 'maxTotalHaltSec', 3, 40, 's'),
|
||||
int('stateMachine', 'stalemateMissShots', 1, 8),
|
||||
int('stateMachine', 'stalemateNoShotHalts', 1, 6),
|
||||
@@ -186,8 +184,15 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
|
||||
num('perception', 'normalSpotSec', 0.1, 3, 's'),
|
||||
num('perception', 'farSpotSec', 0.3, 6, 's'),
|
||||
num('perception', 'decayPerSec', 0.2, 10),
|
||||
num('perception', 'frontConeHalfDeg', 10, 90, '°'),
|
||||
num('perception', 'peripheralCloseM', 30, 250, 'm'),
|
||||
num('perception', 'gunFovHalfDeg', 5, 90, '°'),
|
||||
num('perception', 'nearAwareM', 30, 400, 'm'),
|
||||
num('perception', 'nearArcDeg', 90, 360, '°'),
|
||||
num('perception', 'midAwareM', 100, 1500, 'm'),
|
||||
num('perception', 'nearSpotMul', 1, 5),
|
||||
num('perception', 'midSpotMul', 1, 6),
|
||||
num('perception', 'lookAroundSec', 2, 60, 's'),
|
||||
num('perception', 'lookAroundHoldSec', 0.2, 5, 's'),
|
||||
num('perception', 'discoverScore', 0.05, 0.95),
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -196,8 +201,6 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
|
||||
customOnly: true,
|
||||
fields: [
|
||||
num('tactics', 'visionRangeM', 200, 3500, 'm'),
|
||||
num('tactics', 'visionFovDeg', 40, 180, '°'),
|
||||
num('tactics', 'peripheralRangeM', 30, 800, 'm'),
|
||||
num('tactics', 'engineAudioRangeM', 10, 250, 'm'),
|
||||
num('tactics', 'shotAudioRangeM', 50, 1200, 'm'),
|
||||
num('tactics', 'radioShareRangeM', 50, 1500, 'm'),
|
||||
@@ -221,6 +224,70 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
|
||||
num('estimation', 'maxBiasM', 0, 6, 'm'),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'threat',
|
||||
defaultOpen: false,
|
||||
customOnly: true,
|
||||
fields: [
|
||||
num('threat', 'rangeScaleM', 50, 3000, 'm'),
|
||||
num('threat', 'discoveredMul', 0, 1),
|
||||
num('threat', 'aimConeDeg', 5, 90, '°'),
|
||||
num('threat', 'notAimingMul', 0, 1),
|
||||
num('threat', 'unseenMul', 0, 1),
|
||||
num('threat', 'hitMemorySec', 0, 60, 's'),
|
||||
num('threat', 'hitMul', 1, 5),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'turret',
|
||||
defaultOpen: false,
|
||||
customOnly: true,
|
||||
fields: [
|
||||
num('turret', 'minDwellSec', 0, 5, 's'),
|
||||
num('turret', 'switchMargin', 0, 3),
|
||||
num('turret', 'scanArcDeg', 0, 180, '°'),
|
||||
num('turret', 'scanPeriodSec', 1, 30, 's'),
|
||||
num('turret', 'fixedMountYawSpanDeg', 0, 180, '°'),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'behavior',
|
||||
defaultOpen: false,
|
||||
customOnly: true,
|
||||
fields: [
|
||||
num('behavior', 'scoreIntervalSec', 0.1, 3, '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),
|
||||
num('behavior', 'urgencyWeight', 0, 1),
|
||||
num('behavior', 'haltScore', 0, 1),
|
||||
num('behavior', 'crossfirePenalty', 0, 1),
|
||||
num('behavior', 'coverScore', 0, 1),
|
||||
num('behavior', 'coverDangerWeight', 0, 1),
|
||||
num('behavior', 'coverOffensivePenalty', 0, 1),
|
||||
num('behavior', 'coverRetrySec', 0.5, 30, 's'),
|
||||
num('behavior', 'repositionScore', 0, 1),
|
||||
num('behavior', 'holdScore', 0, 1),
|
||||
num('behavior', 'disperseScore', 0, 1),
|
||||
num('behavior', 'urgentSpeedKeep', 0, 1),
|
||||
num('behavior', 'hullAngleDeg', 0, 45, '°'),
|
||||
num('behavior', 'faceToleranceDeg', 3, 60, '°'),
|
||||
num('behavior', 'faceMinDanger', 0, 2),
|
||||
num('behavior', 'reverseTravelAngleDeg', 60, 180, '°'),
|
||||
num('behavior', 'reverseMaxTurnDistM', 0, 200, 'm'),
|
||||
num('behavior', 'reverseMinSpeedMps', 0.5, 10, 'm/s'),
|
||||
num('behavior', 'reverseHoldSec', 0, 20, 's'),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'fireControl',
|
||||
defaultOpen: false,
|
||||
@@ -230,19 +297,41 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
|
||||
num('fireControl', 'closeRangeM', 30, 250, 'm'),
|
||||
num('fireControl', 'midRangeM', 100, 600, 'm'),
|
||||
num('fireControl', 'longRangeM', 300, 1500, 'm'),
|
||||
num('fireControl', 'midSlowSpeedRatio', 0.1, 1),
|
||||
num('fireControl', 'midSlowMaxMps', 1, 15, 'm/s'),
|
||||
num('fireControl', 'closeRangeMaxSpeedKmh', 3.6, 100, 'km/h'),
|
||||
num('fireControl', 'pointBlankMaxSpeedKmh', 3.6, 100, 'km/h'),
|
||||
num('fireControl', 'stopSpeedMaxMps', 0.1, 2, 'm/s'),
|
||||
num('fireControl', 'longRangeWindowSec', 1, 15, 's'),
|
||||
num('fireControl', 'baseAlignDeg', 0.1, 3, '°'),
|
||||
num('fireControl', 'closeHitRadiusM', 0.25, 2.2, 'm'),
|
||||
num('fireControl', 'barrelSettleDegSec', 0.2, 12, '°/s'),
|
||||
num('fireControl', 'closeSettleHoldSec', 0.02, 0.5, 's'),
|
||||
num('fireControl', 'settleHoldSec', 0.05, 1.5, 's'),
|
||||
num('fireControl', 'unstabilizedStopSpeedMps', 0.1, 3, 'm/s'),
|
||||
num('fireControl', 'stabilizedCreepSpeedMps', 1.5, 15, 'm/s'),
|
||||
num('fireControl', 'aimErrorDeg', 0.01, 2, '°'),
|
||||
num('fireControl', 'moveErrDegPerMps', 0, 3, '°'),
|
||||
num('fireControl', 'turnErrDegPerDegSec', 0, 0.5),
|
||||
num('fireControl', 'stabErrFactor', 0.02, 1),
|
||||
num('fireControl', 'targetHalfHeightM', 0.3, 2, 'm'),
|
||||
num('fireControl', 'fireThreshold', 0.05, 0.95),
|
||||
num('fireControl', 'minFireThreshold', 0.01, 0.9),
|
||||
num('fireControl', 'aimingThresholdBonus', 0, 0.5),
|
||||
num('fireControl', 'closeThresholdBonus', 0, 0.5),
|
||||
num('fireControl', 'enemyReloadThresholdBonus', 0, 0.5),
|
||||
num('fireControl', 'enemyReloadSec', 0, 15, 's'),
|
||||
num('fireControl', 'fleetingThresholdBonus', 0, 0.5),
|
||||
num('fireControl', 'fleetingLateralMps', 0.5, 15, 'm/s'),
|
||||
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', 'autocannonReloadDetectSec', 0.1, 3, 's'),
|
||||
{ id: 'groundAi.fireControl.auxWeapons', section: 'fireControl', field: 'auxWeapons', kind: 'bool' },
|
||||
num('fireControl', 'auxMaxRangeM', 30, 1500, 'm'),
|
||||
{ id: 'groundAi.fireControl.auxFireAtArmor', section: 'fireControl', field: 'auxFireAtArmor', kind: 'bool' },
|
||||
num('fireControl', 'friendlyCorridorM', 1, 10, 'm'),
|
||||
num('fireControl', 'ballisticStepMaxM', 5, 80, 'm'),
|
||||
num('fireControl', 'ballisticSweepRadiusM', 0.02, 0.5, 'm'),
|
||||
@@ -259,16 +348,82 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
|
||||
{ id: 'groundAi.navigation.steerSign', section: 'navigation', field: 'steerSign', kind: 'steerSign' },
|
||||
num('navigation', 'deadEchoSec', 0.3, 10, 's'),
|
||||
num('navigation', 'controlTimeoutSec', 0.3, 10, 's'),
|
||||
num('navigation', 'cornerBrakeAccel', 0.5, 8),
|
||||
num('navigation', 'movingFireSpeedRampMps', 0.2, 5, 'm/s'),
|
||||
num('navigation', 'pivotAngleDeg', 25, 150, '°'),
|
||||
num('navigation', 'stuckWindowSec', 1, 15, 's'),
|
||||
num('navigation', 'stuckMinMoveM', 0.5, 10, 'm'),
|
||||
num('navigation', 'unstickReverseSec', 0.8, 10, 's'),
|
||||
num('navigation', 'tacticalReverseDistM', 10, 90, 'm'),
|
||||
num('navigation', 'tacticalReverseMaxSec', 2, 25, 's'),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'navEngine',
|
||||
defaultOpen: false,
|
||||
customOnly: true,
|
||||
fields: [
|
||||
{ id: 'groundAi.navEngine.enabled', section: 'navEngine', field: 'enabled', kind: 'bool' },
|
||||
{ id: 'groundAi.navEngine.allowFallback', section: 'navEngine', field: 'allowFallback', kind: 'bool' },
|
||||
num('navEngine', 'snapRadiusM', 2, 40, 'm'),
|
||||
num('navEngine', 'goalSnapRadiusM', 5, 150, 'm'),
|
||||
num('navEngine', 'pathBudgetMsPerFrame', 0.05, 5, 'ms'),
|
||||
num('navEngine', 'trafficCostPerPath', 0, 3),
|
||||
num('navEngine', 'trafficCostMaxMul', 1, 10),
|
||||
num('navEngine', 'trafficHoldSec', 0, 120, 's'),
|
||||
num('navEngine', 'cornerOffsetM', 0, 5, 'm'),
|
||||
...NAV_COST_FIELDS.map((field) => num('navCostsTracked', field, 0.1, 20)),
|
||||
...NAV_COST_FIELDS.map((field) => num('navCostsWheeled', field, 0.1, 20)),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'pathFollow',
|
||||
defaultOpen: false,
|
||||
customOnly: true,
|
||||
fields: [
|
||||
num('pathFollow', 'replanIntervalSec', 1, 15, 's'),
|
||||
num('pathFollow', 'replanGoalMoveM', 3, 80, 'm'),
|
||||
num('pathFollow', 'offCorridorReplanM', 3, 60, 'm'),
|
||||
num('pathFollow', 'lookaheadTimeSec', 0.3, 5, 's'),
|
||||
num('pathFollow', 'trackedLookaheadMinM', 2, 40, 'm'),
|
||||
num('pathFollow', 'trackedLookaheadMaxM', 4, 60, 'm'),
|
||||
num('pathFollow', 'wheeledLookaheadMinM', 2, 40, 'm'),
|
||||
num('pathFollow', 'wheeledLookaheadMaxM', 4, 60, 'm'),
|
||||
num('pathFollow', 'cornerAngleDeg', 10, 120, '°'),
|
||||
num('pathFollow', 'cornerLateralAccelMps2', 0.5, 10, 'm/s²'),
|
||||
num('pathFollow', 'cornerBrakeDecelMps2', 0.5, 10, 'm/s²'),
|
||||
num('pathFollow', 'arriveRadiusM', 1, 20, 'm'),
|
||||
num('pathFollow', 'arriveMinSpeedMps', 0.3, 6, 'm/s'),
|
||||
num('pathFollow', 'narrowWallMarginM', 0.2, 6, 'm'),
|
||||
num('pathFollow', 'narrowSpeedMps', 1, 15, 'm/s'),
|
||||
num('pathFollow', 'bumperRayM', 2, 20, 'm'),
|
||||
num('pathFollow', 'bumperStopM', 0.3, 6, 'm'),
|
||||
num('pathFollow', 'bumperBlockSec', 0.2, 5, 's'),
|
||||
num('pathFollow', 'trafficTtcSec', 0.5, 8, 's'),
|
||||
num('pathFollow', 'yieldWaitMaxSec', 0.5, 15, 's'),
|
||||
num('pathFollow', 'stationarySpeedMps', 0.2, 4, 'm/s'),
|
||||
num('pathFollow', 'passMarginM', 0.2, 4, 'm'),
|
||||
num('pathFollow', 'passSpeedMps', 1, 12, 'm/s'),
|
||||
num('pathFollow', 'blockWaitSec', 0.5, 15, 's'),
|
||||
num('pathFollow', 'blockTtlSec', 3, 120, 's'),
|
||||
num('pathFollow', 'contactGapM', 0.2, 3, 'm'),
|
||||
num('pathFollow', 'contactReverseSec', 0.3, 5, 's'),
|
||||
num('pathFollow', 'contactRepeatSec', 3, 120, 's'),
|
||||
num('pathFollow', 'stuckWindowSec', 1, 15, 's'),
|
||||
num('pathFollow', 'stuckMinProgressM', 0.2, 10, 'm'),
|
||||
num('pathFollow', 'unstickReverseM', 2, 25, 'm'),
|
||||
num('pathFollow', 'unstickReverseSec', 0.8, 10, 's'),
|
||||
num('pathFollow', 'unstickRepeatSec', 2, 60, 's'),
|
||||
int('pathFollow', 'unstickMaxAttempts', 1, 10),
|
||||
num('pathFollow', 'jamRadiusM', 2, 50, 'm'),
|
||||
num('pathFollow', 'jamCostMul', 1, 50),
|
||||
num('pathFollow', 'jamTtlSec', 5, 600, 's'),
|
||||
num('pathFollow', 'giveUpRadiusM', 3, 50, 'm'),
|
||||
num('pathFollow', 'giveUpCostMul', 1, 200),
|
||||
num('pathFollow', 'rubbleRadiusM', 1, 40, 'm'),
|
||||
num('pathFollow', 'rubbleCostMul', 1, 50),
|
||||
num('pathFollow', 'rubbleTtlSec', 5, 600, 's'),
|
||||
num('pathFollow', 'wreckRadiusM', 1, 40, 'm'),
|
||||
num('pathFollow', 'wreckCostMul', 1, 50),
|
||||
num('pathFollow', 'wreckTtlSec', 5, 600, 's'),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'crowd',
|
||||
defaultOpen: false,
|
||||
@@ -306,6 +461,13 @@ export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [
|
||||
num('cadence', 'navTickSec', 0.05, 2, 's'),
|
||||
{ id: 'groundAi.diagnostics.telemetry', section: 'diagnostics', field: 'telemetry', kind: 'bool' },
|
||||
num('diagnostics', 'telemetryIntervalSec', 0.5, 60, 's'),
|
||||
{ id: 'groundAi.diagnostics.battleStats', section: 'diagnostics', field: 'battleStats', kind: 'bool' },
|
||||
num('diagnostics', 'statsLogIntervalSec', 10, 600, 's'),
|
||||
num('diagnostics', 'statsSampleSec', 0.2, 5, 's'),
|
||||
num('diagnostics', 'statsSampleRangeM', 50, 1000, 'm'),
|
||||
num('diagnostics', 'statsRearArcDeg', 30, 180, '°'),
|
||||
{ id: 'groundAi.diagnostics.trace', section: 'diagnostics', field: 'trace', kind: 'bool' },
|
||||
num('diagnostics', 'traceIntervalSec', 0.1, 5, 's'),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -90,16 +90,84 @@ const GroundAiNavigationSchema = z.object({
|
||||
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),
|
||||
cornerBrakeAccel: z.number().min(0.5).max(8),
|
||||
movingFireSpeedRampMps: z.number().min(0.2).max(5),
|
||||
pivotAngleDeg: z.number().min(25).max(150),
|
||||
stuckWindowSec: z.number().min(1).max(15),
|
||||
stuckMinMoveM: z.number().min(0.5).max(10),
|
||||
unstickReverseSec: z.number().min(0.8).max(10),
|
||||
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),
|
||||
@@ -108,22 +176,24 @@ const GroundAiPerceptionSchema = z.object({
|
||||
normalSpotSec: z.number().min(0.1).max(3),
|
||||
farSpotSec: z.number().min(0.3).max(6),
|
||||
decayPerSec: z.number().min(0.2).max(10),
|
||||
frontConeHalfDeg: z.number().min(10).max(90),
|
||||
peripheralCloseM: z.number().min(30).max(250),
|
||||
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({
|
||||
preaimAngleDeg: z.number().min(1).max(30),
|
||||
movingShotWaitSec: z.number().min(0.25).max(5),
|
||||
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),
|
||||
reloadAdvanceAngleDeg: z.number().min(0).max(45),
|
||||
hullAngleTriggerDeg: z.number().min(15).max(75),
|
||||
hullAngleTargetDeg: z.number().min(0).max(35),
|
||||
maxTotalHaltSec: z.number().min(3).max(40),
|
||||
stalemateMissShots: z.number().int().min(1).max(8),
|
||||
stalemateNoShotHalts: z.number().int().min(1).max(6),
|
||||
@@ -134,8 +204,6 @@ const GroundAiStateMachineSchema = z.object({
|
||||
|
||||
const GroundAiTacticsSchema = z.object({
|
||||
visionRangeM: z.number().min(200).max(3500),
|
||||
visionFovDeg: z.number().min(40).max(180),
|
||||
peripheralRangeM: z.number().min(30).max(800),
|
||||
engineAudioRangeM: z.number().min(10).max(250),
|
||||
shotAudioRangeM: z.number().min(50).max(1200),
|
||||
radioShareRangeM: z.number().min(50).max(1500),
|
||||
@@ -144,6 +212,58 @@ const GroundAiTacticsSchema = z.object({
|
||||
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),
|
||||
@@ -160,19 +280,41 @@ const GroundAiFireControlSchema = z.object({
|
||||
closeRangeM: z.number().min(30).max(250),
|
||||
midRangeM: z.number().min(100).max(600),
|
||||
longRangeM: z.number().min(300).max(1500),
|
||||
midSlowSpeedRatio: z.number().min(0.1).max(1),
|
||||
midSlowMaxMps: z.number().min(1).max(15),
|
||||
closeRangeMaxSpeedKmh: z.number().min(3.6).max(100),
|
||||
pointBlankMaxSpeedKmh: z.number().min(3.6).max(100),
|
||||
stopSpeedMaxMps: z.number().min(0.1).max(2),
|
||||
longRangeWindowSec: z.number().min(1).max(15),
|
||||
baseAlignDeg: z.number().min(0.1).max(3),
|
||||
closeHitRadiusM: z.number().min(0.25).max(2.2),
|
||||
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),
|
||||
unstabilizedStopSpeedMps: z.number().min(0.1).max(3),
|
||||
stabilizedCreepSpeedMps: z.number().min(1.5).max(15),
|
||||
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),
|
||||
@@ -182,6 +324,13 @@ const GroundAiFireControlSchema = z.object({
|
||||
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({
|
||||
@@ -194,10 +343,17 @@ export const GroundAiTuningSchema = z.object({
|
||||
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,
|
||||
});
|
||||
@@ -212,10 +368,17 @@ export const GroundAiTuningPatchSchema = z.object({
|
||||
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(),
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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 }),
|
||||
|
||||
@@ -94,6 +94,36 @@
|
||||
"ridgeMaxShots": 6
|
||||
},
|
||||
|
||||
// Offline map baking parameters. These are copied into the generator's per-level POI input.
|
||||
"coverMap": {
|
||||
"minCoverHeightM": 1.55,
|
||||
"peekMinM": 3.5,
|
||||
"peekMaxM": 6.0,
|
||||
"retreatMinM": 8.0,
|
||||
// Low dry-stone fence models observed to give unreliable shot protection.
|
||||
"excludedCoverRendinst": ["stone_fence_a", "damaged_stone_fence_a", "damaged_stone_fence_b"]
|
||||
},
|
||||
|
||||
// Offline navigation mesh baking parameters, copied into the generator's per-level POI input.
|
||||
"navBake": {
|
||||
// Placed objects whose stock destructionImpulse (config/rendinst_dmg.blk) is at most this
|
||||
// value are knocked down by tanks and baked as crushable rather than solid (N*s).
|
||||
"crushableMaxImpulse": 45000,
|
||||
// riExtra objects with no destructionImpulse are crushable when their stock hp is at most
|
||||
// this value (wooden fences 2, dry-stone fences 12, car wrecks 20; buses 40).
|
||||
"crushableMaxRiExtraHp": 20,
|
||||
// Passages narrower than this many standard-tier vehicle widths are flagged as chokepoints.
|
||||
"chokepointMaxWidthVehicles": 2.0,
|
||||
// Water up to maxFordDepthM is forded (shallow water cost). Deeper water is a wall: besides the
|
||||
// vehicle's half width, the mesh keeps deepWaterMarginM more ground from it where the bank is
|
||||
// less than deepWaterBankHeightM above the water line,
|
||||
// because low banks slope into the water and a hull at the water line slides in. Higher quays
|
||||
// and ramps keep only the half width.
|
||||
"maxFordDepthM": 0.9,
|
||||
"deepWaterMarginM": 1.5,
|
||||
"deepWaterBankHeightM": 1.0
|
||||
},
|
||||
|
||||
"navigation": {
|
||||
// "vehicle_phys" uses custom inputs with native ownership. "movesys" keeps stock movement.
|
||||
"driveMode": "vehicle_phys",
|
||||
@@ -101,17 +131,131 @@
|
||||
"steerSign": 1.0,
|
||||
"deadEchoSec": 1.2,
|
||||
"controlTimeoutSec": 1.0,
|
||||
"cornerBrakeAccel": 1.75,
|
||||
// Speed error at which the moving-fire controller applies full throttle or braking.
|
||||
"movingFireSpeedRampMps": 1.0,
|
||||
"pivotAngleDeg": 75.0,
|
||||
"stuckWindowSec": 3.6,
|
||||
"stuckMinMoveM": 2.0,
|
||||
"unstickReverseSec": 3.0,
|
||||
"tacticalReverseDistM": 34.0,
|
||||
"tacticalReverseMaxSec": 9.5
|
||||
},
|
||||
|
||||
// Baked navigation packs (tools/navgen), loaded once per battle by the native engine.
|
||||
"navEngine": {
|
||||
"enabled": true,
|
||||
// When the battle's pack is missing or broken: true keeps the script's own navigation for the
|
||||
// whole battle, false leaves the bots standing so the problem shows (testing). Decided once at
|
||||
// battle start, never in the middle of a battle.
|
||||
"allowFallback": true,
|
||||
// Farthest a path's start or goal may lie from the mesh.
|
||||
"snapRadiusM": 12.0,
|
||||
// A goal farther than snapRadiusM from the mesh (a position chosen by tactics inside a building
|
||||
// or on a slope) is moved to the nearest walkable point within this distance; beyond it the
|
||||
// goal counts as unreachable. Also used to find the way back onto the mesh.
|
||||
"goalSnapRadiusM": 40.0,
|
||||
// Path searches are spread over frames; this is the search time allowed per frame.
|
||||
"pathBudgetMsPerFrame": 0.5,
|
||||
// Team traffic: each teammate path planned within trafficHoldSec through a stretch of mesh
|
||||
// raises its cost for the team's next searches by trafficCostPerPath, up to trafficCostMaxMul,
|
||||
// so a team spreads over parallel routes instead of queueing on one road.
|
||||
"trafficCostPerPath": 0.35,
|
||||
"trafficCostMaxMul": 2.5,
|
||||
"trafficHoldSec": 12.0,
|
||||
// Path corners are moved this far away from the building or wall they turn around.
|
||||
"cornerOffsetM": 1.5
|
||||
},
|
||||
|
||||
// Path cost multipliers per surface for tracked vehicles; chokepoint multiplies the surface cost
|
||||
// of passages narrower than navBake.chokepointMaxWidthVehicles.
|
||||
"navCostsTracked": {
|
||||
"road": 0.75,
|
||||
"bridge": 0.9,
|
||||
"ground": 1.0,
|
||||
"rough": 1.65,
|
||||
"forest": 2.1,
|
||||
"crushable": 2.4,
|
||||
"shallowWater": 2.6,
|
||||
"chokepoint": 1.8
|
||||
},
|
||||
|
||||
// The same for wheeled vehicles.
|
||||
"navCostsWheeled": {
|
||||
"road": 0.55,
|
||||
"bridge": 0.75,
|
||||
"ground": 1.15,
|
||||
"rough": 3.2,
|
||||
"forest": 2.8,
|
||||
"crushable": 3.5,
|
||||
"shallowWater": 4.0,
|
||||
"chokepoint": 2.2
|
||||
},
|
||||
|
||||
// Following the path, local avoidance and unstick (offline values).
|
||||
"pathFollow": {
|
||||
// Plan again after this long, when the goal moved this far, or when the bot is this far off its path.
|
||||
"replanIntervalSec": 3.5,
|
||||
"replanGoalMoveM": 15.0,
|
||||
"offCorridorReplanM": 12.0,
|
||||
// Steering point: speed times lookaheadTimeSec, kept within the range of the vehicle kind.
|
||||
"lookaheadTimeSec": 1.4,
|
||||
"trackedLookaheadMinM": 6.0,
|
||||
"trackedLookaheadMaxM": 18.0,
|
||||
"wheeledLookaheadMinM": 10.0,
|
||||
"wheeledLookaheadMaxM": 24.0,
|
||||
// Path corners sharper than cornerAngleDeg are taken at the speed the sideways acceleration
|
||||
// allows; the vehicle brakes toward it (and toward its destination) at cornerBrakeDecelMps2.
|
||||
"cornerAngleDeg": 35.0,
|
||||
"cornerLateralAccelMps2": 2.8,
|
||||
"cornerBrakeDecelMps2": 2.0,
|
||||
"arriveRadiusM": 3.0,
|
||||
"arriveMinSpeedMps": 1.5,
|
||||
// The mesh already keeps the vehicle's half width from walls; less room than this beyond it,
|
||||
// or a baked chokepoint, counts as a narrow passage.
|
||||
"narrowWallMarginM": 1.5,
|
||||
"narrowSpeedMps": 4.5,
|
||||
// Rays from both front corners of the hull for obstacles the baked mesh does not know.
|
||||
"bumperRayM": 7.0,
|
||||
"bumperStopM": 1.5,
|
||||
"bumperBlockSec": 0.6,
|
||||
// Moving vehicles that come within reach in trafficTtcSec: follow them, or in narrow passages
|
||||
// give way to the bigger one for at most yieldWaitMaxSec.
|
||||
"trafficTtcSec": 2.5,
|
||||
"yieldWaitMaxSec": 3.0,
|
||||
// Vehicles slower than stationarySpeedMps, wrecks and players' vehicles in the way are passed
|
||||
// on the side the mesh leaves room, keeping passMarginM between hulls, at up to passSpeedMps.
|
||||
"stationarySpeedMps": 1.0,
|
||||
"passMarginM": 0.8,
|
||||
"passSpeedMps": 4.0,
|
||||
// No side free: stop short, and after blockWaitSec mark the obstacle for path searches for
|
||||
// blockTtlSec and plan again. A hull within contactGapM of it for contactReverseSec backs off.
|
||||
// Pressed again within contactRepeatSec near the same place: mark the obstacle, try the other
|
||||
// side, and after unstickMaxAttempts such repeats give the order up.
|
||||
"blockWaitSec": 2.0,
|
||||
"blockTtlSec": 15.0,
|
||||
"contactGapM": 0.8,
|
||||
"contactReverseSec": 1.0,
|
||||
"contactRepeatSec": 20.0,
|
||||
// Less progress than stuckMinProgressM within stuckWindowSec while wanting to move is stuck.
|
||||
"stuckWindowSec": 3.0,
|
||||
"stuckMinProgressM": 0.8,
|
||||
"unstickReverseM": 6.5,
|
||||
"unstickReverseSec": 3.0,
|
||||
"unstickRepeatSec": 8.0,
|
||||
"unstickMaxAttempts": 3,
|
||||
// Temporary path costs: jams found by unstick, fresh obstacles hit by the front rays, wrecks.
|
||||
// A place given up on after unstickMaxAttempts is all but closed (giveUp*), so the next order
|
||||
// routes elsewhere instead of returning to it.
|
||||
"jamRadiusM": 10.0,
|
||||
"jamCostMul": 12.0,
|
||||
"jamTtlSec": 45.0,
|
||||
"giveUpRadiusM": 15.0,
|
||||
"giveUpCostMul": 40.0,
|
||||
"rubbleRadiusM": 6.0,
|
||||
"rubbleCostMul": 25.0,
|
||||
"rubbleTtlSec": 90.0,
|
||||
"wreckRadiusM": 6.0,
|
||||
"wreckCostMul": 6.0,
|
||||
"wreckTtlSec": 120.0
|
||||
},
|
||||
|
||||
// Exposure-based visual perception (offline values; foliageTransparency matches stock infantry AI).
|
||||
"perception": {
|
||||
"foliageTransparency": 0.01,
|
||||
@@ -121,24 +265,29 @@
|
||||
"normalSpotSec": 0.60,
|
||||
"farSpotSec": 1.45,
|
||||
"decayPerSec": 1.5,
|
||||
"frontConeHalfDeg": 60.0,
|
||||
"peripheralCloseM": 100.0
|
||||
// Every visual arc is relative to the barrel. The sight covers gunFovHalfDeg either side;
|
||||
// near awareness covers nearArcDeg around the barrel and every lookAroundSec opens the rear
|
||||
// for lookAroundHoldSec. Mid-distance awareness covers the barrel's front half.
|
||||
// Near and mid spotting use nearSpotMul and midSpotMul respectively.
|
||||
"gunFovHalfDeg": 30.0,
|
||||
"nearAwareM": 150.0,
|
||||
"nearArcDeg": 270.0,
|
||||
"midAwareM": 600.0,
|
||||
"nearSpotMul": 1.5,
|
||||
"midSpotMul": 2.0,
|
||||
"lookAroundSec": 8.0,
|
||||
"lookAroundHoldSec": 1.0,
|
||||
"discoverScore": 0.35
|
||||
},
|
||||
|
||||
// Per-bot hull state machine timings and thresholds (offline values).
|
||||
// Timings and thresholds of the hull actions (short halt, cover pull-back, reposition, repair).
|
||||
"stateMachine": {
|
||||
"preaimAngleDeg": 8.0,
|
||||
// Time a ready gun can be held up by speed or aim before attempting a short halt.
|
||||
"movingShotWaitSec": 1.0,
|
||||
"shortHaltMaxSec": 3.0,
|
||||
"shortHaltCooldownSec": 4.0,
|
||||
"turnLaunchSpeedMps": 2.1,
|
||||
"coverMinDistM": 6.0,
|
||||
"coverMaxDistM": 24.0,
|
||||
"coverRetreatBudgetSec": 6.0,
|
||||
"reloadAdvanceAngleDeg": 18.0,
|
||||
"hullAngleTriggerDeg": 20.0,
|
||||
"hullAngleTargetDeg": 10.0,
|
||||
"maxTotalHaltSec": 12.0,
|
||||
"stalemateMissShots": 2,
|
||||
"stalemateNoShotHalts": 2,
|
||||
@@ -149,9 +298,7 @@
|
||||
|
||||
"tactics": {
|
||||
"visionRangeM": 1250.0,
|
||||
"visionFovDeg": 115.0,
|
||||
"peripheralRangeM": 230.0,
|
||||
"engineAudioRangeM": 65.0,
|
||||
"engineAudioRangeM": 150.0,
|
||||
"shotAudioRangeM": 380.0,
|
||||
"radioShareRangeM": 450.0,
|
||||
"memoryTtlSec": 12.0,
|
||||
@@ -171,26 +318,129 @@
|
||||
"maxBiasM": 2.2
|
||||
},
|
||||
|
||||
// Threat table (decision layer design, section 4): how dangerous each discovered enemy is to the
|
||||
// bot. Danger falls with distance as 1 / (1 + distance / rangeScaleM) and is multiplied by
|
||||
// discoveredMul until the enemy is seen clearly, by notAimingMul unless its hull or gun points
|
||||
// within aimConeDeg of the bot (or it hit the bot), by unseenMul when the bot is out of its
|
||||
// sight, and by hitMul for hitMemorySec after it hit the bot. Penetration is not counted yet.
|
||||
"threat": {
|
||||
"rangeScaleM": 400.0,
|
||||
"discoveredMul": 0.7,
|
||||
"aimConeDeg": 25.0,
|
||||
"notAimingMul": 0.5,
|
||||
"unseenMul": 0.4,
|
||||
"hitMemorySec": 6.0,
|
||||
"hitMul": 2.0
|
||||
},
|
||||
|
||||
// The turret gives visible contacts attention by danger, then checks memory and directional cues.
|
||||
// While engaged, the competing threat needs switchMargin more danger to take over.
|
||||
// The turret sweeps the route when it has no contact or cue.
|
||||
"turret": {
|
||||
"minDwellSec": 0.6,
|
||||
"switchMargin": 0.25,
|
||||
"scanArcDeg": 60.0,
|
||||
"scanPeriodSec": 6.0,
|
||||
"fixedMountYawSpanDeg": 60.0
|
||||
},
|
||||
|
||||
// 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,
|
||||
"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,
|
||||
"urgencyWeight": 0.15,
|
||||
"haltScore": 0.55,
|
||||
"crossfirePenalty": 0.15,
|
||||
"coverScore": 0.45,
|
||||
"coverDangerWeight": 0.25,
|
||||
"coverOffensivePenalty": 0.2,
|
||||
"coverRetrySec": 4.0,
|
||||
"repositionScore": 0.7,
|
||||
"holdScore": 0.6,
|
||||
"disperseScore": 0.62,
|
||||
"urgentSpeedKeep": 0.5,
|
||||
"hullAngleDeg": 20.0,
|
||||
"faceToleranceDeg": 15.0,
|
||||
"faceMinDanger": 0.15,
|
||||
"reverseTravelAngleDeg": 110.0,
|
||||
"reverseMaxTurnDistM": 45.0,
|
||||
"reverseMinSpeedMps": 2.5,
|
||||
"reverseHoldSec": 3.0
|
||||
},
|
||||
|
||||
// Fire permission (decision layer design, section 6). A main-gun shot needs its estimated hit
|
||||
// probability to reach the fire threshold. The hit probability compares the visible part of the
|
||||
// target (its projected width, targetHalfHeightM high, shrunk when only part of it is visible)
|
||||
// with the expected angular error: aimErrorDeg, plus moveErrDegPerMps per m/s of own speed and
|
||||
// turnErrDegPerDegSec per deg/s of hull turn (times stabErrFactor with a stabilizer), plus the
|
||||
// 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 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,
|
||||
"midRangeM": 300.0,
|
||||
"longRangeM": 800.0,
|
||||
"midSlowSpeedRatio": 0.45,
|
||||
"midSlowMaxMps": 5.5,
|
||||
// Moving-fire speed rises from the mid-range limit through the close-range boundary to point blank.
|
||||
"closeRangeMaxSpeedKmh": 30.0,
|
||||
"pointBlankMaxSpeedKmh": 35.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,
|
||||
"closeHitRadiusM": 0.85,
|
||||
// Outside close range, the rate at which barrel alignment drifts relative to the aim direction.
|
||||
"barrelSettleDegSec": 1.8,
|
||||
"closeSettleHoldSec": 0.08,
|
||||
"settleHoldSec": 0.20,
|
||||
"unstabilizedStopSpeedMps": 0.45,
|
||||
"stabilizedCreepSpeedMps": 5.5,
|
||||
"closeSettleHoldSec": 0.06,
|
||||
"settleHoldSec": 0.12,
|
||||
"aimErrorDeg": 0.07,
|
||||
"moveErrDegPerMps": 0.35,
|
||||
"turnErrDegPerDegSec": 0.03,
|
||||
"stabErrFactor": 0.2,
|
||||
"targetHalfHeightM": 1.0,
|
||||
"fireThreshold": 0.45,
|
||||
"minFireThreshold": 0.1,
|
||||
"aimingThresholdBonus": 0.1,
|
||||
"closeThresholdBonus": 0.15,
|
||||
"enemyReloadThresholdBonus": 0.08,
|
||||
"enemyReloadSec": 3.0,
|
||||
"fleetingThresholdBonus": 0.1,
|
||||
"fleetingLateralMps": 3.0,
|
||||
"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,
|
||||
// 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,
|
||||
"autocannonReloadDetectSec": 0.6,
|
||||
// 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,
|
||||
"friendlyCorridorM": 3.2,
|
||||
"ballisticStepMaxM": 25.0,
|
||||
"ballisticSweepRadiusM": 0.12,
|
||||
@@ -199,6 +449,20 @@
|
||||
|
||||
"diagnostics": {
|
||||
"telemetry": true,
|
||||
"telemetryIntervalSec": 5.0
|
||||
"telemetryIntervalSec": 5.0,
|
||||
// Battle statistics for comparing builds (WTO_AI|BATTLE_STATS): cumulative per vehicle class,
|
||||
// logged every statsLogIntervalSec and when the battle ends. Every statsSampleSec each bot
|
||||
// checks the nearest enemy in line of sight within statsSampleRangeM: whether it knows it,
|
||||
// how far the turret is off it, and whether its rear (statsRearArcDeg wide) faces it.
|
||||
"battleStats": true,
|
||||
"statsLogIntervalSec": 60.0,
|
||||
"statsSampleSec": 1.0,
|
||||
"statsSampleRangeM": 300.0,
|
||||
"statsRearArcDeg": 120.0,
|
||||
// Replay trace for the AI viewer (WTO_AI|TRACE_*, HIT, DEATH): every traceIntervalSec the
|
||||
// capture zones, every ground unit and every bot's decision state. About 10 MB of log for
|
||||
// 32 bots over 15 minutes at 0.5 s.
|
||||
"trace": true,
|
||||
"traceIntervalSec": 0.5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"level": "avg_berlin",
|
||||
"version": 1,
|
||||
"bake": {
|
||||
// The original arterial and ring roads use this LMp2 material.
|
||||
"roadMaterials": ["concrete"],
|
||||
"walkableRendinst": ["fountain_base_b_body"],
|
||||
"downhillLinks": [
|
||||
// Dry endpoints verified on the two meshes at the eastern canal bank.
|
||||
{
|
||||
"from": { "x": 2476.0, "y": 43.34, "z": 1124.0 },
|
||||
"to": { "x": 2460.0, "y": 36.61, "z": 1124.0 },
|
||||
"radiusM": 0.75,
|
||||
"widthTiers": [0]
|
||||
},
|
||||
{
|
||||
"from": { "x": 2476.0, "y": 43.12, "z": 1135.5 },
|
||||
"to": { "x": 2458.0, "y": 36.59, "z": 1135.5 },
|
||||
"radiusM": 0.75,
|
||||
"widthTiers": [1]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"level": "avg_poland",
|
||||
"version": 1,
|
||||
"bake": {
|
||||
// The town streets and squares use this LMp2 material.
|
||||
"roadMaterials": ["concrete"]
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user