Restore autonomous orbit patrol tasks
This commit is contained in:
parent
7fe2b7389e
commit
f011d81c9f
6 changed files with 137 additions and 2 deletions
|
|
@ -19,6 +19,82 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
AgentCompletesAttackTaskThroughTargetFireAndYmir();
|
||||
AgentCompletesHaulTaskThroughMovementAndCargoCommands();
|
||||
RejectedHaulTransferDoesNotAdvanceTask();
|
||||
AgentPatrolsHistoricalOrbitCircuitThroughMovementCommands();
|
||||
}
|
||||
|
||||
private static void AgentPatrolsHistoricalOrbitCircuitThroughMovementCommands()
|
||||
{
|
||||
var agent = Entity(0, 0, "workers");
|
||||
agent.AgentTaskCapabilities = [AetheriaRuntimeAgentTaskTypes.Defend];
|
||||
var run = new AetheriaRuntimeRunCheckpointCommit
|
||||
{
|
||||
RunId = "agent-patrol-smoke",
|
||||
CurrentZoneIndex = 0,
|
||||
CurrentEntityKey = "zone.0.entity.0",
|
||||
Zones =
|
||||
[
|
||||
new AetheriaRuntimeZoneSnapshotCommit
|
||||
{
|
||||
ZoneIndex = 0,
|
||||
Entities = [agent],
|
||||
Orbits =
|
||||
[
|
||||
new AetheriaRuntimeOrbitSnapshotCommit { OrbitKey = "orbit:east", FixedPositionX = 20 },
|
||||
new AetheriaRuntimeOrbitSnapshotCommit { OrbitKey = "orbit:west", FixedPositionX = -20 }
|
||||
],
|
||||
Bodies =
|
||||
[
|
||||
new AetheriaRuntimeBodySnapshotCommit { BodyKey = "body:east", OrbitKey = "orbit:east", Kind = "planet" },
|
||||
new AetheriaRuntimeBodySnapshotCommit { BodyKey = "body:west", OrbitKey = "orbit:west", Kind = "planet" }
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var issue = AetheriaRuntimeDaemonCommandDocument.Create(
|
||||
AetheriaRuntimeDaemonCommandKinds.IssueAgentTask,
|
||||
"commander-smoke",
|
||||
"starbridge-smoke",
|
||||
0,
|
||||
"");
|
||||
issue.CommandId = "issue-patrol";
|
||||
issue.AgentTask = new AetheriaRuntimeAgentTaskCommand
|
||||
{
|
||||
TaskId = "patrol-orbits",
|
||||
CorporationKey = "workers",
|
||||
TaskType = AetheriaRuntimeAgentTaskTypes.Defend,
|
||||
Priority = 10,
|
||||
ZoneIndex = 0,
|
||||
CompletionRadius = 5,
|
||||
TargetBodyKeys = ["body:east", "body:west"]
|
||||
};
|
||||
var sawWestLeg = false;
|
||||
var sawReturnToEast = false;
|
||||
for (var frame = 0; frame < 30; frame++)
|
||||
{
|
||||
var tick = AetheriaRuntimeDaemonTickRunner.Tick(
|
||||
Path.Combine(Path.GetTempPath(), "aetheria-agent-patrol-smoke.cc"),
|
||||
run,
|
||||
new AetheriaRuntimeDaemonTickOptions
|
||||
{
|
||||
FrameId = frame,
|
||||
FixedDeltaSeconds = 0.1,
|
||||
SimulationTimeSeconds = frame * 0.1,
|
||||
ObservedCommands = frame == 0 ? [issue] : Array.Empty<AetheriaRuntimeDaemonCommandDocument>(),
|
||||
ProjectilePhysics = AetheriaRuntimeProjectilePhysicsUnavailable.Instance,
|
||||
BuildPublications = false
|
||||
});
|
||||
Require(tick.OperationResult.AppliedCommandIds.Any(id => id.EndsWith(":move", StringComparison.Ordinal)),
|
||||
"patrol controller must drive the shared movement command every tick");
|
||||
var cursor = run.AgentTasks.Single().CircuitIndex;
|
||||
sawWestLeg |= cursor == 1;
|
||||
sawReturnToEast |= sawWestLeg && cursor == 0;
|
||||
if (sawReturnToEast)
|
||||
break;
|
||||
}
|
||||
|
||||
Require(sawWestLeg && sawReturnToEast, "patrol must advance through and wrap its authored orbit circuit");
|
||||
RequireEqual(AetheriaRuntimeAgentTaskStatuses.Assigned, run.AgentTasks.Single().Status,
|
||||
"patrol is persistent work and must remain assigned after one circuit");
|
||||
}
|
||||
|
||||
private static void RejectedHaulTransferDoesNotAdvanceTask()
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
[Key(17)] public int DeliveredQuantity { get; set; }
|
||||
[Key(18)] public int PendingQuantity { get; set; }
|
||||
[Key(19)] public string Phase { get; set; } = "";
|
||||
[Key(20)] public IReadOnlyList<string> TargetBodyKeys { get; set; } = Array.Empty<string>();
|
||||
[Key(21)] public int CircuitIndex { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -71,6 +73,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
[Key(10)] public int OriginEntityIndex { get; set; } = -1;
|
||||
[Key(11)] public string ItemKey { get; set; } = "";
|
||||
[Key(12)] public int Quantity { get; set; }
|
||||
[Key(13)] public IReadOnlyList<string> TargetBodyKeys { get; set; } = Array.Empty<string>();
|
||||
}
|
||||
|
||||
public static class AetheriaRuntimeAgentScheduler
|
||||
|
|
@ -178,6 +181,11 @@ namespace GameCult.Aetheria.State.Verse
|
|||
commands.AddRange(PlanHaul(run, zone!, task, agent, frameId));
|
||||
continue;
|
||||
}
|
||||
if (string.Equals(task.TaskType, AetheriaRuntimeAgentTaskTypes.Defend, StringComparison.Ordinal))
|
||||
{
|
||||
commands.AddRange(PlanPatrol(zone!, task, agent, frameId));
|
||||
continue;
|
||||
}
|
||||
|
||||
var target = task.TargetEntityIndex < 0
|
||||
? null
|
||||
|
|
@ -277,6 +285,44 @@ namespace GameCult.Aetheria.State.Verse
|
|||
};
|
||||
}
|
||||
|
||||
private static IReadOnlyList<AetheriaRuntimeDaemonCommandDocument> PlanPatrol(
|
||||
AetheriaRuntimeZoneSnapshotCommit zone,
|
||||
AetheriaRuntimeAgentTaskCommit task,
|
||||
AetheriaRuntimeEntitySnapshotCommit agent,
|
||||
long frameId)
|
||||
{
|
||||
var circuit = (task.TargetBodyKeys ?? Array.Empty<string>())
|
||||
.Where(key => !string.IsNullOrWhiteSpace(key))
|
||||
.ToArray();
|
||||
if (circuit.Length == 0)
|
||||
{
|
||||
Fail(task, agent);
|
||||
return Array.Empty<AetheriaRuntimeDaemonCommandDocument>();
|
||||
}
|
||||
|
||||
task.CircuitIndex = ((task.CircuitIndex % circuit.Length) + circuit.Length) % circuit.Length;
|
||||
var body = AetheriaRuntimeDaemonRenderQueries.QueryBodyPoses(zone)
|
||||
.FirstOrDefault(candidate => string.Equals(candidate.BodyKey, circuit[task.CircuitIndex], StringComparison.Ordinal));
|
||||
if (string.IsNullOrWhiteSpace(body.BodyKey))
|
||||
{
|
||||
Fail(task, agent);
|
||||
return Array.Empty<AetheriaRuntimeDaemonCommandDocument>();
|
||||
}
|
||||
|
||||
var dx = body.CenterX - agent.PositionX;
|
||||
var dz = body.CenterZ - agent.PositionZ;
|
||||
var distance = Math.Sqrt(dx * dx + dz * dz);
|
||||
if (distance <= Math.Max(0.01, task.CompletionRadius))
|
||||
{
|
||||
task.CircuitIndex = (task.CircuitIndex + 1) % circuit.Length;
|
||||
var next = AetheriaRuntimeDaemonRenderQueries.QueryBodyPoses(zone)
|
||||
.First(candidate => string.Equals(candidate.BodyKey, circuit[task.CircuitIndex], StringComparison.Ordinal));
|
||||
dx = next.CenterX - agent.PositionX;
|
||||
dz = next.CenterZ - agent.PositionZ;
|
||||
}
|
||||
return new[] { Movement(task, agent, frameId, dx, dz, 1) };
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeDaemonCommandDocument Movement(
|
||||
AetheriaRuntimeAgentTaskCommit task,
|
||||
AetheriaRuntimeEntitySnapshotCommit agent,
|
||||
|
|
|
|||
|
|
@ -187,6 +187,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
("requestedQuantity", task.RequestedQuantity.ToString(CultureInfo.InvariantCulture)),
|
||||
("deliveredQuantity", task.DeliveredQuantity.ToString(CultureInfo.InvariantCulture)),
|
||||
("phase", task.Phase),
|
||||
("targetBodyKeys", string.Join(",", task.TargetBodyKeys ?? Array.Empty<string>())),
|
||||
("circuitIndex", task.CircuitIndex.ToString(CultureInfo.InvariantCulture)),
|
||||
("targetPosition", string.Join(",", new[]
|
||||
{
|
||||
task.TargetPositionX.ToString("0.###", CultureInfo.InvariantCulture),
|
||||
|
|
|
|||
|
|
@ -209,6 +209,11 @@ namespace GameCult.Aetheria.State.Verse
|
|||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Equals(taskType, AetheriaRuntimeAgentTaskTypes.Defend, StringComparison.Ordinal) &&
|
||||
!(request.TargetBodyKeys ?? Array.Empty<string>()).Any(key => !string.IsNullOrWhiteSpace(key)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
run.AgentTasks = (run.AgentTasks ?? Array.Empty<AetheriaRuntimeAgentTaskCommit>())
|
||||
.Concat(new[]
|
||||
|
|
@ -231,6 +236,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
Phase = string.Equals(taskType, AetheriaRuntimeAgentTaskTypes.Haul, StringComparison.Ordinal)
|
||||
? "pickup"
|
||||
: "",
|
||||
TargetBodyKeys = request.TargetBodyKeys ?? Array.Empty<string>(),
|
||||
Status = AetheriaRuntimeAgentTaskStatuses.Queued
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -510,7 +510,12 @@ public sealed class AetheriaRuntimeDaemonOperationsClient
|
|||
WeaponGroup = (int)ReadPayloadDouble(request, "weaponGroup", 0),
|
||||
OriginEntityIndex = (int)ReadPayloadDouble(request, "originEntityIndex", -1),
|
||||
ItemKey = ReadPayloadString(request, "itemKey", ""),
|
||||
Quantity = (int)ReadPayloadDouble(request, "quantity", 0)
|
||||
Quantity = (int)ReadPayloadDouble(request, "quantity", 0),
|
||||
TargetBodyKeys = ReadPayloadString(request, "targetBodyKeys", "")
|
||||
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(key => key.Trim())
|
||||
.Where(key => !string.IsNullOrWhiteSpace(key))
|
||||
.ToArray()
|
||||
}),
|
||||
AetheriaRuntimeDaemonCommandKinds.CancelAgentTask => client.CancelAgentTask(
|
||||
frame,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
|
|||
| Starbridge | original/shared architecture intent | one daemon session | pilot + commander surfaces | Unity + Electron | commander task board and autonomous explore execution wired; Electron Eve lowering and split-target proof missing | commander orders plus four pilots and autonomous workers |
|
||||
| Behavior engine | `ServerShared/Behaviors` composition | daemon | executable action/status projection | action bar and feedback | reference | every behavior family and modifier lifecycle |
|
||||
| Sensors/visibility | decaying sources and observer information thresholds | daemon | contacts and ping events | indicators/maps | reference | threshold, decay, ping and classification timelines |
|
||||
| AI/tasks | corporation task scheduler plus agent state machines | daemon | commander task board and shared semantic controls | Eve commander/pilot clients | explore, attack, and same-zone haul execution wired through shared commands; capability/priority assignment and rejected-transfer behavior proven | original optimum-range control, cross-zone haul, mine/tow/defend timelines, cancellation and reconnect |
|
||||
| AI/tasks | corporation task scheduler plus agent state machines | daemon | commander task board and shared semantic controls | Eve commander/pilot clients | explore, attack, same-zone haul, and persistent orbit patrol wired through shared commands; capability/priority assignment and rejected-transfer behavior proven | original optimum-range control, cross-zone haul, mining, towing, survey-tool timelines, cancellation and reconnect |
|
||||
| Consumables | cargo-backed timed behavior containers | daemon | dynamic actions and active effects | action bar/schematic | reference | consume, stacking, duration and cleanup |
|
||||
|
||||
## Ownership Invariants
|
||||
|
|
|
|||
Loading…
Reference in a new issue