<commit_before>//! Implements the rules of chess and position evaluation logic.

pub mod board_geometry;
pub mod board;
pub mod evaluation;

use std::mem;
use std::cmp::max;
use std::cell::UnsafeCell;
use std::hash::{Hasher, SipHasher};
use basetypes::*;
use bitsets::*;
use chess_move::*;
use notation;
use self::board::{Board, piece_attacks_from};
use self::board_geometry::*;
use self::evaluation::evaluate_board;


#[derive(Clone, Copy)]
struct StateInfo {
    halfmove_clock: u8,
    last_move: Move,
    is_repeated: bool,
    repeated_boards_hash: u64,
}


/// Represents an illegal possiton error.
pub struct IllegalPosition;


/// Represents a chess position.
///
/// `Position` is intended as a convenient interface for the
/// tree-searching algorithm. It encapsulates most of the
/// chess-specific knowledge like the chess rules, values of pieces,
/// king safety, pawn structure etc. `Position` can be instantiated
/// from a FEN string, can generate the all possible moves (plus a
/// "null move") in the current position, play a selected move and<commit_msg>added comments<commit_after>//! Implements the rules of chess and position evaluation logic.

pub mod board_geometry;
pub mod board;
pub mod evaluation;

use std::mem;
use std::cmp::max;
use std::cell::UnsafeCell;
use std::hash::{Hasher, SipHasher};
use basetypes::*;
use bitsets::*;
use chess_move::*;
use notation;
use self::board::{Board, piece_attacks_from};
use self::board_geometry::*;
use self::evaluation::evaluate_board;


#[derive(Clone, Copy)]
struct StateInfo {
    // The number of halfmoves since the last pawn advance or capture.
    halfmove_clock: u8,
    
    // The last played move.
    last_move: Move,

    // `true ` if the position is a draw by repetition.
    is_repeated: bool,
    
    // A hash value for the set of boards that had occurred twice or
    // more during the game.
    repeated_boards_hash: u64,
}


/// Represents an illegal possiton error.
pub struct IllegalPosition;


/// Represents a chess position.
///
/// `Position` is intended as a convenient interface for the
/// tree-searching algorithm. It encapsulates most of the
/// chess-specific knowledge like the chess rules, values of pieces,
/// king safety, pawn structure etc. `Position` can be instantiated
/// from a FEN string, can generate the all possible moves (plus a
/// "null move") in the current position, play a selected move and
{'fraction_non_alphanumeric': 0.11101905550952776, 'fraction_numerical': 0.0024855012427506215, 'mean_word_length': 4.0103734439834025, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1262384', 'n_tokens_mistral': 721, 'n_tokens_neox': 699, 'n_words': 289}