-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimulation.m
46 lines (38 loc) · 1.1 KB
/
simulation.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
% simulation
% set deboarding agents on the doorpoint
for iagent = 1:agentcount
if agent(iagent, agentSTATE) == agentSTATEdeboarding
agent(iagent, [agentXPOS, agentYPOS]) = door(agent(iagent, agentLDOOR), [doorXPOS, doorYPOS]);
end
stat_start_position(iagent, :) = agent(iagent, [agentXPOS, agentYPOS]);
end
%timestep iteration
for step = 1:stepcount
t = step*dt;
if t <= DOORS_DELAY
train_entrance;
end
% random order for agents
order = randperm(agentcount);
doordecision_frequency;
% decrement door state ("blocking" time)
door(:,doorSTATE) = door(:,doorSTATE) - dt*ones(doorcount,1);
calculate_distances;
for i = 1:agentcount
iagent = order(i);
% people update in random order (board, deboard, status change)
agent_update
if agent(iagent, agentSTATE) == agentSTATEmoving
door_decision;
calculate_forces;
end
end
% move agents simultaneously
move_agents
% draw
paint
video_capture
pause(0.02)
save_data
data_export
end