A fast, C++-backed chess engine package for R.
Inspired by: https://github.com/kjda/chess-on-go
Current status: early but functional (v0.1.0). The core move generator, game registry, SAN replay, and enrichment pipeline are implemented and tested.
ply_*, ply_pgn_*R CMD check --no-tests --no-manual passedFrom GitHub:
install.packages("remotes")
remotes::install_github("plychess/ply-r")Install from local source (compiles C++ code):
install.packages(".", repos = NULL, type = "source")Run tests from the project root:
install.packages("testthat")
testthat::test_dir("tests/testthat")Or run package checks from the terminal:
R CMD build .
R CMD check ply_0.1.0.tar.gzGenerate the PDF manual:
R CMD Rd2pdf .Note: PDF generation requires a working LaTeX installation.
library(ply)
state <- ply_game_init()
moves <- ply_legal_moves(state)
state2 <- ply_move_apply(state, "e2e4")
fen <- ply_fen_serialize(state2)id <- ply_game_new("alice")
ply_game_join(id, "bob")
ply_game_move(id, "alice", "e2e4")
info <- ply_game_info(id)The package exports two public groups:
+----------------------+
| ply-r |
| R Chess Engine Repo |
+----------+-----------+
|
+----------v-----------+
| R/ public API |
| ply_* + ply_pgn_* |
+----------+-----------+
|
+----------v-----------+
| Rcpp bridge |
| RcppExports + bridge |
+----------+-----------+
|
+----------v-----------+
| C++ engine core |
| bitboards + registry |
+----+------------+----+
| |
+---------v--+ +-----v----------------+
| tests/ | | docs + package meta |
| perft 1..6 | | man, README, NS, CI |
+-------------+ +----------------------+
Recent validation passed with
R CMD check --no-tests --no-manual, and the package test
suite also passed separately during development.
Note: full manual PDF generation may fail locally if LaTeX packages are missing. This is an environment issue, not an engine issue.
The package includes broad automated coverage across core engine logic, edge cases, registry workflows, SAN replay, and batch enrichment. In addition to unit and integration tests, move-generation correctness is validated with perft against published reference node counts, including deep verification through perft depth 6 (119,060,324 nodes) from the starting position. This gives strong confidence in legal move generation and rule handling under both typical and stress conditions.
The roadmap is to keep correctness as the foundation while expanding the package as a practical learning tool for machine learning and introductory AI in R: deep validation is already in place (including perft verification through depth 6), and the next phase is to add learner-friendly examples, modeling-ready feature workflows, and clear statistical analysis paths so R users can move from chess data generation to ML experimentation with minimal setup.