Example #1
0
 def _get_lap(self):
     pix_arr = self.numpy_array
     point_a = IMAGE_HELPER.GetPixelColor(pix_arr, 203, 51)
     if point_a in self.LAP_COLOR_MAP:
         return self.LAP_COLOR_MAP[point_a]
     else:
         # TODO: What should this do? The pixel is not known, so assume same lap?
         return self.lap
 def _checkpoint(self, checkpoint_points):
     pix_arr = self.numpy_array
     colored_dots = map(lambda point: IMAGE_HELPER.GetPixelColor(pix_arr, point[0], point[1]), 
                        checkpoint_points)
     pixel_means = np.mean(colored_dots, 1)
     #print colored_dots
     #cprint('Pixel means: %s' % pixel_means, 'cyan')
     return any(val < 100 for val in pixel_means)
    def _evaluate_end_state(self):
        #cprint('Evaluate End State called!','yellow')
        pix_arr = self.pixel_array

        upper_left = IMAGE_HELPER.GetPixelColor(pix_arr, 19, 19)
        upper_right = IMAGE_HELPER.GetPixelColor(pix_arr, 620, 19)
        bottom_left = IMAGE_HELPER.GetPixelColor(pix_arr, 19, 460)
        bottom_right = IMAGE_HELPER.GetPixelColor(pix_arr, 620, 460)

        if upper_left == upper_right == bottom_left == bottom_right:
            self.end_episode_confidence += 1
        else:
            self.end_episode_confidence = 0

        if self.end_episode_confidence > self.END_EPISODE_THRESHOLD:
            return True
        else:
            return False
Example #4
0
    def _evaluate_end_state(self):
        #cprint('Evaluate End State called!','yellow')
        pix_arr = self.numpy_array

        upper_left = IMAGE_HELPER.GetPixelColor(pix_arr, 19, 19)
        upper_right = IMAGE_HELPER.GetPixelColor(pix_arr, 620, 19)
        bottom_left = IMAGE_HELPER.GetPixelColor(pix_arr, 19, 460)
        bottom_right = IMAGE_HELPER.GetPixelColor(pix_arr, 620, 460)

        if upper_left == upper_right == bottom_left == bottom_right or (
                self.USE_CHECKPOINTS_TO_END_EPISODE
                and self.chkpt_count > self.END_EPISODE_CHECKPOINT_THRESHOLD
        ) or (self.USE_LAPS_TO_END_EPISODE
              and self._get_lap() > self.END_EPISODE_LAP_THRESHOLD):
            self.end_episode_confidence += 1
        else:
            self.end_episode_confidence = 0

        if self.end_episode_confidence > self.END_EPISODE_THRESHOLD:
            return True
        else:
            return False
    def _evaluate_checkpoint(self, checkpoint_points):
        checkpoint_pixels = [IMAGE_HELPER.GetPixelColor(self.pixel_array, point[0], point[1])
                             for point in checkpoint_points]

        #print(checkpoint_pixels)
        
        # If the first pixel is not a valid color, no need to check the other three
        if not checkpoint_pixels[0] in self.HUD_PROGRESS_COLOR_VALUES:
            return -1
        # If the first pixel is good, make sure the other three match
        elif not self.all_equal(checkpoint_pixels):
            return -1
        # If all are good, return the corresponding value
        else:
            return self.HUD_PROGRESS_COLOR_VALUES[checkpoint_pixels[0]]
 def _evaluate_end_state(self):
     #cprint('Evaluate End State called!','yellow')
     return self.end_race_pixel_color == IMAGE_HELPER.GetPixelColor(
         self.pixel_array, 203, 51)