-
Notifications
You must be signed in to change notification settings - Fork 0
/
reward_example.py
41 lines (31 loc) · 1.09 KB
/
reward_example.py
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
def reward_function(params):
center_variance = params["distance_from_center"] / params["track_width"]
left_lane = []#Fill in the waypoints
center_lane = []#Fill in the waypoints
right_lane = []#Fill in the waypoints
fast = []#Fill in the waypoints
slow = []#Fill in the waypoints
reward = 21
if params["all_wheels_on_track"]:
reward += 10
else:
reward -= 10
if params["closest_waypoints"][1] in left_lane and params["is_left_of_center"]:
reward += 10
elif params["closest_waypoints"][1] in right_lane and not params["is_left_of_center"]:
reward += 10
elif params["closest_waypoints"][1] in center_lane and center_variance < 0.4:
reward += 10
else:
reward -= 10
if params["closest_waypoints"][1] in fast:
if params["speed"] == 2 :
reward += 10
else:
reward -= 10
elif params["closest_waypoints"][1] in slow:
if params["speed"] == 1 :
reward += 10
else:
reward -= 10
return float(reward)