Skip to content

Commit 912f9ed

Browse files
committed
smartcab left turn
1 parent 7081cb2 commit 912f9ed

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

projects/smartcab/smartcab/environment.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,11 @@ def act(self, agent, action):
312312
violation = 4 # Accident
313313
elif inputs['oncoming'] == 'right': # Oncoming car turning right
314314
violation = 4 # Accident
315-
else: # Green light
316-
heading = (heading[1], -heading[0]) # Valid move. We assume the cab will wait for the lane to be clear on a green light, before taking the left turn.
315+
else:# Green light
316+
if inputs['oncoming'] == 'right' or inputs['oncoming'] == 'forward': # Incoming traffic
317+
violation = 3 # Accident
318+
else: # Valid move!
319+
heading = (heading[1], -heading[0])
317320

318321
# Agent wants to drive right:
319322
elif action == 'right':

0 commit comments

Comments
 (0)