tensor_predictors/dataAnalysis/chess/Rchess/R/RcppExports.R

125 lines
3.8 KiB
R
Raw Normal View History

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
#' Human Crafted Evaluation
HCE <- function(positions) {
.Call(`_Rchess_HCE`, positions)
}
#' Given a FEN (position) determines if its whites turn
isWhiteTurn <- function(positions) {
.Call(`_Rchess_isWhiteTurn`, positions)
}
#' Check if current side to move is in check
isCheck <- function(positions) {
.Call(`_Rchess_isCheck`, positions)
}
#' Check if the current position is a quiet position (no piece is attacked)
isQuiet <- function(positions) {
.Call(`_Rchess_isQuiet`, positions)
}
#' Check if position is terminal
#'
#' Checks if the position is a terminal position, meaning if the game ended
#' by mate, stale mate or the 50 modes rule. Three-Fold repetition is NOT
#' checked, therefore a seperate game history is required which the board
#' does NOT track.
#'
isTerminal <- function(positions) {
.Call(`_Rchess_isTerminal`, positions)
}
#' Check if checkmate is possible by material on the board
#'
#' Checks if there is sufficient mating material on the board, meaning if it
#' possible for any side to deliver a check mate. More specifically, it
#' checks if the pieces on the board are KK, KNK or KBK.
#'
isInsufficient <- function(positions) {
.Call(`_Rchess_isInsufficient`, positions)
}
2023-12-11 13:29:51 +00:00
#' 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`.
#'
data.gen <- function(file, sample_size, score_min = -5.0, score_max = +5.0, quiet = FALSE, min_ply_count = 10L, white_only = TRUE) {
.Call(`_Rchess_data_gen`, file, sample_size, score_min, score_max, quiet, min_ply_count, white_only)
}
#' Human Crafted Evaluation
eval.psqt <- function(positions, psqt, pawn_structure = FALSE, eval_rooks = FALSE, eval_king = FALSE) {
.Call(`_Rchess_eval_psqt`, positions, psqt, pawn_structure, eval_rooks, eval_king)
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))
}