def utility(self, data): # every 1500 is 0.1 enemy_dist = data.enemy.location.dist(data.ball.location) enemy_dist_u = enemy_dist * 0.00006 dist01 = rlu.dist_01(data.car.dist_to_ball) dist01 = 1 - easing.smooth_stop(4, dist01) car_to_ball = data.ball.location - data.car.location above_ang = car_to_ball.ang_to(Vec3(z=1)) aa01 = easing.fix(1 - 1.5 * above_ang / math.pi) return easing.fix(0.76 * aa01 + enemy_dist_u) * (data.ball.location.z > 25)
def utility(self, data): ball_soon = predict.move_ball(data.ball.copy(), 1) team_sign = datalibs.team_sign(data.car.team) own_half_01 = easing.fix(easing.remap(team_sign * datalibs.ARENA_LENGTH2, (-1 * team_sign) * datalibs.ARENA_LENGTH2, 0.0, 1.1, ball_soon.location.y)) self.ball_to_goal_right = self.enemy_goal_right - data.ball_when_hit.location self.ball_to_goal_left = self.enemy_goal_left - data.ball_when_hit.location self.aim_cone = route.AimCone(self.ball_to_goal_right.ang(), self.ball_to_goal_left.ang()) car_to_ball = data.ball_when_hit.location - data.car.location in_position = self.aim_cone.contains_direction(car_to_ball) return easing.fix(own_half_01 + 0.06 * in_position)
def utility(self, data): car_to_pad = self.location - data.car.location_2d state = data.packet.game_boosts[self.index] if not state.is_active: return 0 # consider distance, angle, and size dist = 1 - rlu.dist_01(data.car.location.dist(self.location)) ang = rlu.face_ang_01(data.car.orientation.front.ang_to_flat(car_to_pad)) big = 1 if self.info.is_full_boost else 0.65 # prefer those closer to own goal between_car_and_goal = datalibs.is_point_closer_to_goal(self.location, data.car.location, data.car.team) btcg = 1 if between_car_and_goal else 0.9 off_dist_01 = 1 if data.agent.point_of_interest is not None and False: # Only deviate if pot is far away and there is time to collect boost car_to_pot_dist = data.car.location.dist(data.agent.point_of_interest) pad_to_car_dist = data.car.location.dist(self.location) pad_to_pot_dist = data.agent.point_of_interest.dist(self.location) if car_to_pot_dist > 1200 and pad_to_car_dist < pad_to_pot_dist: # prefer those between car and point of interest off_dist_01 = rlu.dist_01(pad_to_car_dist + pad_to_pot_dist - car_to_pot_dist) off_dist_01 = 1 - off_dist_01**2 else: off_dist_01 = 0 result = easing.fix(dist * ang * big * btcg * off_dist_01) # data.renderer.draw_line_3d(data.car.location.tuple(), self.location.tuple(), data.renderer.create_color(255, 0, int(result * 255), 0)) return result
def utility(self, data): team_sign = datalibs.team_sign(data.car.team) ball_to_goal = datalibs.get_goal_location(data.car.team) - data.ball.location ball_vel_g = data.ball.velocity.proj_onto_size(ball_to_goal) if ball_vel_g > 0: vel_g_01 = easing.fix(ball_vel_g / 700 + 0.36) else: vel_g_01 = 0 too_close = ball_to_goal.length2() < 900*900 hits_goal_prediction = predict.will_ball_hit_goal(data.ball) hits_goal = hits_goal_prediction.happens and rlmath.sign(data.ball.velocity.y) == team_sign and hits_goal_prediction.time < 6 return easing.fix(vel_g_01) or hits_goal or too_close
def utility(self, data): team_sign = datalibs.team_sign(data.car.team) ball_to_goal = datalibs.get_goal_location(data.car.team) - data.ball.location ball_vel_g = data.ball.velocity.proj_onto_size(ball_to_goal) if ball_vel_g > 0: vel_g_01 = easing.fix(ball_vel_g / 1000 + 0.5) else: vel_g_01 = easing.fix(0.5 + ball_vel_g / 3000) ball_on_my_half_01 = easing.fix(easing.remap((-1*team_sign) * datalibs.ARENA_LENGTH2, team_sign * datalibs.ARENA_LENGTH2, 0, 1.6, data.ball.location.y)) enemy_on_my_half_01 = easing.fix(easing.remap((-1*team_sign) * datalibs.ARENA_LENGTH2, team_sign * datalibs.ARENA_LENGTH2, 0.5, 1.1, data.ball.location.y)) enemy_reaches_first = predict.time_till_reach_ball(data.ball, data.enemy) < data.time_till_hit enemy_first_01 = 1 if enemy_reaches_first else 0.6 return easing.fix(ball_on_my_half_01 * enemy_on_my_half_01 * vel_g_01 * enemy_first_01)
def utility(self, data): team_sign = datalibs.team_sign(data.car.team) goal_to_ball = data.ball.location - datalibs.get_goal_location(data.car.team) car_to_ball = data.ball.location - data.car.location ball_own_half_01 = easing.fix(easing.remap((-1*team_sign) * datalibs.ARENA_LENGTH2, team_sign * datalibs.ARENA_LENGTH2, -0.2, 1.2, data.ball.location.y)) car_to_ball = data.ball_when_hit.location - data.car.location in_position = self.aim_cone.contains_direction(car_to_ball) return ball_own_half_01 * in_position
def utility(self, data): if data.car.boost == 100: return -0.5 boost01 = data.car.boost / 100.0 boost01 = 1 - easing.smooth_stop(4, boost01) # best_boost = self.collect_boost_system.evaluate(data) pot_01 = 1 if data.agent.point_of_interest is not None: # Agent have a point of interest. Only collect boost if missing speed and boost pot_01 = easing.fix(1 - data.car.velocity.length() / 2500) # 2500 so he is always missing some speed ut = boost01 * pot_01 return easing.inv_lerp(0, 0.9, ut)
def dist_01(dist, max_dist=MAX_DIST): return easing.fix(dist / float(max_dist))
def face_ang_01(ang): return easing.fix(math.cos(ang))