Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Keisuke ANDO
socceR
Commits
64281254
Commit
64281254
authored
Dec 07, 2022
by
Keisuke ANDO
😌
Browse files
Re-Add test data removed, Fix code about namespace
parent
39740e4a
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
R/read_log.R
View file @
64281254
...
...
@@ -5,7 +5,7 @@
#' @export
#' @examples
#' rcg <- read_log("data/20220405162804-HELIOS_base_3-vs-enemy_2.rcg")
#' rcl <- read_log("data/20220
304142841
-HELIOS_base_
1
-vs-
ThunderLeague_1
.rcl")
#' rcl <- read_log("data/20220
405162804
-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
,
...
...
data/20220405162804-HELIOS_base_3-vs-enemy_2.rcg
0 → 100644
View file @
64281254
This diff is collapsed.
Click to expand it.
data/20220
304142841
-HELIOS_base_
1
-vs-
ThunderLeague_1
.rcl
→
data/20220
405162804
-HELIOS_base_
3
-vs-
enemy_2
.rcl
View file @
64281254
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment