added agent position trail to plot

This commit is contained in:
2026-01-01 16:06:19 -08:00
parent 4735c2b77b
commit c59b96f547
7 changed files with 61 additions and 9 deletions

View File

@@ -28,6 +28,7 @@ function obj = initialize(obj, domain, objective, agents, minAlt, timestep, part
% Define simulation time parameters
obj.timestep = timestep;
obj.timestepIndex = 0;
obj.maxIter = maxIter - 1;
% Define domain
@@ -66,6 +67,10 @@ function obj = initialize(obj, domain, objective, agents, minAlt, timestep, part
% Create initial partitioning
obj = obj.partition();
% Initialize variable that will store agent positions for trail plots
obj.posHist = NaN(size(obj.agents, 1), obj.maxIter + 1, 3);
obj.posHist(1:size(obj.agents, 1), 1, 1:3) = reshape(cell2mat(cellfun(@(x) x.pos, obj.agents, 'UniformOutput', false)), size(obj.agents, 1), 1, 3);
% Set up plots showing initialized state
obj = obj.plot();
end