feat: goap ai for faction and ship

This commit is contained in:
2026-03-18 00:09:39 -04:00
parent b3508d9d08
commit ad5f733b3e
14 changed files with 945 additions and 349 deletions

View File

@@ -12,7 +12,9 @@ export interface ShipSnapshot {
state: string;
orderKind: string | null;
defaultBehaviorKind: string;
behaviorPhase: string | null;
controllerTaskKind: string;
commanderObjective: string | null;
nodeId?: string | null;
bubbleId?: string | null;
dockedStationId?: string | null;

View File

@@ -1,5 +1,5 @@
import { inventoryAmount } from "./viewerMath";
import { describeShipCurrentAction, describeShipLocation, describeShipState } from "./viewerSelection";
import { describeShipCurrentAction, describeShipLocation, describeShipObjective, describeShipState } from "./viewerSelection";
import type { CameraMode, Selectable, WorldState, ZoomLevel } from "./viewerTypes";
export function renderFactionStrip(
@@ -65,8 +65,8 @@ export function renderFactionStrip(
</div>
` : ""}
<div class="ship-card-ai">
<p>Order ${ship.orderKind ?? "none"}</p>
<p>Behavior ${ship.defaultBehaviorKind}</p>
${ship.commanderObjective ? `<p>Objective ${describeShipObjective(ship.commanderObjective)}</p>` : ""}
<p>Behavior ${ship.defaultBehaviorKind}${ship.behaviorPhase ? ` · ${ship.behaviorPhase}` : ""}</p>
<p>Task ${ship.controllerTaskKind}</p>
</div>
</article>

View File

@@ -5,7 +5,7 @@ import {
formatSystemDistance,
inventoryAmount,
} from "./viewerMath";
import { describeOrbitalParent, describeSelectable, describeShipCurrentAction, describeShipState, describeSpatialNodePathWithinSystem, getSelectionGroup, renderSystemDetails } from "./viewerSelection";
import { describeOrbitalParent, describeSelectable, describeShipCurrentAction, describeShipObjective, describeShipState, describeSpatialNodePathWithinSystem, getSelectionGroup, renderSystemDetails } from "./viewerSelection";
import type {
CameraMode,
HistoryWindowState,
@@ -203,6 +203,9 @@ export function updateDetailPanel(
detailBodyEl.innerHTML = `
<p>Parent ${parent}</p>
<p>State ${shipState}</p>
${ship.commanderObjective ? `<p>Objective ${describeShipObjective(ship.commanderObjective)}</p>` : ""}
<p>Behavior ${ship.defaultBehaviorKind}${ship.behaviorPhase ? ` · ${ship.behaviorPhase}` : ""}</p>
<p>Task ${ship.controllerTaskKind}</p>
${shipAction ? `
<div class="detail-progress">
<div class="detail-progress-label">

View File

@@ -349,6 +349,16 @@ function describeControllerTask(taskKind: string): string {
}
}
export function describeShipObjective(objective: string): string {
switch (objective) {
case "set-mining-objective": return "mine resources";
case "set-patrol-objective": return "patrol";
case "set-construction-objective": return "build station";
case "set-idle-objective": return "idle";
default: return objective;
}
}
export function describeShipCurrentAction(ship: ShipSnapshot): { label: string; progress: number } | undefined {
if (!ship.currentAction) {
return undefined;