-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.m
42 lines (34 loc) · 1.06 KB
/
tests.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
% tests for reward
% test that there is no crash
state = [nan 1 nan; -9 0 0]; % same lane, car is behind, same velocity
action = [0 0]; %stay in this position
reward = calcReward(state, action);
assert(reward == 0);
% test right before bumper, no crash
state = [nan 1 nan; -6 0 0]; % same lane, car is right behind, same velocity
reward = calcReward(state, action);
assert(reward == 0);
%test bumper crash
state = [nan 1 nan; -5 0 0]; % same lane, car is right behind, same velocity
reward = calcReward(state, action);
assert(reward == -100);
%test no crash after action
state = [nan 1 nan; -11 0 0];
action = [0 1];
reward = calcReward(state, action);
assert(reward == 2);
%test no crash after action
state = [nan 1 nan; -8 0 0];
action = [0 1];
reward = calcReward(state, action);
assert(reward == 2);
%test bumper crash after action
state = [nan 1 nan; -7 0 0];
action = [0 1];
reward = calcReward(state, action);
assert(reward == -98);
%test overpass crash after action
state = [nan 1 nan; -9 0 0];
action = [0 9];
reward = calcReward(state, action);
assert(reward == -82);