<commit_before>import main
import robocup
import math
import constants
import evaluations.ball
# Defensive positioning
# 2 main schools of thought
# Man to man coverage
# Zone coverage

# A mix of two will be the best
# We need to figure out good algorithms to find a position for each robot

# Zone defense works on keep robots somewhat spread for the incoming cross pass
# This also helps with a counter attack as one robot is free on the side of the field

# With defense, you want to push the opponents outside and cover the middle and any cross passes
# In robocup, covering crosses is a little harder due to how quickly the ball moves in comparison
# to the robots themselves.
# With that, a stronger angle defense is needed.
# Angle defense is needed to close distance to cover a wider angle
# Figure out the mathimatical relationship between distance and angle coverage
# I would imagine it is somewhat of a power / exp situation

# (1) Next, figure out a quick way to estimate the shot chance of a robot on the opponent side
# This is due to win_eval is very slow (From what I have heard)

# Can be estimated most likely with some sort of distance function and delta for the robots in the way

# Zones will need to be figured out physically until we can test multiple different ones against each other
# One basic system would be to just do a third of the field on either side of the center line

# (2) Defense wise, the robots can only pass form their mouth
# we can get that angle as well as the angle of their approach to do some early estimations
# of pass / shot direction
# A complementary filter on those two shouldn't be too hard
# Mostly likely weight towards the predicted mouth angle a little bit more (use at the very least velocity, hopefully acceleration too)

# (3) Next we need to get a list of robot positions that we should move into
# This would require figureing out their best pass / shot posiitions
# Move to block both their current positions
# As well stay in positions to block future pass positions
# Use space_coeff to find large pockets of open space and good shots from that positions
# Only one need to defend there

# (4) Area  defense will be used for zones further away from the ball
# We ened to cover as many zones as possible further away so finding a good area for each robot away from the action is needed
# To do this, we need to find where there is a significant amount of space
# What the best angle is from the ball
# And any nearby robots that we will need to move into defense for
# We can find a good position to pass to (using eight furthest time if multiple points are needed to be covered
# or just the center of the group if they are somewhat close)
# We also need to find the closest bot that is incoming that we need to cover
# Decide if covering the pass or the shot is better
# Minimize risk to find the best
# (5) Risk can be considered the closeness of another robot inc to the shot / pass location and their possible leathality
# in that position
# Risk must take into account the direction of attack onto the ball
# As well as the defense in those positions

###############################
## Most likely needed functions
###############################
#
# 
# (1) estimate_kick_block_percent(point, our_pos[])
# (2) predict_kick_direction(robot)
# (3) best_defense_positions(ball_pt)
# (4) create_area_defense_zones()
# (5) esteimate_risk_score(pt)

## Estimates the win_eval function so as to not slow down the execution
#
# @param kick_point: Point at which we will kick from
# @param recieve_point: Point at which they are kicking to
# @param blocking_robot_pos[]: list of robots that we should estimate the block for
# @return A percentage chance of block
def estimate_kick_block_percent(kick_point, recieve_point, blocking_robot_pos[]):

    # for each blocking robot pos
    # take angle and distance
    # Move through N different angles
    # Producting a Keneral function for each blocking robot
    # Invert
    # Normalize (Using a square or some sort of thing)
    # Produce percentage from this estimation

    # Array of tuples of all possible blocks
    blocks = []
    kick_direction = (recieve_point - kick_point)
    kick_angle = math.atan2(kick_direction.y, kick_direction.x)

    for pos in blocking_robot_pos:
        block_direction = (pos - kick_point)
        dist = block_direction.mag()
        angle = math.atan2(block_direction.y, block_direction.x) - kick_angle

        if (math.abs(angle) < math.pi / 2 && dist > 0):

        # Kill any that are over pi/2 away
        blocks.extend([(angle, dist)])

    # Standard deviation basically
    half_kick_width = 0.1*math.pi
    num_of_estimates = 10

    total = 0

    for line_offset in range(-half_kick_width, half_kick_width):
        chance = 0
        # How much to decrease with of kernel per distance away
        # Inf @ 0 to 0 @ pi / 2
        distance_scale = 1 / math.abs(math.tan(line_num))

        for pos  in blocks:
            # Produce a number between -1 and 1
            # Find u based off of line_offset
            # Scale output then based on distance
            u = line_offset * distance_scale
            chance += max((35/32)*pow((1-pow(u,2)), 3), 0)

    # Invert
    # Normalize
    # Produce percentage

    pass
    # TODO: Figure out the math for this
    # Most likely project the blocking robots onto the kick_line<commit_msg>Added notes to main play file<commit_after>import main
import robocup
import math
import constants
import evaluations.ball
# Defensive positioning
# 2 main schools of thought
# Man to man coverage
# Zone coverage

