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 @@
#' @export
#' @examples
#' 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) {
ext <- path |> path() |> path_ext()
......@@ -27,11 +27,11 @@ read_rcg <- function(path) {
parse_json(simplifyVector = TRUE, flatten = TRUE) |>
as_tibble() |>
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) |>
select(time:capacity, ball.x:ball.vy) |>
rename(step = time) |>
rename_with(stringr::str_replace, pattern = "\\.", replacement = "_")
rename_with(str_replace, pattern = "\\.", replacement = "_")
return(rcg)
}
......@@ -43,22 +43,22 @@ read_rcl <- function(path) {
read_lines() |>
as_tibble() |>
mutate(
step = value |> stringr::str_extract("\\d+") |> as.numeric(),
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)$"),
step = value |> str_extract("\\d+") |> as.numeric(),
agent = value |> str_extract("\\w+_([0-9]{1,2}|Coach)(?!\\))"),
team = agent |> str_remove("_([0-9]{1,2}|Coach)"),
unum = agent |> 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 == "")),
str_extract("\\(.+\\)$") |>
map(~ .x |>
str_split("\\(|\\)", simplify = TRUE) |>
str_trim() |>
discard(~ .x == "")),
) |>
unnest(commands) |>
mutate(
commands = commands |> stringr::str_split("\\ ", n = 2),
command = commands |> purrr::map_chr(1),
args = commands |> purrr::map(~ .x[-1]),
commands = commands |> str_split("\\ ", n = 2),
command = commands |> map_chr(1),
args = commands |> map(~ .x[-1]),
) |>
select(
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