I'm currently building chess engine in Rust from scratch but I am having RAM problems even on calculating 6 ply.
According to Shannon's calculation there are 119,060,324 possible games after ply 6. If you store board position in 100 bytes that is over 11 GB. Machine I am using has 16 GB RAM (~5 GB used by system).
Here is core of my board representation:
pub struct ChessBoard {
pub white_to_move: bool,
pub white_pawns: u64,
pub white_rooks: u64,
pub white_knights: u64,
pub white_bishops: u64,
pub white_queens: u64,
pub white_king: u64,
pub black_pawns: u64,
pub black_rooks: u64,
pub black_knights: u64,
pub black_bishops: u64,
pub black_queens: u64,
pub black_king: u64,
}
How is it even possible to calculate to 15+ depth when number of positions grows exponentially with each ply? How do chess engines on mobile calculate positions with even less RAM? Am I missing something?