def fast_move_to_point_backward(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 ) angle = env.me.get_angle_to_unit(mirrow_point) if abs(angle) > geometry.degree_to_rad(1): env.move.turn = angle return v0 = geometry.vector_abs(env.me.speed_x, env.me.speed_y) vn = 0 a = -env.game.hockeyist_speed_up_factor n = prediction.count_n(v0, a, vn) if n is None: env.move.speed_up = -1.0 return n = round(n) + 1 x0 = 0. xn = prediction.count_xn(x0, v0, a, n) if xn > distance: env.move.speed_up = 1.0 else: env.move.speed_up = -1.0
def do(self, env): distance = env.me.get_distance_to_unit(self.point) angle = env.me.get_angle_to_unit(self.point) if distance < 2: self.done = True speed_abs = geometry.vector_abs(env.me.speed_x, env.me.speed_y) print ( 'tick = ', env.world.tick, 'MoveToPoint done', 'x = ', env.me.x, 'y = ', env.me.y, 'speed abs = ', speed_abs ) return if abs(angle) > geometry.degree_to_rad(1): env.move.turn = angle return v0 = geometry.vector_abs(env.me.speed_x, env.me.speed_y) vn = 0 a = -env.game.hockeyist_speed_down_factor n = prediction.count_n(v0, a, vn) if n is None: env.move.speed_up = 1.0 # print 'tick = ', env.world.tick, 'speed = 1. n is None' return n = round(n) + 1 x0 = 0. xn = prediction.count_xn(x0, v0, a, n) # print ( # 'v0 = ', v0, # 'n =', n, # 'xn =', xn, # 'dist = ', distance # ) # import ipdb; ipdb.set_trace() if xn > distance: # print 'tick = ', env.world.tick, 'speed = -1.' env.move.speed_up = -1.0 else: # print 'tick = ', env.world.tick, 'speed = 1.' env.move.speed_up = 1.0