# A mix of two will be the best
# We need to figure out good algorithms to find a position for each robot

# Zone defense works on keep robots somewhat spread for the incoming cross pass
# This also helps with a counter attack as one robot is free on the side of the field

# With defense, you want to push the opponents outside and cover the middle and any cross passes
# In robocup, covering crosses is a little harder due to how quickly the ball moves in comparison
# to the robots themselves.
# With that, a stronger angle defense is needed.
# Angle defense is needed to close distance to cover a wider angle
# Figure out the mathimatical relationship between distance and angle coverage
# I would imagine it is somewhat of a power / exp situation

# (1) Next, figure out a quick way to estimate the shot chance of a robot on the opponent side
# This is due to win_eval is very slow (From what I have heard)

# Can be estimated most likely with some sort of distance function and delta for the robots in the way

# Zones will need to be figured out physically until we can test multiple different ones against each other
# One basic system would be to just do a third of the field on either side of the center line

# (2) Defense wise, the robots can only pass form their mouth
# we can get that angle as well as the angle of their approach to do some early estimations
# of pass / shot direction
# A complementary filter on those two shouldn't be too hard
# Mostly likely weight towards the predicted mouth angle a little bit more (use at the very least velocity, hopefully acceleration too)

# (3) Next we need to get a list of robot positions that we should move into
# This would require figureing out their best pass / shot posiitions
# Move to block both their current positions
# As well stay in positions to block future pass positions
# Use space_coeff to find large pockets of open space and good shots from that positions
# Only one need to defend there

# (4) Area  defense will be used for zones further away from the ball
# We ened to cover as many zones as possible further away so finding a good area for each robot away from the action is needed
# To do this, we need to find where there is a significant amount of space
# What the best angle is from the ball
# And any nearby robots that we will need to move into defense for
# We can find a good position to pass to (using eight furthest time if multiple points are needed to be covered
# or just the center of the group if they are somewhat close)
# We also need to find the closest bot that is incoming that we need to cover
# Decide if covering the pass or the shot is better
# Minimize risk to find the best
# (5) Risk can be considered the closeness of another robot inc to the shot / pass location and their possible leathality
# in that position
# Risk must take into account the direction of attack onto the ball
# As well as the defense in those positions

###############################
## Most likely needed functions
###############################
#
# 
# (1) estimate_kick_block_percent(point, our_pos[])
# (2) predict_kick_direction(robot)
# (3) best_defense_positions(ball_pt)
# (4) create_area_defense_zones()
# (5) esteimate_risk_score(pt)

## Estimates the win_eval function so as to not slow down the execution
#
# @param kick_point: Point at which we will kick from
# @param recieve_point: Point at which they are kicking to
# @param blocking_robot_pos[]: list of robots that we should estimate the block for
# @return A percentage chance of block
def estimate_kick_block_percent(kick_point, recieve_point, blocking_robot_pos[]):

    # for each blocking robot pos
    # take angle and distance
    # Move through N different angles
    # Producting a Keneral function for each blocking robot
    # Invert
    # Normalize (Using a square or some sort of thing)
    # Produce percentage from this estimation

    # Array of tuples of all possible blocks
    blocks = []
    kick_direction = (recieve_point - kick_point)
    kick_angle = math.atan2(kick_direction.y, kick_direction.x)

    for pos in blocking_robot_pos:
        block_direction = (pos - kick_point)
        dist = block_direction.mag()
        angle = math.atan2(block_direction.y, block_direction.x) - kick_angle

        if (math.abs(angle) < math.pi / 2 && dist > 0):

        # Kill any that are over pi/2 away
        blocks.extend([(angle, dist)])

    # Standard deviation basically
    half_kick_width = 0.1*math.pi
    num_of_estimates = 10

    total = 0

    for line_offset in range(-half_kick_width, half_kick_width):
        chance = 0
        # How much to decrease with of kernel per distance away
        # Inf @ 0 to 0 @ pi / 2
        distance_scale = 1 / math.abs(math.tan(line_num))

        for pos  in blocks:
            # Produce a number between -1 and 1
            # Find u based off of line_offset
            # Scale output then based on distance 
            u = line_offset * distance_scale
            chance += max((35/32)*pow((1-pow(u,2)), 3), 0)

    # Invert
    # Normalize
    # Produce percentage

    pass
    # TODO: Figure out the math for this
    # Most likely project the blocking robots onto the kick_line
{'fraction_non_alphanumeric': 0.05834025662328072, 'fraction_numerical': 0.006646358349487676, 'mean_word_length': 3.5273715002089427, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '973919', 'n_tokens_mistral': 2895, 'n_tokens_neox': 2777, 'n_words': 1576}