2023-12-11 13:29:51 +00:00
|
|
|
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
|
|
|
|
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
|
|
|
|
|
|
|
|
#' Specialized version of `read_cyclic.cpp` taylored to work in conjunction with
|
|
|
|
#' `gmlm_chess()` as data generator to provide random draws from a FEN data set
|
|
|
|
#' with scores filtered to be in in the range `score_min` to `score_max`.
|
|
|
|
#'
|
2023-12-19 13:13:49 +00:00
|
|
|
data.gen <- function(file, sample_size, score_min = -5.0, score_max = +5.0, quiet = FALSE) {
|
|
|
|
.Call(`_Rchess_data_gen`, file, sample_size, score_min, score_max, quiet)
|
2023-12-11 13:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#' Convert a legal FEN string to a 3D binary (integer with 0-1 entries) array
|
|
|
|
fen2int <- function(boards) {
|
|
|
|
.Call(`_Rchess_fen2int`, boards)
|
|
|
|
}
|
|
|
|
|
|
|
|
#' Reads lines from a text file with recycling.
|
|
|
|
#'
|
|
|
|
read.cyclic <- function(file, nrows = 1000L, skip = 100L, start = 1L, line_len = 64L) {
|
|
|
|
.Call(`_Rchess_read_cyclic`, file, nrows, skip, start, line_len)
|
|
|
|
}
|
|
|
|
|
|
|
|
#' Samples a legal move from a given position
|
|
|
|
sample.move <- function(pos) {
|
|
|
|
.Call(`_Rchess_sample_move`, pos)
|
|
|
|
}
|
|
|
|
|
|
|
|
#' Samples a random FEN (position) by applying `ply` random moves to the start
|
|
|
|
#' position.
|
|
|
|
#'
|
|
|
|
#' @param nr number of positions to sample
|
|
|
|
#' @param min_depth minimum number of random ply's to generate random positions
|
|
|
|
#' @param max_depth maximum number of random ply's to generate random positions
|
|
|
|
sample.fen <- function(nr, min_depth = 4L, max_depth = 20L) {
|
|
|
|
.Call(`_Rchess_sample_fen`, nr, min_depth, max_depth)
|
|
|
|
}
|
|
|
|
|
|
|
|
#' Converts a FEN string to a Board (position) or return the current internal state
|
|
|
|
board <- function(fen = "") {
|
|
|
|
.Call(`_Rchess_board`, fen)
|
|
|
|
}
|
|
|
|
|
|
|
|
print.board <- function(fen = "") {
|
|
|
|
invisible(.Call(`_Rchess_print_board`, fen))
|
|
|
|
}
|
|
|
|
|
|
|
|
print.moves <- function(fen = "") {
|
|
|
|
invisible(.Call(`_Rchess_print_moves`, fen))
|
|
|
|
}
|
|
|
|
|
|
|
|
print.bitboards <- function(fen = "") {
|
|
|
|
invisible(.Call(`_Rchess_print_bitboards`, fen))
|
|
|
|
}
|
|
|
|
|
|
|
|
position <- function(pos, moves, san = FALSE) {
|
|
|
|
.Call(`_Rchess_position`, pos, moves, san)
|
|
|
|
}
|
|
|
|
|
|
|
|
perft <- function(depth = 6L) {
|
|
|
|
invisible(.Call(`_Rchess_perft`, depth))
|
|
|
|
}
|
|
|
|
|
|
|
|
go <- function(depth = 6L) {
|
|
|
|
.Call(`_Rchess_go`, depth)
|
|
|
|
}
|
|
|
|
|
|
|
|
ucinewgame <- function() {
|
|
|
|
invisible(.Call(`_Rchess_ucinewgame`))
|
|
|
|
}
|
|
|
|
|
|
|
|
.onLoad <- function(libname, pkgname) {
|
|
|
|
invisible(.Call(`_Rchess_onLoad`, libname, pkgname))
|
|
|
|
}
|
|
|
|
|
|
|
|
.onUnload <- function(libpath) {
|
|
|
|
invisible(.Call(`_Rchess_onUnload`, libpath))
|
|
|
|
}
|
|
|
|
|