import type { Position } from '../../../sdk/types.js'; import { nearestSafePoint, type OffRoutePoint } from './off-route-points.js'; import type { RouteEvidence } from './escape-planner.js'; /** 藏身角落,离路点的一种(见 OffRoutePoint)。 */ export type HideSpot = OffRoutePoint; /** * 躲藏点:离线从服务端烘焙地图(config/clawclaw/clawclaw.tmj.baked.npz)算出的「藏身角落」。筛选条件: * - 所在房间有 ≥2 个出口(非死胡同,被追能逃);**走廊**(做任务的必经路线)一律排除; * - 出口 ≥4 的枢纽房间排除(穿行人流太大,藏不住); * - 取房间内「离各出口最深、且远离任务点/出生点」的可走格(缩在内侧角落,避开穿行线与刷新点)。 * * 重新生成:scripts/find-hide-spots.py(用后端 venv 解释器跑,读 baked.npz,打印可粘贴的本数组)。 * 这是离线烘焙数据,和 pathfind 的可行走网格一样:运行时按需 snap 到最近可走格即可。 */ export const HIDE_SPOTS: readonly HideSpot[] = [ { x: 2882, y: 1362, room: '导航仓' }, { x: 2386, y: 1138, room: '健身房' }, { x: 1922, y: 1234, room: '酒吧' }, { x: 2418, y: 2130, room: '休闲会所' }, { x: 1538, y: 1826, room: '监控室' }, { x: 514, y: 2402, room: '动力监控室' }, { x: 1538, y: 2514, room: '自助餐厅' }, { x: 1314, y: 2674, room: '制氧舱' }, { x: 2514, y: 2882, room: '中央厨房' }, { x: 2882, y: 2994, room: '冷库' }, { x: 3858, y: 2434, room: '情报室' }, ]; /** 躲藏点离任一威胁多近就硬排除(与 nearestSafeTask 的端点排除同量级)。 */ export const HIDE_THREAT_EXCLUDE_RANGE = 500; /** 去躲藏点的测地路径经过威胁这个距离内也排除(避免走向把守者)。 */ export const HIDE_PATH_THREAT_RADIUS = 350; export interface NearestSafeHideOptions { threatExcludeRadius?: number; pathThreatRadius?: number; /** 当前已选躲藏点:仍是合法候选就保持不变,杜绝等距摇摆。 */ stickyTo?: HideSpot | null; /** 被标记为不可达的移动目标:在其附近的点跳过。 */ blockedTarget?: Position | null; /** Current-frame parallel A* projection; invalid or incomplete evidence falls back safely. */ routeEvidence?: Readonly | null; } /** * 选「最近的安全躲藏点」:威胁旁的点硬排除、去路经过威胁附近的点排除,余者取测地最近,带粘性 * (当前点仍合法就不换),全部被封死时退回「离威胁最远」的点。实现复用 nearestSafePoint。 */ export function nearestSafeHideSpot( from: Position, threatPoints: Position[] = [], opts: NearestSafeHideOptions = {}, ): HideSpot | null { return nearestSafePoint(HIDE_SPOTS, from, threatPoints, { threatExcludeRadius: opts.threatExcludeRadius ?? HIDE_THREAT_EXCLUDE_RANGE, pathThreatRadius: opts.pathThreatRadius ?? HIDE_PATH_THREAT_RADIUS, stickyTo: opts.stickyTo ?? null, blockedTarget: opts.blockedTarget ?? null, routeEvidence: opts.routeEvidence, }); }