Restore daemon corporation task scheduling
This commit is contained in:
parent
c3e401725c
commit
266ab49dc6
14 changed files with 570 additions and 9 deletions
|
|
@ -71,6 +71,8 @@ export const AetheriaRuntimeDaemonCommandKinds = {
|
|||
setHeatsinksEnabled: 37,
|
||||
setShutdownPerformance: 38,
|
||||
toggleShieldEnabled: 39,
|
||||
issueAgentTask: 40,
|
||||
cancelAgentTask: 41,
|
||||
} as const;
|
||||
|
||||
export const AetheriaRuntimeEveCommandKinds = {
|
||||
|
|
@ -165,7 +167,8 @@ export type AetheriaRuntimeDaemonCommandDocumentSlot =
|
|||
| "storeItem"
|
||||
| "authorRuntimeId"
|
||||
| "subjectKey"
|
||||
| "claimKind";
|
||||
| "claimKind"
|
||||
| "agentTask";
|
||||
|
||||
export const aetheriaRuntimeDaemonCommandDocumentSlots: Record<AetheriaRuntimeDaemonCommandDocumentSlot, number> = {
|
||||
schema: 0,
|
||||
|
|
@ -197,6 +200,7 @@ export const aetheriaRuntimeDaemonCommandDocumentSlots: Record<AetheriaRuntimeDa
|
|||
authorRuntimeId: 27,
|
||||
subjectKey: 28,
|
||||
claimKind: 29,
|
||||
agentTask: 30,
|
||||
};
|
||||
|
||||
export type AetheriaRuntimeEveCommandDocumentSlot =
|
||||
|
|
@ -950,7 +954,8 @@ export type AetheriaRuntimeRunCheckpointCommitSlot =
|
|||
| "factionRelationships"
|
||||
| "generationSeed"
|
||||
| "currentEntityKey"
|
||||
| "credits";
|
||||
| "credits"
|
||||
| "agentTasks";
|
||||
|
||||
export const aetheriaRuntimeRunCheckpointCommitSlots: Record<AetheriaRuntimeRunCheckpointCommitSlot, number> = {
|
||||
runId: 0,
|
||||
|
|
@ -964,6 +969,7 @@ export const aetheriaRuntimeRunCheckpointCommitSlots: Record<AetheriaRuntimeRunC
|
|||
generationSeed: 9,
|
||||
currentEntityKey: 10,
|
||||
credits: 11,
|
||||
agentTasks: 12,
|
||||
};
|
||||
|
||||
export type AetheriaRuntimeZoneSnapshotCommitSlot =
|
||||
|
|
@ -1043,7 +1049,9 @@ export type AetheriaRuntimeEntitySnapshotCommitSlot =
|
|||
| "contacts"
|
||||
| "hullItemKey"
|
||||
| "factionKey"
|
||||
| "shutdownPerformance";
|
||||
| "shutdownPerformance"
|
||||
| "agentTaskCapabilities"
|
||||
| "assignedAgentTaskId";
|
||||
|
||||
export const aetheriaRuntimeEntitySnapshotCommitSlots: Record<AetheriaRuntimeEntitySnapshotCommitSlot, number> = {
|
||||
entityIndex: 0,
|
||||
|
|
@ -1082,6 +1090,8 @@ export const aetheriaRuntimeEntitySnapshotCommitSlots: Record<AetheriaRuntimeEnt
|
|||
hullItemKey: 35,
|
||||
factionKey: 36,
|
||||
shutdownPerformance: 37,
|
||||
agentTaskCapabilities: 38,
|
||||
assignedAgentTaskId: 39,
|
||||
};
|
||||
|
||||
export type AetheriaRuntimeProjectileCommitSlot =
|
||||
|
|
|
|||
|
|
@ -14,6 +14,114 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
MissingPhysicsOwnerCannotAdvanceProjectiles();
|
||||
ThermalCellsUseFossilConductionAndRadiation();
|
||||
MultipleActorsUseTheSameMovementLever();
|
||||
AgentClaimsAndCompletesExploreTaskThroughCommands();
|
||||
SchedulerAssignsHighestPriorityCompatibleTask();
|
||||
}
|
||||
|
||||
private static void SchedulerAssignsHighestPriorityCompatibleTask()
|
||||
{
|
||||
var agent = Entity(0, 0, "workers");
|
||||
agent.AgentTaskCapabilities = [AetheriaRuntimeAgentTaskTypes.Explore];
|
||||
var low = AgentTask("low", 1);
|
||||
var high = AgentTask("high", 99);
|
||||
var run = new AetheriaRuntimeRunCheckpointCommit
|
||||
{
|
||||
RunId = "agent-priority-smoke",
|
||||
Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [agent] }],
|
||||
AgentTasks = [low, high]
|
||||
};
|
||||
|
||||
AetheriaRuntimeAgentScheduler.AssignAndPlan(run, 4);
|
||||
|
||||
RequireEqual(AetheriaRuntimeAgentTaskStatuses.Assigned, high.Status,
|
||||
"highest priority compatible task must claim the available agent");
|
||||
RequireEqual(AetheriaRuntimeAgentTaskStatuses.Queued, low.Status,
|
||||
"lower priority task must remain queued when no controller remains");
|
||||
RequireEqual("high", agent.AssignedAgentTaskId, "agent assignment must point at the selected task");
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeAgentTaskCommit AgentTask(string id, int priority) => new()
|
||||
{
|
||||
TaskId = id,
|
||||
CorporationKey = "workers",
|
||||
TaskType = AetheriaRuntimeAgentTaskTypes.Explore,
|
||||
Priority = priority,
|
||||
ZoneIndex = 0,
|
||||
TargetPositionX = 100,
|
||||
CompletionRadius = 5
|
||||
};
|
||||
|
||||
private static void AgentClaimsAndCompletesExploreTaskThroughCommands()
|
||||
{
|
||||
var agent = Entity(0, 0, "workers");
|
||||
agent.AgentTaskCapabilities = [AetheriaRuntimeAgentTaskTypes.Explore];
|
||||
var run = new AetheriaRuntimeRunCheckpointCommit
|
||||
{
|
||||
RunId = "agent-task-smoke",
|
||||
CurrentZoneIndex = 0,
|
||||
CurrentEntityKey = "zone.0.entity.0",
|
||||
Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [agent] }]
|
||||
};
|
||||
var issue = AetheriaRuntimeDaemonCommandDocument.Create(
|
||||
AetheriaRuntimeDaemonCommandKinds.IssueAgentTask,
|
||||
"commander-smoke",
|
||||
"starbridge-smoke",
|
||||
0,
|
||||
"");
|
||||
issue.CommandId = "issue-explore";
|
||||
issue.AgentTask = new AetheriaRuntimeAgentTaskCommand
|
||||
{
|
||||
TaskId = "explore-east",
|
||||
CorporationKey = "workers",
|
||||
TaskType = AetheriaRuntimeAgentTaskTypes.Explore,
|
||||
Priority = 50,
|
||||
ZoneIndex = 0,
|
||||
TargetPositionX = 50,
|
||||
TargetPositionZ = 0,
|
||||
CompletionRadius = 5
|
||||
};
|
||||
var completed = false;
|
||||
for (var frame = 0; frame <= 20; frame++)
|
||||
{
|
||||
var tick = AetheriaRuntimeDaemonTickRunner.Tick(
|
||||
Path.Combine(Path.GetTempPath(), "aetheria-agent-task-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
|
||||
});
|
||||
if (frame == 0)
|
||||
{
|
||||
Require(tick.OperationResult.AppliedCommandIds.Contains("issue-explore"),
|
||||
"commander task command must enter the normal tick reducer");
|
||||
Require(tick.OperationResult.AppliedCommandIds.Any(id => id.Contains(":explore-east:0:move", StringComparison.Ordinal)),
|
||||
"agent movement must return through the same command receipts");
|
||||
}
|
||||
completed = string.Equals(run.AgentTasks.Single().Status, AetheriaRuntimeAgentTaskStatuses.Completed, StringComparison.Ordinal);
|
||||
if (completed)
|
||||
break;
|
||||
}
|
||||
|
||||
Require(completed, "agent must complete an explore task without direct position mutation");
|
||||
Require(string.IsNullOrWhiteSpace(agent.AssignedAgentTaskId), "completed task must release the agent");
|
||||
Require(agent.PositionX >= 45, "agent must reach the task through repeated movement commands");
|
||||
|
||||
var frameDocument = new AetheriaRuntimeDaemonFrameDocument { FrameId = 21, Run = run };
|
||||
var commander = AetheriaRuntimeDaemonGameSurfaceBuilder.BuildCommander(
|
||||
frameDocument,
|
||||
new AetheriaRuntimeDaemonHealthDocument(),
|
||||
AetheriaRuntimeDaemonCommandBoundaryDocument.Create("agent-task-smoke"));
|
||||
var taskNode = Flatten(commander.Surface.Root)
|
||||
.Single(component => string.Equals(component.Id, "aetheria.starbridge.commander.tasks.explore_east", StringComparison.Ordinal));
|
||||
RequireEqual(AetheriaRuntimeAgentTaskStatuses.Completed, taskNode.Props["status"],
|
||||
"commander Eve surface must publish authoritative task status");
|
||||
Require(commander.Commands.Any(command => string.Equals(command.Command, "aetheria.daemon.issue_agent_task", StringComparison.Ordinal)),
|
||||
"commander Eve surface must advertise task issue command");
|
||||
}
|
||||
|
||||
private static void MultipleActorsUseTheSameMovementLever()
|
||||
|
|
@ -224,6 +332,14 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
private static double GridValue(AetheriaRuntimeEntitySnapshotCommit entity, string name, int index) =>
|
||||
entity.StatGrids.Single(grid => string.Equals(grid.Name, name, StringComparison.OrdinalIgnoreCase)).Values[index];
|
||||
|
||||
private static IEnumerable<AetheriaRuntimeSurfaceComponent> Flatten(AetheriaRuntimeSurfaceComponent root)
|
||||
{
|
||||
yield return root;
|
||||
foreach (var child in root.Children)
|
||||
foreach (var descendant in Flatten(child))
|
||||
yield return descendant;
|
||||
}
|
||||
|
||||
private static double Stat(AetheriaRuntimeEntitySnapshotCommit entity, string name) =>
|
||||
entity.StatGrids.Single(grid => string.Equals(grid.Name, name, StringComparison.OrdinalIgnoreCase)).Values[0];
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,217 @@
|
|||
using MessagePack;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace GameCult.Aetheria.State.Verse
|
||||
{
|
||||
public static class AetheriaRuntimeAgentTaskTypes
|
||||
{
|
||||
public const string Mine = "mine";
|
||||
public const string Haul = "haul";
|
||||
public const string Tow = "tow";
|
||||
public const string Defend = "defend";
|
||||
public const string Attack = "attack";
|
||||
public const string Explore = "explore";
|
||||
|
||||
public static readonly IReadOnlyList<string> All =
|
||||
new[] { Mine, Haul, Tow, Defend, Attack, Explore };
|
||||
}
|
||||
|
||||
public static class AetheriaRuntimeAgentTaskStatuses
|
||||
{
|
||||
public const string Queued = "queued";
|
||||
public const string Assigned = "assigned";
|
||||
public const string Completed = "completed";
|
||||
public const string Cancelled = "cancelled";
|
||||
public const string Failed = "failed";
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaRuntimeAgentTaskCommit
|
||||
{
|
||||
[Key(0)] public string TaskId { get; set; } = "";
|
||||
[Key(1)] public string CorporationKey { get; set; } = "";
|
||||
[Key(2)] public string TaskType { get; set; } = "";
|
||||
[Key(3)] public int Priority { get; set; }
|
||||
[Key(4)] public int ZoneIndex { get; set; } = -1;
|
||||
[Key(5)] public string Status { get; set; } = AetheriaRuntimeAgentTaskStatuses.Queued;
|
||||
[Key(6)] public int AssignedEntityIndex { get; set; } = -1;
|
||||
[Key(7)] public int TargetEntityIndex { get; set; } = -1;
|
||||
[Key(8)] public double TargetPositionX { get; set; }
|
||||
[Key(9)] public double TargetPositionZ { get; set; }
|
||||
[Key(10)] public double CompletionRadius { get; set; } = 10;
|
||||
[Key(11)] public int WeaponGroup { get; set; }
|
||||
[Key(12)] public long AssignedFrameId { get; set; } = -1;
|
||||
[Key(13)] public long CompletedFrameId { get; set; } = -1;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaRuntimeAgentTaskCommand
|
||||
{
|
||||
[Key(0)] public string TaskId { get; set; } = "";
|
||||
[Key(1)] public string CorporationKey { get; set; } = "";
|
||||
[Key(2)] public string TaskType { get; set; } = "";
|
||||
[Key(3)] public int Priority { get; set; }
|
||||
[Key(4)] public int ZoneIndex { get; set; } = -1;
|
||||
[Key(5)] public int TargetEntityIndex { get; set; } = -1;
|
||||
[Key(6)] public double TargetPositionX { get; set; }
|
||||
[Key(7)] public double TargetPositionZ { get; set; }
|
||||
[Key(8)] public double CompletionRadius { get; set; } = 10;
|
||||
[Key(9)] public int WeaponGroup { get; set; }
|
||||
}
|
||||
|
||||
public static class AetheriaRuntimeAgentScheduler
|
||||
{
|
||||
public const string RuntimeId = "aetheria.daemon.agent-scheduler";
|
||||
|
||||
public static IReadOnlyList<AetheriaRuntimeDaemonCommandDocument> AssignAndPlan(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
long frameId)
|
||||
{
|
||||
if (run == null)
|
||||
return Array.Empty<AetheriaRuntimeDaemonCommandDocument>();
|
||||
|
||||
ReleaseInvalidAssignments(run);
|
||||
AssignQueuedTasks(run, frameId);
|
||||
return PlanAssignedTasks(run, frameId);
|
||||
}
|
||||
|
||||
private static void AssignQueuedTasks(AetheriaRuntimeRunCheckpointCommit run, long frameId)
|
||||
{
|
||||
var tasks = (run.AgentTasks ?? Array.Empty<AetheriaRuntimeAgentTaskCommit>()).Where(task => task != null).ToArray();
|
||||
var entities = (run.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>())
|
||||
.Where(zone => zone != null)
|
||||
.SelectMany(zone => (zone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
|
||||
.Where(entity => entity != null)
|
||||
.Select(entity => (zone.ZoneIndex, Entity: entity)))
|
||||
.ToArray();
|
||||
|
||||
foreach (var corporation in tasks
|
||||
.Where(task => string.Equals(task.Status, AetheriaRuntimeAgentTaskStatuses.Queued, StringComparison.Ordinal))
|
||||
.GroupBy(task => task.CorporationKey ?? "", StringComparer.Ordinal))
|
||||
foreach (var typeAndZone in corporation.GroupBy(task => (TaskType: task.TaskType ?? "", task.ZoneIndex)))
|
||||
{
|
||||
var available = entities
|
||||
.Where(pair => pair.Entity.IsActive && string.IsNullOrWhiteSpace(pair.Entity.AssignedAgentTaskId))
|
||||
.Where(pair => string.Equals(pair.Entity.FactionKey ?? "", corporation.Key, StringComparison.Ordinal))
|
||||
.Where(pair => pair.ZoneIndex == typeAndZone.Key.ZoneIndex)
|
||||
.Where(pair => (pair.Entity.AgentTaskCapabilities ?? Array.Empty<string>()).Contains(typeAndZone.Key.TaskType, StringComparer.Ordinal))
|
||||
.OrderBy(pair => pair.ZoneIndex)
|
||||
.ThenBy(pair => pair.Entity.EntityIndex)
|
||||
.ToArray();
|
||||
var orderedTasks = typeAndZone.OrderByDescending(task => task.Priority).ThenBy(task => task.TaskId, StringComparer.Ordinal);
|
||||
foreach (var assignment in orderedTasks.Zip(available, (task, agent) => (task, agent)))
|
||||
{
|
||||
assignment.task.Status = AetheriaRuntimeAgentTaskStatuses.Assigned;
|
||||
assignment.task.AssignedEntityIndex = assignment.agent.Entity.EntityIndex;
|
||||
assignment.task.AssignedFrameId = frameId;
|
||||
assignment.agent.Entity.AssignedAgentTaskId = assignment.task.TaskId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IReadOnlyList<AetheriaRuntimeDaemonCommandDocument> PlanAssignedTasks(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
long frameId)
|
||||
{
|
||||
var commands = new List<AetheriaRuntimeDaemonCommandDocument>();
|
||||
foreach (var task in (run.AgentTasks ?? Array.Empty<AetheriaRuntimeAgentTaskCommit>())
|
||||
.Where(task => task != null && string.Equals(task.Status, AetheriaRuntimeAgentTaskStatuses.Assigned, StringComparison.Ordinal)))
|
||||
{
|
||||
var zone = (run.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>())
|
||||
.FirstOrDefault(candidate => candidate != null && candidate.ZoneIndex == task.ZoneIndex);
|
||||
var agent = zone?.Entities?.FirstOrDefault(entity => entity != null && entity.EntityIndex == task.AssignedEntityIndex);
|
||||
if (agent == null || !agent.IsActive)
|
||||
continue;
|
||||
|
||||
var target = task.TargetEntityIndex < 0
|
||||
? null
|
||||
: zone!.Entities.FirstOrDefault(entity => entity != null && entity.EntityIndex == task.TargetEntityIndex);
|
||||
var targetX = target?.PositionX ?? task.TargetPositionX;
|
||||
var targetZ = target?.PositionZ ?? task.TargetPositionZ;
|
||||
var dx = targetX - agent.PositionX;
|
||||
var dz = targetZ - agent.PositionZ;
|
||||
var distance = Math.Sqrt(dx * dx + dz * dz);
|
||||
if (distance <= Math.Max(0.01, task.CompletionRadius) &&
|
||||
!string.Equals(task.TaskType, AetheriaRuntimeAgentTaskTypes.Attack, StringComparison.Ordinal))
|
||||
{
|
||||
Complete(task, agent, frameId);
|
||||
commands.Add(Movement(task, agent, frameId, 0, 0, 0));
|
||||
continue;
|
||||
}
|
||||
|
||||
var magnitude = distance <= 0.0001 ? 0 : 1;
|
||||
commands.Add(Movement(task, agent, frameId, dx, dz, magnitude));
|
||||
if (string.Equals(task.TaskType, AetheriaRuntimeAgentTaskTypes.Attack, StringComparison.Ordinal) && target != null)
|
||||
{
|
||||
commands.Add(Command(task, agent, frameId, AetheriaRuntimeDaemonCommandKinds.SetTarget, "target", command =>
|
||||
command.TargetEntityKey = EntityKey(run, task.ZoneIndex, target.EntityIndex)));
|
||||
commands.Add(Command(task, agent, frameId, AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup, "fire", command =>
|
||||
command.WeaponGroup = Math.Max(0, task.WeaponGroup)));
|
||||
}
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeDaemonCommandDocument Movement(
|
||||
AetheriaRuntimeAgentTaskCommit task,
|
||||
AetheriaRuntimeEntitySnapshotCommit agent,
|
||||
long frameId,
|
||||
double dx,
|
||||
double dz,
|
||||
double magnitude)
|
||||
{
|
||||
return Command(task, agent, frameId, AetheriaRuntimeDaemonCommandKinds.SetMoveVector, "move", command =>
|
||||
{
|
||||
var length = Math.Sqrt(dx * dx + dz * dz);
|
||||
command.DirectionX = length <= 0.0001 ? 0 : dx / length;
|
||||
command.DirectionY = length <= 0.0001 ? 0 : dz / length;
|
||||
command.ScalarValue = magnitude;
|
||||
});
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeDaemonCommandDocument Command(
|
||||
AetheriaRuntimeAgentTaskCommit task,
|
||||
AetheriaRuntimeEntitySnapshotCommit agent,
|
||||
long frameId,
|
||||
AetheriaRuntimeDaemonCommandKinds kind,
|
||||
string phase,
|
||||
Action<AetheriaRuntimeDaemonCommandDocument> configure)
|
||||
{
|
||||
var actor = $"zone.{task.ZoneIndex}.entity.{agent.EntityIndex}";
|
||||
var command = AetheriaRuntimeDaemonCommandDocument.Create(kind, RuntimeId, "daemon-agent-scheduler", frameId, actor);
|
||||
command.CommandId = string.Join(":", RuntimeId, task.TaskId, frameId.ToString(CultureInfo.InvariantCulture), phase);
|
||||
configure(command);
|
||||
return command;
|
||||
}
|
||||
|
||||
private static void Complete(AetheriaRuntimeAgentTaskCommit task, AetheriaRuntimeEntitySnapshotCommit agent, long frameId)
|
||||
{
|
||||
task.Status = AetheriaRuntimeAgentTaskStatuses.Completed;
|
||||
task.CompletedFrameId = frameId;
|
||||
agent.AssignedAgentTaskId = "";
|
||||
}
|
||||
|
||||
private static void ReleaseInvalidAssignments(AetheriaRuntimeRunCheckpointCommit run)
|
||||
{
|
||||
var activeTaskIds = (run.AgentTasks ?? Array.Empty<AetheriaRuntimeAgentTaskCommit>())
|
||||
.Where(task => task != null && string.Equals(task.Status, AetheriaRuntimeAgentTaskStatuses.Assigned, StringComparison.Ordinal))
|
||||
.Select(task => task.TaskId)
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
foreach (var entity in (run.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>())
|
||||
.Where(zone => zone != null)
|
||||
.SelectMany(zone => zone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>()))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(entity.AssignedAgentTaskId) && !activeTaskIds.Contains(entity.AssignedAgentTaskId))
|
||||
entity.AssignedAgentTaskId = "";
|
||||
}
|
||||
}
|
||||
|
||||
private static string EntityKey(AetheriaRuntimeRunCheckpointCommit run, int zoneIndex, int entityIndex) =>
|
||||
AetheriaRuntimeRunCheckpointCommit.EntityRecordKey(run.RunId, zoneIndex, entityIndex);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f9ad0b6b39cf40bf951dd16f17502991
|
||||
|
|
@ -192,7 +192,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
SetOverrideShutdown,
|
||||
SetHeatsinksEnabled,
|
||||
SetShutdownPerformance,
|
||||
ToggleShieldEnabled
|
||||
ToggleShieldEnabled,
|
||||
IssueAgentTask,
|
||||
CancelAgentTask
|
||||
}
|
||||
|
||||
[CultDocument("gamecult.aetheria.daemon_provider_advertisement", "gamecult.aetheria.daemon_provider_advertisement.v1")]
|
||||
|
|
@ -661,6 +663,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
[Key(29)]
|
||||
public string ClaimKind { get; set; } = "";
|
||||
|
||||
[Key(30)]
|
||||
public AetheriaRuntimeAgentTaskCommand AgentTask { get; set; } = new AetheriaRuntimeAgentTaskCommand();
|
||||
|
||||
public static AetheriaRuntimeDaemonCommandDocument Create(
|
||||
AetheriaRuntimeDaemonCommandKinds kind,
|
||||
string clientId,
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var root = SurfaceRoot(
|
||||
"aetheria.starbridge.commander.root",
|
||||
StrategicWorldSurface("aetheria.starbridge.commander.world", run, zone),
|
||||
BuildAgentTaskBoard(run),
|
||||
BuildStarbridgeStationStockCard(starbridge),
|
||||
BuildStarbridgeWaveForecastCard(starbridge),
|
||||
BuildStarbridgeRuntimeRolesCard(starbridge));
|
||||
|
|
@ -153,9 +154,61 @@ namespace GameCult.Aetheria.State.Verse
|
|||
AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandName(entry.Kind),
|
||||
AetheriaRuntimeDaemonSurfaceCommandCatalog.Label(entry.Kind),
|
||||
"cultmesh"))
|
||||
.Concat(new[]
|
||||
{
|
||||
new AetheriaRuntimeSurfaceCommandTemplate("aetheria.daemon.issue_agent_task", "Issue Task", "cultmesh"),
|
||||
new AetheriaRuntimeSurfaceCommandTemplate("aetheria.daemon.cancel_agent_task", "Cancel Task", "cultmesh")
|
||||
})
|
||||
.ToArray());
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent BuildAgentTaskBoard(AetheriaRuntimeRunCheckpointCommit run)
|
||||
{
|
||||
var tasks = (run.AgentTasks ?? Array.Empty<AetheriaRuntimeAgentTaskCommit>())
|
||||
.Where(task => task != null)
|
||||
.OrderBy(task => TaskStatusOrder(task.Status))
|
||||
.ThenByDescending(task => task.Priority)
|
||||
.ThenBy(task => task.TaskId, StringComparer.Ordinal)
|
||||
.Select(task => Node(
|
||||
$"aetheria.starbridge.commander.tasks.{SurfaceToken(task.TaskId)}",
|
||||
"list.item",
|
||||
new[]
|
||||
{
|
||||
("label", task.TaskType),
|
||||
("taskId", task.TaskId),
|
||||
("corporation", task.CorporationKey),
|
||||
("status", task.Status),
|
||||
("priority", task.Priority.ToString(CultureInfo.InvariantCulture)),
|
||||
("zoneIndex", task.ZoneIndex.ToString(CultureInfo.InvariantCulture)),
|
||||
("assignedEntityIndex", task.AssignedEntityIndex.ToString(CultureInfo.InvariantCulture)),
|
||||
("targetEntityIndex", task.TargetEntityIndex.ToString(CultureInfo.InvariantCulture)),
|
||||
("targetPosition", string.Join(",", new[]
|
||||
{
|
||||
task.TargetPositionX.ToString("0.###", CultureInfo.InvariantCulture),
|
||||
task.TargetPositionZ.ToString("0.###", CultureInfo.InvariantCulture)
|
||||
})),
|
||||
("cancelCommand", "aetheria.daemon.cancel_agent_task")
|
||||
}))
|
||||
.ToArray();
|
||||
return Node(
|
||||
"aetheria.starbridge.commander.tasks",
|
||||
"list",
|
||||
new[]
|
||||
{
|
||||
("title", "Orders"),
|
||||
("issueCommand", "aetheria.daemon.issue_agent_task"),
|
||||
("taskTypes", string.Join(",", AetheriaRuntimeAgentTaskTypes.All))
|
||||
},
|
||||
tasks);
|
||||
}
|
||||
|
||||
private static int TaskStatusOrder(string status) =>
|
||||
string.Equals(status, AetheriaRuntimeAgentTaskStatuses.Assigned, StringComparison.Ordinal) ? 0 :
|
||||
string.Equals(status, AetheriaRuntimeAgentTaskStatuses.Queued, StringComparison.Ordinal) ? 1 : 2;
|
||||
|
||||
private static string SurfaceToken(string value) => new string(
|
||||
(value ?? "").Select(character => char.IsLetterOrDigit(character) ? character : '_').ToArray());
|
||||
|
||||
private static AetheriaRuntimeSurfaceComponent StrategicWorldSurface(
|
||||
string id,
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
|
|
|
|||
|
|
@ -571,5 +571,28 @@ namespace GameCult.Aetheria.State.Verse
|
|||
command.StoreItem.HasDestinationPosition = hasDestinationPosition;
|
||||
return Send(command);
|
||||
}
|
||||
|
||||
internal AetheriaRuntimeDaemonCommandEnvelope IssueAgentTask(
|
||||
AetheriaRuntimeDaemonFrameDocument? frame,
|
||||
AetheriaRuntimeAgentTaskCommand task)
|
||||
{
|
||||
task ??= new AetheriaRuntimeAgentTaskCommand();
|
||||
var command = Create(AetheriaRuntimeDaemonCommandKinds.IssueAgentTask, frame);
|
||||
command.AgentTask = task;
|
||||
command.SubjectKey = string.IsNullOrWhiteSpace(task.CorporationKey)
|
||||
? "aetheria.tasks"
|
||||
: $"aetheria.tasks.{task.CorporationKey}";
|
||||
return Send(command);
|
||||
}
|
||||
|
||||
internal AetheriaRuntimeDaemonCommandEnvelope CancelAgentTask(
|
||||
AetheriaRuntimeDaemonFrameDocument? frame,
|
||||
string taskId)
|
||||
{
|
||||
var command = Create(AetheriaRuntimeDaemonCommandKinds.CancelAgentTask, frame);
|
||||
command.AgentTask.TaskId = taskId ?? "";
|
||||
command.SubjectKey = "aetheria.tasks";
|
||||
return Send(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,11 +176,82 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return ApplyEnterWormholeIntent(run, command, context.Intents);
|
||||
case AetheriaRuntimeDaemonCommandKinds.TowToStation:
|
||||
return ApplyTowToStationIntent(run, command, context.Intents);
|
||||
case AetheriaRuntimeDaemonCommandKinds.IssueAgentTask:
|
||||
return ApplyIssueAgentTask(run, command);
|
||||
case AetheriaRuntimeDaemonCommandKinds.CancelAgentTask:
|
||||
return ApplyCancelAgentTask(run, command);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ApplyIssueAgentTask(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeDaemonCommandDocument command)
|
||||
{
|
||||
var request = command.AgentTask ?? new AetheriaRuntimeAgentTaskCommand();
|
||||
var taskId = string.IsNullOrWhiteSpace(request.TaskId) ? command.CommandId : request.TaskId;
|
||||
var taskType = (request.TaskType ?? "").Trim().ToLowerInvariant();
|
||||
if (string.IsNullOrWhiteSpace(taskId) ||
|
||||
string.IsNullOrWhiteSpace(request.CorporationKey) ||
|
||||
!AetheriaRuntimeAgentTaskTypes.All.Contains(taskType, StringComparer.Ordinal) ||
|
||||
request.ZoneIndex < 0 ||
|
||||
!(run.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>()).Any(zone =>
|
||||
zone != null && zone.ZoneIndex == request.ZoneIndex) ||
|
||||
(run.AgentTasks ?? Array.Empty<AetheriaRuntimeAgentTaskCommit>()).Any(task =>
|
||||
task != null && string.Equals(task.TaskId, taskId, StringComparison.Ordinal)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
run.AgentTasks = (run.AgentTasks ?? Array.Empty<AetheriaRuntimeAgentTaskCommit>())
|
||||
.Concat(new[]
|
||||
{
|
||||
new AetheriaRuntimeAgentTaskCommit
|
||||
{
|
||||
TaskId = taskId,
|
||||
CorporationKey = request.CorporationKey ?? "",
|
||||
TaskType = taskType,
|
||||
Priority = request.Priority,
|
||||
ZoneIndex = request.ZoneIndex,
|
||||
TargetEntityIndex = request.TargetEntityIndex,
|
||||
TargetPositionX = request.TargetPositionX,
|
||||
TargetPositionZ = request.TargetPositionZ,
|
||||
CompletionRadius = request.CompletionRadius > 0 ? request.CompletionRadius : 10,
|
||||
WeaponGroup = request.WeaponGroup,
|
||||
Status = AetheriaRuntimeAgentTaskStatuses.Queued
|
||||
}
|
||||
})
|
||||
.ToArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool ApplyCancelAgentTask(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeDaemonCommandDocument command)
|
||||
{
|
||||
var taskId = command.AgentTask?.TaskId ?? command.TextValue ?? "";
|
||||
var task = (run.AgentTasks ?? Array.Empty<AetheriaRuntimeAgentTaskCommit>())
|
||||
.FirstOrDefault(candidate => candidate != null && string.Equals(candidate.TaskId, taskId, StringComparison.Ordinal));
|
||||
if (task == null ||
|
||||
string.Equals(task.Status, AetheriaRuntimeAgentTaskStatuses.Completed, StringComparison.Ordinal) ||
|
||||
string.Equals(task.Status, AetheriaRuntimeAgentTaskStatuses.Cancelled, StringComparison.Ordinal))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var entity in (run.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>())
|
||||
.Where(zone => zone != null)
|
||||
.SelectMany(zone => zone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>()))
|
||||
{
|
||||
if (string.Equals(entity.AssignedAgentTaskId, task.TaskId, StringComparison.Ordinal))
|
||||
entity.AssignedAgentTaskId = "";
|
||||
}
|
||||
task.Status = AetheriaRuntimeAgentTaskStatuses.Cancelled;
|
||||
task.AssignedEntityIndex = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool ApplySetTarget(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeDaemonCommandDocument command)
|
||||
|
|
|
|||
|
|
@ -92,6 +92,16 @@ public sealed class AetheriaRuntimeDaemonOperationsClient
|
|||
return Submit((client, frame) => client.SetMoveVector(frame, directionX, directionY, scalarValue));
|
||||
}
|
||||
|
||||
public AetheriaRuntimeDaemonCommandEnvelope IssueAgentTask(AetheriaRuntimeAgentTaskCommand task)
|
||||
{
|
||||
return Submit((client, frame) => client.IssueAgentTask(frame, task));
|
||||
}
|
||||
|
||||
public AetheriaRuntimeDaemonCommandEnvelope CancelAgentTask(string taskId)
|
||||
{
|
||||
return Submit((client, frame) => client.CancelAgentTask(frame, taskId));
|
||||
}
|
||||
|
||||
public CultMeshOperationReceipt SetLookDirection(double directionX, double directionY, double directionZ)
|
||||
{
|
||||
return Send((client, frame) => client.SetLookDirection(frame, directionX, directionY, directionZ));
|
||||
|
|
@ -484,6 +494,24 @@ public sealed class AetheriaRuntimeDaemonOperationsClient
|
|||
AetheriaRuntimeDaemonCommandKinds.SetTarget => client.SetTarget(
|
||||
frame,
|
||||
ReadPayloadString(request, "targetEntityId", ReadPayloadString(request, "entityId", ""))),
|
||||
AetheriaRuntimeDaemonCommandKinds.IssueAgentTask => client.IssueAgentTask(
|
||||
frame,
|
||||
new AetheriaRuntimeAgentTaskCommand
|
||||
{
|
||||
TaskId = ReadPayloadString(request, "taskId", ""),
|
||||
CorporationKey = ReadPayloadString(request, "corporation", ""),
|
||||
TaskType = ReadPayloadString(request, "taskType", ""),
|
||||
Priority = (int)ReadPayloadDouble(request, "priority", 0),
|
||||
ZoneIndex = (int)ReadPayloadDouble(request, "zoneIndex", -1),
|
||||
TargetEntityIndex = (int)ReadPayloadDouble(request, "targetEntityIndex", -1),
|
||||
TargetPositionX = ReadPayloadDouble(request, "targetPositionX", 0),
|
||||
TargetPositionZ = ReadPayloadDouble(request, "targetPositionZ", 0),
|
||||
CompletionRadius = ReadPayloadDouble(request, "completionRadius", 10),
|
||||
WeaponGroup = (int)ReadPayloadDouble(request, "weaponGroup", 0)
|
||||
}),
|
||||
AetheriaRuntimeDaemonCommandKinds.CancelAgentTask => client.CancelAgentTask(
|
||||
frame,
|
||||
ReadPayloadString(request, "taskId", "")),
|
||||
_ => AetheriaRuntimeDaemonSurfaceCommandCatalog.TrySubmitArgumentless(
|
||||
client,
|
||||
frame,
|
||||
|
|
|
|||
|
|
@ -133,6 +133,19 @@ namespace GameCult.Aetheria.State.Verse
|
|||
.ToArray(),
|
||||
operationResult.Intents);
|
||||
}
|
||||
var agentCommands = AetheriaRuntimeAgentScheduler.AssignAndPlan(operationResult.Run, options.FrameId);
|
||||
if (agentCommands.Count > 0)
|
||||
{
|
||||
var agentResult = AetheriaRuntimeDaemonOperations.Execute(
|
||||
operationResult.Run,
|
||||
agentCommands,
|
||||
options.OperationContext);
|
||||
operationResult = new AetheriaRuntimeDaemonOperationResult(
|
||||
agentResult.Run,
|
||||
operationResult.AppliedCommandIds.Concat(agentResult.AppliedCommandIds).ToArray(),
|
||||
operationResult.RejectedCommandIds.Concat(agentResult.RejectedCommandIds).ToArray(),
|
||||
agentResult.Intents);
|
||||
}
|
||||
AetheriaRuntimeDaemonSimulation.Step(
|
||||
operationResult.Run,
|
||||
operationResult.Intents,
|
||||
|
|
|
|||
|
|
@ -195,6 +195,10 @@ namespace GameCult.Aetheria.State.Verse
|
|||
[Key(11)]
|
||||
public int Credits { get; set; }
|
||||
|
||||
[Key(12)]
|
||||
public IReadOnlyList<AetheriaRuntimeAgentTaskCommit> AgentTasks { get; set; } =
|
||||
Array.Empty<AetheriaRuntimeAgentTaskCommit>();
|
||||
|
||||
public AetheriaRuntimeLoadoutTemplateCommit CreateLoadoutTemplate(string entityKey)
|
||||
{
|
||||
return TryParseEntityKey(entityKey, out var zoneIndex, out var entityIndex)
|
||||
|
|
@ -899,6 +903,12 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
[Key(37)]
|
||||
public double ShutdownPerformance { get; set; }
|
||||
|
||||
[Key(38)]
|
||||
public IReadOnlyList<string> AgentTaskCapabilities { get; set; } = Array.Empty<string>();
|
||||
|
||||
[Key(39)]
|
||||
public string AssignedAgentTaskId { get; set; } = "";
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
|
|
@ -309,6 +309,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return AetheriaRuntimeClaimKinds.Metadata;
|
||||
case AetheriaRuntimeDaemonCommandKinds.DestroyEntity:
|
||||
return AetheriaRuntimeClaimKinds.System;
|
||||
case AetheriaRuntimeDaemonCommandKinds.IssueAgentTask:
|
||||
case AetheriaRuntimeDaemonCommandKinds.CancelAgentTask:
|
||||
return AetheriaRuntimeClaimKinds.Ai;
|
||||
case AetheriaRuntimeDaemonCommandKinds.Interact:
|
||||
case AetheriaRuntimeDaemonCommandKinds.SetDockedCurrentShip:
|
||||
return AetheriaRuntimeClaimKinds.Interaction;
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
|
|||
| Assets | `Assets/Resources` | Aetheria provider | asset catalog + CultMesh CDN | runtime cache/load | wired; basic lowering; not live-proven remotely | cold/warm remote-only live load and cache proof |
|
||||
| Save/resume | original persistence paths | daemon/CultCache | published current state | clients rehydrate | owner-exists; not parity-proven | mid-loop restart |
|
||||
| Terminus loop | original game composition | daemon/Ymir/Eve | pilot surface | Aetheria.Unity | incomplete; no scenario proof | fly/fire/loot/dock/trade |
|
||||
| Starbridge | original/shared architecture intent | one daemon session | pilot + commander surfaces | Unity + Electron | incomplete; split-target proof missing | commander plus four pilots |
|
||||
| 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 | agent state/task framework | daemon | observable intent/state only | no decision authority | reference | combat range control and civilian tasks |
|
||||
| AI/tasks | corporation task scheduler plus agent state machines | daemon | commander task board and shared semantic controls | Eve commander/pilot clients | explore task queue, capability/priority assignment, and shared-command execution wired; remaining task families reference | combat range control, mine/haul/tow/defend/attack 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
|
||||
|
|
|
|||
|
|
@ -94,6 +94,15 @@ towing, survey, and wandering.
|
|||
AI reads the same contacts, behavior graph, physics, and command primitives as
|
||||
players. It does not use privileged damage or movement shortcuts.
|
||||
|
||||
The original corporation scheduler is preserved in commit `ab8aa5fb`,
|
||||
`ServerShared/GameContext.cs`. For each corporation it filters unreserved
|
||||
tasks, groups them by task type, discards groups with no compatible available
|
||||
controller, orders jobs by descending priority, zips them with compatible
|
||||
controllers, flattens the assignments, reserves each task, and calls the
|
||||
controller's ordinary `AssignTask` entry point. The daemon scheduler must retain
|
||||
that queue/capability/priority/availability contract. Assignment state is
|
||||
durable; task execution drives the same semantic controls used by players.
|
||||
|
||||
## Quality And Progression
|
||||
|
||||
Crafted items carry continuous quality. Quality changes performance, durability
|
||||
|
|
@ -107,9 +116,10 @@ contacts, impulses, projectile trajectories, and spatial placement candidates.
|
|||
The daemon owns equipment interpretation, accepted controls, resource costs,
|
||||
damage meaning, lifecycle, inventory, and persistence.
|
||||
|
||||
The current Aetheria-local `AetheriaRuntimeYmirProjectilePhysics` does not call
|
||||
standalone `Ymir.Core`; it is migration scaffolding, not completion of this
|
||||
boundary.
|
||||
Daemon projectile integration and contact detection now call standalone
|
||||
`Ymir.Core`. Ship flight, gravity, tractor interaction, docking placement, and
|
||||
the remaining Unity query bridge still need to enter that same world before
|
||||
the boundary is complete.
|
||||
|
||||
## Simulation Pipeline
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue