def fast_move_to_point(env, point): distance = env.me.get_distance_to_unit(point) mirrow_point = geometry.Point( 2 * env.me.x - point.x, 2 * env.me.y - point.y ) time_turn_forward = abs(env.me.get_angle_to_unit(point)) / env.game.hockeyist_turn_angle_factor time_move_forward = prediction.count_n_by_x( 0, 0, env.game.hockeyist_speed_up_factor, distance) time_turn_backward = abs(env.me.get_angle_to_unit(mirrow_point)) / env.game.hockeyist_turn_angle_factor time_move_backward = prediction.count_n_by_x( 0, 0, env.game.hockeyist_speed_down_factor, distance) if time_turn_backward + time_move_backward > time_turn_forward + time_move_forward: fast_move_to_point_forward(env, point) else: fast_move_to_point_backward(env, point)
def ticks_to_reach_point(env, hockeyist, point): distance = geometry.distance(hockeyist, point) if distance < 0.01: return 0 angle = hockeyist.get_angle_to_unit(point) v0 = ( hockeyist.speed_x * (point.x - hockeyist.x) + hockeyist.speed_y * (point.y - hockeyist.y) ) / distance a = env.game.hockeyist_speed_up_factor ticks_for_move = prediction.count_n_by_x(0, v0, a, distance) return abs(angle) / env.game.hockeyist_turn_angle_factor + ticks_for_move