Commit e2e55a3f authored by Takumi Amano's avatar Takumi Amano 💬
Browse files

[fix]フィールドのサイズを修正

parent 4f82b1a0
soccer_field_length = 105
soccer_field_width = 68
soccer_goal_width = 14.02
get_referee <- function(rcl) { get_referee <- function(rcl) {
referee <- rcl |> referee <- rcl |>
dplyr::filter(command == "referee") %>% dplyr::filter(command == "referee") %>%
...@@ -67,8 +70,9 @@ get_ball <- function(rcg) { ...@@ -67,8 +70,9 @@ get_ball <- function(rcg) {
dplyr::mutate(next_ball_vy = lead(ball_vy)) %>% dplyr::mutate(next_ball_vy = lead(ball_vy)) %>%
dplyr::mutate(kick_speed= (ball_vx^2+ball_vy^2)) %>% dplyr::mutate(kick_speed= (ball_vx^2+ball_vy^2)) %>%
dplyr::mutate(a_kick_speed= (next_ball_vx^2+next_ball_vy^2)) %>% dplyr::mutate(a_kick_speed= (next_ball_vx^2+next_ball_vy^2)) %>%
dplyr::mutate(target_ball_x = (ball_x + next_ball_vx*10)) %>% dplyr::mutate(target_ball_x = (ball_x + ball_vx)) %>%
dplyr::mutate(target_ball_y = (ball_y + next_ball_vy*10)) dplyr::mutate(target_ball_y = (ball_y + ball_vy)) %>%
dplyr::mutate(shoot_ball = (kick_speed > 1)&((soccer_field_length/2)<abs(target_ball_x))&((soccer_goal_width/2)>abs(target_ball_y)))
return(ball) return(ball)
} }
...@@ -132,7 +136,7 @@ get_kick_log <- function(action,goal) { ...@@ -132,7 +136,7 @@ get_kick_log <- function(action,goal) {
(judge == "NULL") & (next_judge == "NULL") & a_sameteam & !a_sameunum)) %>% (judge == "NULL") & (next_judge == "NULL") & a_sameteam & !a_sameunum)) %>%
dplyr::mutate(shoot = ( dplyr::mutate(shoot = (
shoot_scc | shoot_scc |
abs(target_ball_x) > 54 & abs(target_ball_y) < 12)) %>% abs(target_ball_x) > (soccer_field_length/2) & abs(target_ball_y) < 12)) %>%
dplyr::mutate(dribble = ( dplyr::mutate(dribble = (
(!shoot)& (!shoot)&
(!pass_scc)& (!pass_scc)&
...@@ -215,8 +219,8 @@ get_shoot <- function(kick) { ...@@ -215,8 +219,8 @@ get_shoot <- function(kick) {
dplyr::filter(shoot == TRUE) %>% dplyr::filter(shoot == TRUE) %>%
distinct(step, .keep_all = TRUE) %>% distinct(step, .keep_all = TRUE) %>%
dplyr::select(step,team,ball_x,ball_y,ball_vx,ball_vy,next_ball_x,next_ball_y,next_ball_vx,next_ball_vy,shoot,shoot_scc) %>% dplyr::select(step,team,ball_x,ball_y,ball_vx,ball_vy,next_ball_x,next_ball_y,next_ball_vx,next_ball_vy,shoot,shoot_scc) %>%
dplyr::mutate(ball_goal_dist = sqrt((54-abs(ball_x))^2+abs((ball_y))^2)) %>% dplyr::mutate(ball_goal_dist = sqrt(((soccer_field_length/2)-abs(ball_x))^2+abs((ball_y))^2)) %>%
dplyr::mutate(ball_goal_angle = atan2((54-abs(ball_x)),ball_y)) dplyr::mutate(ball_goal_angle = atan2(((soccer_field_length/2)-abs(ball_x)),ball_y))
return(output) return(output)
} }
...@@ -224,8 +228,8 @@ get_xg <- function(kick){ ...@@ -224,8 +228,8 @@ get_xg <- function(kick){
output <- kick |> output <- kick |>
dplyr::filter(shoot == TRUE) %>% dplyr::filter(shoot == TRUE) %>%
distinct(step, .keep_all = TRUE) %>% distinct(step, .keep_all = TRUE) %>%
dplyr::mutate(ball_goal_dist = sqrt((54-abs(ball_x))^2+abs((ball_y))^2)) %>% dplyr::mutate(ball_goal_dist = sqrt(((soccer_field_length/2)-abs(ball_x))^2+abs((ball_y))^2)) %>%
dplyr::mutate(ball_goal_angle = atan2((54-abs(ball_x)),ball_y)) %>% dplyr::mutate(ball_goal_angle = atan2(((soccer_field_length/2)-abs(ball_x)),ball_y)) %>%
dplyr::select(step,team,px,py,ball_x,ball_y,ball_goal_dist,ball_goal_angle) dplyr::select(step,team,px,py,ball_x,ball_y,ball_goal_dist,ball_goal_angle)
return(output) return(output)
} }
...@@ -242,8 +246,8 @@ get_xg_l <- function(kick){ ...@@ -242,8 +246,8 @@ get_xg_l <- function(kick){
dplyr::filter(shoot == TRUE) %>% dplyr::filter(shoot == TRUE) %>%
dplyr::filter(side == "l") %>% dplyr::filter(side == "l") %>%
distinct(step, .keep_all = TRUE) %>% distinct(step, .keep_all = TRUE) %>%
dplyr::mutate(ball_goal_dist = sqrt((54-abs(ball_x))^2+abs((ball_y))^2)) %>% dplyr::mutate(ball_goal_dist = sqrt(((soccer_field_length/2)-abs(ball_x))^2+abs((ball_y))^2)) %>%
dplyr::mutate(ball_goal_angle = atan2((54-abs(ball_x)),ball_y)) %>% dplyr::mutate(ball_goal_angle = atan2(((soccer_field_length/2)-abs(ball_x)),ball_y)) %>%
dplyr::select(px,py,ball_x,ball_y,ball_goal_dist,ball_goal_angle) dplyr::select(px,py,ball_x,ball_y,ball_goal_dist,ball_goal_angle)
return(output) return(output)
} }
...@@ -263,8 +267,8 @@ get_xg_r <- function(kick){ ...@@ -263,8 +267,8 @@ get_xg_r <- function(kick){
dplyr::filter(side == "r") %>% dplyr::filter(side == "r") %>%
distinct(step, .keep_all = TRUE) %>% distinct(step, .keep_all = TRUE) %>%
dplyr::mutate(px = px * -1,py = py *-1,ball_x = -1 * ball_x,ball_y = ball_y * -1) %>% dplyr::mutate(px = px * -1,py = py *-1,ball_x = -1 * ball_x,ball_y = ball_y * -1) %>%
dplyr::mutate(ball_goal_dist = sqrt((54-abs(ball_x))^2+abs((ball_y))^2)) %>% dplyr::mutate(ball_goal_dist = sqrt(((soccer_field_length/2)-abs(ball_x))^2+abs((ball_y))^2)) %>%
dplyr::mutate(ball_goal_angle = atan2((54-abs(ball_x)),ball_y)) %>% dplyr::mutate(ball_goal_angle = atan2(((soccer_field_length/2)-abs(ball_x)),ball_y)) %>%
dplyr::select(px,py,ball_x,ball_y,ball_goal_dist,ball_goal_angle) dplyr::select(px,py,ball_x,ball_y,ball_goal_dist,ball_goal_angle)
return(output) return(output)
} }
...@@ -296,7 +300,7 @@ get_goalkeeper_action<- function(actionAll){ ...@@ -296,7 +300,7 @@ get_goalkeeper_action<- function(actionAll){
output <- actionAll |> output <- actionAll |>
dplyr::filter(unum == 1) %>% dplyr::filter(unum == 1) %>%
dplyr::mutate(ball_keeper_dist_x = sqrt((px-ball_x)^2)) %>% dplyr::mutate(ball_keeper_dist_x = sqrt((px-ball_x)^2)) %>%
dplyr::mutate(player_goal_dist = sqrt((54-abs(px))^2+abs((py))^2)) %>% dplyr::mutate(player_goal_dist = sqrt(((soccer_field_length/2)-abs(px))^2+abs((py))^2)) %>%
dplyr::mutate(opp_team =(team != shoot_team)) %>% dplyr::mutate(opp_team =(team != shoot_team)) %>%
dplyr::mutate(ball_closer_goal_goalkeeper = opp_team & (ball_goal_dist < player_goal_dist)) dplyr::mutate(ball_closer_goal_goalkeeper = opp_team & (ball_goal_dist < player_goal_dist))
return(output) return(output)
...@@ -309,8 +313,8 @@ get_shoot_epv <- function(players,shoot){ ...@@ -309,8 +313,8 @@ get_shoot_epv <- function(players,shoot){
dplyr::select(step,side,ball_keeper_dist_x,keeper_goal_dist=player_goal_dist,ball_closer_goal_goalkeeper) dplyr::select(step,side,ball_keeper_dist_x,keeper_goal_dist=player_goal_dist,ball_closer_goal_goalkeeper)
opponent_team <- shootAll |> opponent_team <- shootAll |>
dplyr::filter(team != shoot_team) %>% dplyr::filter(team != shoot_team) %>%
dplyr::mutate(r_post_x = (ball_x + (py - ball_y)*(7-ball_x)/(-54-ball_y))) %>% dplyr::mutate(r_post_x = (ball_x + (py - ball_y)*((soccer_goal_width/2)-ball_x)/(-(soccer_field_length/2)-ball_y))) %>%
dplyr::mutate(l_post_x = (ball_x + (py - ball_y)*(-7-ball_x)/(-54-ball_y))) %>% dplyr::mutate(l_post_x = (ball_x + (py - ball_y)*(-(soccer_goal_width/2)-ball_x)/(-(soccer_field_length/2)-ball_y))) %>%
dplyr::mutate(triangle_in_player = (px > l_post_x)&(px < r_post_x)) %>% dplyr::mutate(triangle_in_player = (px > l_post_x)&(px < r_post_x)) %>%
dplyr::mutate(dist_ball_in_3m = (ball_player_dist < 3)) dplyr::mutate(dist_ball_in_3m = (ball_player_dist < 3))
opp_triangle_in_player_num <- opponent_team |> opp_triangle_in_player_num <- opponent_team |>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment