#move-generation #chess #moves #piece #sliding #simd #gen

nightly bin+lib chess-move-gen

Fast chess move generation library. Uses SIMD for fast sliding piece move generation

33 releases

0.9.0 Jan 1, 2025
0.8.2 Nov 29, 2020
0.7.8 Nov 25, 2020
0.7.0 Jul 17, 2020
0.3.3 Mar 30, 2017

#85 in Game dev

Download history 9/week @ 2024-09-18 33/week @ 2024-09-25 1/week @ 2024-10-09 1/week @ 2024-10-16 1/week @ 2024-10-30 1/week @ 2024-11-06 153/week @ 2025-01-01

153 downloads per month

MIT license

3MB
114K SLoC

Fast chess move generation library. Uses SIMD for fast sliding piece move generation

Example usage:

use chess_move_gen::*;
let mut list = MoveVec::new();
let position = &Position::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w QqKk - 0 1").unwrap();
legal_moves::<MoveVec>(position, &mut list);
assert_eq!(list.len(), 20);

Ways to store moves:

MoveVec: Wraps a vector of generated moves, useful if you need to access the actual moves being generated

MoveCounter: Counts moves of each kind (captures, castles, promotions etc). Useful if you are making a perft function or need statistics about moves for a position, but don't care about the actual moves

SortedMoveAdder + SortedMoveHeap: Stores genarated moves in a sorted binary heap, which are efficiently ordered as they are inserted based on a heuristic scoring and piece-square table that you provide. Use this if you want the moves to have a reasonably good initial ordering so moves that are checked first are more likely to lead to eg alpha-beta cutoffs and reduce the search tree size.

Dependencies

~315–435KB