From 912f9edbb2c6647039cf71c42f0f075d842b273e Mon Sep 17 00:00:00 2001 From: Adarsh Nair Date: Wed, 9 Aug 2017 11:41:09 -0700 Subject: [PATCH] smartcab left turn --- projects/smartcab/smartcab/environment.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/smartcab/smartcab/environment.py b/projects/smartcab/smartcab/environment.py index 41113a049f..6f157a0d6d 100755 --- a/projects/smartcab/smartcab/environment.py +++ b/projects/smartcab/smartcab/environment.py @@ -312,8 +312,11 @@ def act(self, agent, action): violation = 4 # Accident elif inputs['oncoming'] == 'right': # Oncoming car turning right violation = 4 # Accident - else: # Green light - 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. + else:# Green light + if inputs['oncoming'] == 'right' or inputs['oncoming'] == 'forward': # Incoming traffic + violation = 3 # Accident + else: # Valid move! + heading = (heading[1], -heading[0]) # Agent wants to drive right: elif action == 'right':