Module pleco::movegen
[−]
[src]
Module for generating moves from a [Board]. Allow for generating Legal and Pseudo-Legal moves of various types.
Generation Types
The Types of moves that can be generated are:
All
, Captures
, Quiets
, QuietChecks
, Evasions
, NonEvasions
Generating all moves is legal to do no matter the position. However, Captures
, Quiets
,
QuietChecks
, and NonEvasions
can only be done if the board is in NOT in check. Likewise,
Evasions
can only be done when the board is currently in check.
Legal vs. PseudoLegal Moves
For the generation type, moves can either be generated to be Legal, Or Pseudo-Legal. A Legal move is, for as the name implies, a legal move for the current side to play for a given position. A Pseudo-Legal move is a move that is "likely" to be legal for the current position, but cannot be gaurnteed.
Why would someone ever want to generate moves that might not be legal? Performance. Based on
some benchmarking, generating all Pseudo-Legal moves is around twice as fast as generating all
Legal moves. So, if you are fine with generating moves and then checking them post-generation
with a Board::is_legal(m: BitMove)
, then the performance boost is potentially worth it.
Structs
Legal |
Dummy Struct to represent the generation of Legal Moves. |
MoveGen |
Structure to generate moves from. Stores the current state of the board, and other references to help generating all possible moves. |
PseudoLegal |
Dummy Struct to represent the generation of PseudoLegal Moves. |
Traits
Legality |
Determines the if the moves generated are PseudoLegal or legal moves.
PseudoLegal moves require that a move's legality is determined before applying
to a |