library(rchess)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
pgn <- "~/../Downloads/pgn_data_analysis.pgn"
pgn <- readLines(pgn, warn = FALSE)
pgn <- paste(pgn, collapse = "\n")
css <- Chess$new()
css$load_pgn(pgn)
## [1] TRUE
plot(css)
css$history_detail()
## # A tibble: 34 × 8
## piece from to number_move piece_number_move status
## <chr> <chr> <chr> <int> <int> <chr>
## 1 a1 Rook a1 <NA> NA 1 game over
## 2 b1 Knight b1 c3 3 1 game over
## 3 c1 Bishop c1 <NA> NA 1 game over
## 4 White Queen d1 <NA> NA 1 game over
## 5 White King e1 g1 13 1 game over
## 6 f1 Bishop f1 g2 11 1 game over
## 7 g1 Knight g1 e2 7 1 game over
## 8 h1 Rook h1 f1 13 1 game over
## 9 a2 Pawn a2 a3 15 1 game over
## 10 b2 Pawn b2 b4 17 1 game over
## # ... with 24 more rows, and 2 more variables: number_move_capture <int>,
## # captured_by <chr>
css$history_detail() %>%
arrange(number_move)
## # A tibble: 34 × 8
## piece from to number_move piece_number_move status
## <chr> <chr> <chr> <int> <int> <chr>
## 1 c2 Pawn c2 c4 1 1 game over
## 2 e7 Pawn e7 e5 2 1 game over
## 3 b1 Knight b1 c3 3 1 game over
## 4 g8 Knight g8 f6 4 1 game over
## 5 e2 Pawn e2 e4 5 1 game over
## 6 f8 Bishop f8 c5 6 1 <NA>
## 7 g1 Knight g1 e2 7 1 game over
## 8 Black King e8 g8 8 1 game over
## 9 h8 Rook h8 f8 8 1 game over
## 10 g2 Pawn g2 g3 9 1 game over
## # ... with 24 more rows, and 2 more variables: number_move_capture <int>,
## # captured_by <chr>
css$history_detail() %>%
arrange(number_move_capture)
## # A tibble: 34 × 8
## piece from to number_move piece_number_move status
## <chr> <chr> <chr> <int> <int> <chr>
## 1 a1 Rook a1 <NA> NA 1 game over
## 2 b1 Knight b1 c3 3 1 game over
## 3 c1 Bishop c1 <NA> NA 1 game over
## 4 White Queen d1 <NA> NA 1 game over
## 5 White King e1 g1 13 1 game over
## 6 f1 Bishop f1 g2 11 1 game over
## 7 g1 Knight g1 e2 7 1 game over
## 8 h1 Rook h1 f1 13 1 game over
## 9 a2 Pawn a2 a3 15 1 game over
## 10 b2 Pawn b2 b4 17 1 game over
## # ... with 24 more rows, and 2 more variables: number_move_capture <int>,
## # captured_by <chr>
sessionInfo()
## R version 3.3.1 (2016-06-21)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 14393)
##
## locale:
## [1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
## [3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
## [5] LC_TIME=Spanish_Spain.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] dplyr_0.5.0 rchess_0.1
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.10 knitr_1.15.1 magrittr_1.5
## [4] munsell_0.4.3 colorspace_1.3-2 R6_2.2.0
## [7] stringr_1.2.0 plyr_1.8.4 tools_3.3.1
## [10] grid_3.3.1 gtable_0.2.0 DBI_0.6
## [13] htmltools_0.3.5 yaml_2.1.14 lazyeval_0.2.0.9000
## [16] assertthat_0.1 rprojroot_1.2 digest_0.6.12
## [19] tibble_1.2 ggplot2_2.2.1 htmlwidgets_0.8
## [22] curl_2.4 evaluate_0.10 rmarkdown_1.4
## [25] V8_1.3 stringi_1.1.3 scales_0.4.1
## [28] backports_1.0.5 jsonlite_1.3