Пример #1
0
def action_after_kickoff(message, player):
    ball_visible, ball_location = see_utils.ball_is_visible(message)
    if ball_visible:
        return tmp_func(message, player)
    else:
        print('ball invisible')
        return '(turn 30)' + commands.change_view_normal(message, player)
Пример #2
0
 def get_reward(self, message):
     reward = 0
     ball_visible, ball_location = see_message_utils.ball_is_visible(
         message)
     if ball_visible: reward += 1 + 50 - float(ball_location[2])
     if self.last_command == None: reward -= 1
     return reward
Пример #3
0
def write_ball_info(message, player):
    ball_visible, ball_location = see_utils.ball_is_visible(message)
    ball_kickable = ball_visible and float(ball_location[1]) < 1.0
    nearest_to_goal = ball_visible and see_utils.judge_nearest_to_goal(
        message, ball_location, player_locations)

    player.update_status(
        'ball', {
            'visible': ball_visible,
            'kickable': ball_kickable,
            'player_is_nearest': nearest_to_goal
        })
Пример #4
0
 def calc_suggest_command(self, message):
     ball_visible, ball_location = see_message_utils.ball_is_visible(
         message)
     ball_kickable = ball_visible and float(ball_location[1]) < 1.0
     goal_visible, goal_location = see_message_utils.enemy_goal_is_visible(
         message, self)
     if ball_kickable and goal_visible:
         return '(kick 80 {})'.format(goal_location[2])
     elif ball_visible and (float(ball_location[2]) > 20
                            or float(ball_location[2]) < -20):
         return '(turn {})'.format(ball_location[2])
     elif ball_kickable:
         return '(kick 15 60)'
     elif ball_visible:
         return '(dash 80 {})'.format(ball_location[2])
     else:
         return '(turn 60)'
Пример #5
0
def tmp_func(message, player):
    ball_visible , ball_location = see_utils.ball_is_visible(message)
    ball_kickable = ball_visible and float(ball_location[1]) < 1.0
    command = None

    if ball_kickable:
        command = commands.kick_to_closest_member(message, player)
        if command == None:
            return commands.turn_60(message, player) + commands.change_view_narrow(message, player)
        return command + commands.change_view_normal(message, player)
    elif ball_visible and player.status['player_number'] > 1:
        player_locations = list(filter(see_utils.filter_team_players, message[0][2:-1]))
        nearest_to_ball = see_utils.judge_nearest_to_ball(message, ball_location, player_locations)
        if float(ball_location[1]) < 10.0 and nearest_to_ball:
            return commands.dash_to_ball(message, player)
        return commands.turn_to_ball(message, player)
    elif ball_visible:
        return commands.dash_max(message, player)
    else:
        return commands.turn_30(message, player)
Пример #6
0
def calc_reward_from_see_message(message: list, player: int) -> int:
    ball_visible, ball_location = see_message_utils.ball_is_visible(message)
    ball_kickable = ball_visible and float(ball_location[1]) < 1.0
    goal_visible, goal_location = see_message_utils.enemy_goal_is_visible(
        message, player)
    players = list(filter(see_message_utils.filter_players(), message[0][2:]))

    reward = 0
    if ball_visible:
        reward += 1.0 - float(ball_location[1]) / 50
    else:
        reward -= 100.0
    if ball_kickable:
        reward += 50
    if goal_visible:
        reward += 20
    if ball_visible and goal_visible and float(goal_location[1]) < 30:
        reward += 70
    # if len(players) > 1:
    #     reward += 0.3

    return reward
Пример #7
0
def calc_next_reward(command, message, last_command=None):
    next_reward = 0.0
    parsed_command = parse_message(command)[0]
    ball_visible, ball_location = see_message_utils.ball_is_visible(message)
    ball_kickable = ball_visible and float(ball_location[1]) < 1.0
    if parsed_command[0] == 'kick':
        if not ball_kickable:
            next_reward -= 100
    elif parsed_command[0] == 'change_view':
        next_reward -= 20
        if last_command == command:
            next_reward -= 100
    elif parsed_command[0] == 'dash':
        if float(parsed_command[1]) < 1.0:
            next_reward -= 100
        else:
            next_reward += 20
        if float(parsed_command[2]) < 40.0 and float(
                parsed_command[2]) > -40.0:
            next_reward += 20
    if parsed_command[0] == 'turn':
        next_reward += 20
    return next_reward