#include #include #include "SchachHoernchen/Board.h" //' Given a FEN (position) determines if its whites turn // [[Rcpp::export(rng = false)]] Rcpp::LogicalVector isWhiteTurn(const std::vector& positions) { // Iterate all positions and call the static board evaluation return Rcpp::LogicalVector(positions.begin(), positions.end(), [](const Board& pos) { return pos.isWhiteTurn(); } ); } //' Check if current side to move is in check // [[Rcpp::export(rng = false)]] Rcpp::LogicalVector isCheck(const std::vector& positions) { return Rcpp::LogicalVector(positions.begin(), positions.end(), [](const Board& pos) { return pos.isCheck(); } ); } //' Check if the current position is a quiet position (no piece is attacked) // [[Rcpp::export(rng = false)]] Rcpp::LogicalVector isQuiet(const std::vector& positions) { return Rcpp::LogicalVector(positions.begin(), positions.end(), [](const Board& pos) { return pos.isQuiet(); } ); } //' 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. //' // [[Rcpp::export(rng = false)]] Rcpp::LogicalVector isTerminal(const std::vector& positions) { return Rcpp::LogicalVector(positions.begin(), positions.end(), [](const Board& pos) { return pos.isTerminal(); } ); } //' 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. //' // [[Rcpp::export(rng = false)]] Rcpp::LogicalVector isInsufficient(const std::vector& positions) { return Rcpp::LogicalVector(positions.begin(), positions.end(), [](const Board& pos) { return pos.isInsufficient(); } ); }