Commit 51e2f5e2 authored by Masaki Ban's avatar Masaki Ban 🍜
Browse files

SPADL形式用のプログラムの追加

read_rclでrefereeのコマンドがteamとagentに抽出される問題の修正
.gitignoreで.DS_STOREを除外
parent 49e8ea6f
......@@ -2,3 +2,4 @@
.Rhistory
.RData
.Ruserdata
.DS_Store
\ No newline at end of file
library(tidyverse)
source("R/read_rcg.R")
source("R/read_rcl.R")
source("R/rcg_covert.R")
source("R/rcl_convert.R")
rcg <- read_rcg("data/20220405162804-HELIOS_base_3-vs-enemy_2.rcg")
rcl <- read_rcl("data/20220405162804-HELIOS_base_3-vs-enemy_2.rcl")
ball <- get_ball(rcg)
agent <- get_agent_pos(rcg)
command <- get_command(rcl)
#' Read RCG file
#'
#' @param path RCG file path
#' @return Parsed tibble of RCG file in \code{path}
#' @examples
#' read_rcg("data/20220405162804-HELIOS_base_3-vs-enemy_2.rcg")
get_ball <- function(rcg) {
ball <- rcg |>
dplyr::select(
step,
ball_x,
ball_y,
ball_vx,
ball_vy
) |>
dplyr::distinct(step, .keep_all = T)
return(ball)
}
get_agent_pos <- function(rcg) {
agent_pos <- rcg |>
dplyr::select(
step,
side,
unum,
type,
x,
y,
)
return(agent_pos)
}
get_kick <- function(rcl) {
kick <- rcl |>
dplyr::filter(command == "kick") |>
dplyr::select(
step,
team,
unum,
command,
)
return(kick)
}
get_command <- function(rcl) {
kick <- rcl |>
dplyr::filter(command == "kick"| command == "tackle" | command == "referee") |>
dplyr::select(
step,
team,
unum,
command,
args,
)
return(kick)
}
#classify_kick <- function(kick) {
# command <- kick |>
# dplyr::mutate(
# action <- if(kick$team)
# )
# return(command)
#}
get_tackle <- function(rcl) {
tackle <- rcl |>
dplyr::filter(command == "tackle")
return(tackle)
}
......@@ -6,34 +6,34 @@
#' read_rcg("data/20220405162804-HELIOS_base_3-vs-enemy_2.rcl")
read_rcl <- function(path) {
rcl <- path |>
readr::read_lines() |>
tibble::as_tibble() |>
dplyr::mutate(
step = value |> stringr::str_extract("\\d+"),
agent = value |> stringr::str_extract("\\w+_([0-9]{1,2}|Coach)"),
team = agent |> stringr::str_remove("_([0-9]{1,2}|Coach)"),
unum = agent |> stringr::str_extract("([0-9]{1,2}|Coach)$"),
commands = value |>
stringr::str_extract("\\(.+\\)$") |>
purrr::map(~ .x |>
stringr::str_split("\\(|\\)", simplify = TRUE) |>
stringr::str_trim() |>
purrr::discard(~ .x == "")),
) |>
tidyr::unnest(commands) |>
dplyr::mutate(
commands = commands |> stringr::str_split("\\ ", n = 2),
command = commands |> purrr::map_chr(1),
args = commands |> purrr::map(~ .x[-1]),
) |>
dplyr::select(
step,
team,
unum,
command,
args,
line = value,
)
readr::read_lines() |>
tibble::as_tibble() |>
dplyr::mutate(
step = value |> stringr::str_extract("\\d+"),
agent = value |> stringr::str_extract("\\w+_([0-9]{1,2}|Coach)(?!\\))"),
team = agent |> stringr::str_remove("_([0-9]{1,2}|Coach)"),
unum = agent |> stringr::str_extract("([0-9]{1,2}|Coach)$"),
commands = value |>
stringr::str_extract("\\(.+\\)$") |>
purrr::map(~ .x |>
stringr::str_split("\\(|\\)", simplify = TRUE) |>
stringr::str_trim() |>
purrr::discard(~ .x == "")),
) |>
tidyr::unnest(commands) |>
dplyr::mutate(
commands = commands |> stringr::str_split("\\ ", n = 2),
command = commands |> purrr::map_chr(1),
args = commands |> purrr::map(~ .x[-1]),
) |>
dplyr::select(
step,
team,
unum,
command,
args,
# line = value,
)
return(rcl)
}
library(tidyverse)
source("R/read_rcl.R")
rcl <- read_rcl("data/test.rcl")
This source diff could not be displayed because it is too large. You can view the blob instead.
Recv HELIOS_base_Coach: (init HELIOS_base (version 14))
0,239 Recv HELIOS_base_5: (turn 0)(turn_neck 0)(done)
0,239 (referee kick_off_l)
0,239 Recv HELIOS_base_Coach: (done)
27,0 Recv HELIOS_base_11: (kick 100 9.12788)(turn_neck 56)(attentionto our 6)(done)
4054,0 (referee goal_l_1)
4764,0 (referee yellow_card_r_6)
\ No newline at end of file
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