Module pleco::board::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 from a Board are:

All, Captures, Quiets, QuietChecks, Evasions, NonEvasions

There are all derived from the GenTypes enum.

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.

All will generating all moves, while any other option will generate all moves, except for under-promotions.

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 guaranteed.

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::legal_move, then the performance boost is potentially worth it.

Examples

Generating all legal moves:

This example is not tested
let moves: MoveList = board.generate_moves();

Generating all pseudo-legal moves:

This example is not tested
let moves: MoveList = board.generate_pseudolegal_moves();

Generating all pseudo-legal captures:

This example is not tested
let moves: MoveList = board.generate_moves_of_type(GenTypes::Captures);

Structs

Legal

Dummy Struct to represent the generation of Legal Moves.

MoveGen

Public move generator.

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 Board.