def on_car_positions(self, data, tick):
        car = self.my_car()

        if not car.crashed:
            cur_index = self.my_car().track_piece_index
            macro_index = self.track.macro_piece_map[cur_index]
            next_macro_beginning = self.track.reverse_macro_map[(macro_index + 1) % len(self.track.reverse_macro_map)]
            lane = car.lane()
            next_macro_beginning_piece = car.track.track_pieces[next_macro_beginning]
            next_macro_radius = next_macro_beginning_piece.true_radius(lane)
            #next_macro_target_speed = physics.estimate_stable_speed_at_angle(next_macro_radius, physics.crash_angle_buffered())
            next_macro_target_speed = physics.estimate_safe_speed_at_angle(next_macro_radius, physics.crash_angle_buffered())

            if car.current_track_piece().is_straight:
                if physics.distance_to_break(car.velocity, next_macro_target_speed) >= \
                car.track.distance_until_index(car.track_piece_index,
                                               car.in_piece_distance,
                                               next_macro_beginning,
                                               lane):
                    self.throttle(physics.throttle_to_reach_velocity(car.velocity, next_macro_target_speed), tick)
                else:
                    self.throttle(1.0, tick)
            else:
                # it's a bend!
                #FIXME: do the safe ending in a more intelligent way than adding one to the next piece index
                #FIXME: this is just copied from the other bot, we want velocities, not throttles
                the_until = (next_macro_beginning + 1) % car.track.track_piece_count
                deduced_throttle = my_bisect(0.0, 1.0, 6, lambda t: physics.is_safe_until_simple(car, t, the_until, 0.0))
                self.throttle(deduced_throttle, tick)
        else:
            self.ping()
    def on_car_positions(self, data, tick):
        car = self.my_car()

        if not car.crashed:
            the_until = (car.track_piece_index + self.piece_look_ahead) % car.track.track_piece_count
            deduced_throttle = my_bisect(0.0, 1.0, 6, lambda t: physics.is_safe_until_simple(car, t, the_until, 0.0))
            print("decided to go on throttle {0} from {1} to {2}".format(deduced_throttle, car.track_piece_index, the_until))
            self.throttle(deduced_throttle, tick)
        else:
            self.ping()