-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathagent_seat_search.m
47 lines (43 loc) · 1.22 KB
/
agent_seat_search.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
47
% tries to find a free seat for iagent starting from its current chosen
% door
% important note: this file is specifically designed for the two train
% station layouts and needs to be updated if any door-configuration gets
% changed
free_seat_found = 0;
% making szenario-specific-separations
if simulation_mode == simulationMODEonetrain
if cdoor <= 2
free_seat_found = 1;
return;
end
% each door of second class coach and bistro wagon
ctrain = 1;
if (cdoor <= 9)
ccoach = (cdoor - mod(cdoor+1,2) - 1) / 2;
% first class coaches
else
ccoach = (cdoor - mod(cdoor,2)) / 2;
end
end
if simulation_mode == simulationMODEtwotrains
if cdoor <= 3
free_seat_found = 1;
return;
end
% each door of second class coach and bistro wagon
if (cdoor <= 10)
ctrain = 1;
ccoach = (cdoor - mod(cdoor,2) - 2) / 2;
% first class coaches
elseif (cdoor <= 14)
ctrain = 1;
ccoach = (cdoor - mod(cdoor+1,2) -1) / 2;
elseif (cdoor <= 21)
ctrain = 2;
ccoach = (cdoor - mod(cdoor+1,2) -1) / 2 - 6;
else
ctrain = 2;
ccoach = (cdoor - mod(cdoor,2)) / 2 - 6;
end
end
coach_seat_search;