direction is 'left''rightor 'straight""if self crashedreturn self percepts(direction action['steer'compass_deriv {'left': ,'straight': ,'right':- }[direction]*self turning_angle self rob_dir (self rob_dir compass_deriv + )% make in range [ , rob_x_new self rob_x math cos(self rob_dir*math pi/ rob_y_new self rob_y math sin(self rob_dir*math pi/ path ((self rob_x,self rob_y),(rob_x_new,rob_y_new)if any(line_segments_intersect(path,wallfor wall in self env walls)self crashed true if self plottingplt plot([self rob_x],[self rob_y]," *",markersize= plt draw(self rob_xself rob_y rob_x_newrob_y_new self history append((self rob_xself rob_y)if self plotting and not self crashedplt plot([self rob_x],[self rob_y],"go"plt draw(plt pause(self sleep_timereturn self percepts(this detects if the whisker and the wall intersect it' value is returned as percept agentenv py -(continued def whisker(self)"""returns true whenever the whisker sensor intersects with wall ""whisk_ang_world (self rob_dir-self whisker_angle)*math pi/ angle in radians in world coordinates wx self rob_x self whisker_length math cos(whisk_ang_worldwy self rob_y self whisker_length math sin(whisk_ang_worldwhisker_line ((self rob_x,self rob_y),(wx,wy)hit any(line_segments_intersect(whisker_line,wallfor wall in self env wallsif hitself wall_history append((self rob_xself rob_y)if self plottingplt plot([self rob_x],[self rob_y],"ro"plt draw(return hit def line_segments_intersect(linea,lineb)"""returns true if the line segmentslinea and lineb intersect line segment is represented as pair of points point is represented as ( ,ypair version june