Commit 64281254 authored by Keisuke ANDO's avatar Keisuke ANDO 😌
Browse files

Re-Add test data removed, Fix code about namespace

parent 39740e4a
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#' @export #' @export
#' @examples #' @examples
#' rcg <- read_log("data/20220405162804-HELIOS_base_3-vs-enemy_2.rcg") #' rcg <- read_log("data/20220405162804-HELIOS_base_3-vs-enemy_2.rcg")
#' rcl <- read_log("data/20220304142841-HELIOS_base_1-vs-ThunderLeague_1.rcl") #' rcl <- read_log("data/20220405162804-HELIOS_base_3-vs-enemy_2.rcl")
read_log <- function(path) { read_log <- function(path) {
ext <- path |> path() |> path_ext() ext <- path |> path() |> path_ext()
...@@ -27,11 +27,11 @@ read_rcg <- function(path) { ...@@ -27,11 +27,11 @@ read_rcg <- function(path) {
parse_json(simplifyVector = TRUE, flatten = TRUE) |> parse_json(simplifyVector = TRUE, flatten = TRUE) |>
as_tibble() |> as_tibble() |>
filter(type == "show") |> filter(type == "show") |>
select(time,stime,players, ball.x, ball.y, ball.vx, ball.vy) |> select(time, stime, players, ball.x, ball.y, ball.vx, ball.vy) |>
unnest(players) |> unnest(players) |>
select(time:capacity, ball.x:ball.vy) |> select(time:capacity, ball.x:ball.vy) |>
rename(step = time) |> rename(step = time) |>
rename_with(stringr::str_replace, pattern = "\\.", replacement = "_") rename_with(str_replace, pattern = "\\.", replacement = "_")
return(rcg) return(rcg)
} }
...@@ -43,22 +43,22 @@ read_rcl <- function(path) { ...@@ -43,22 +43,22 @@ read_rcl <- function(path) {
read_lines() |> read_lines() |>
as_tibble() |> as_tibble() |>
mutate( mutate(
step = value |> stringr::str_extract("\\d+") |> as.numeric(), step = value |> str_extract("\\d+") |> as.numeric(),
agent = value |> stringr::str_extract("\\w+_([0-9]{1,2}|Coach)(?!\\))"), agent = value |> str_extract("\\w+_([0-9]{1,2}|Coach)(?!\\))"),
team = agent |> stringr::str_remove("_([0-9]{1,2}|Coach)"), team = agent |> str_remove("_([0-9]{1,2}|Coach)"),
unum = agent |> stringr::str_extract("([0-9]{1,2}|Coach)$"), unum = agent |> str_extract("([0-9]{1,2}|Coach)$"),
commands = value |> commands = value |>
stringr::str_extract("\\(.+\\)$") |> str_extract("\\(.+\\)$") |>
purrr::map(~ .x |> map(~ .x |>
stringr::str_split("\\(|\\)", simplify = TRUE) |> str_split("\\(|\\)", simplify = TRUE) |>
stringr::str_trim() |> str_trim() |>
purrr::discard(~ .x == "")), discard(~ .x == "")),
) |> ) |>
unnest(commands) |> unnest(commands) |>
mutate( mutate(
commands = commands |> stringr::str_split("\\ ", n = 2), commands = commands |> str_split("\\ ", n = 2),
command = commands |> purrr::map_chr(1), command = commands |> map_chr(1),
args = commands |> purrr::map(~ .x[-1]), args = commands |> map(~ .x[-1]),
) |> ) |>
select( select(
step, step,
......
This diff is collapsed.
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