Echecs.Move (Echecs v0.1.5)

Copy Markdown View Source

Chess moves as structs and as packed integers.

The engine generates moves as packed integers: from (bits 0–5), to (bits 6–11), promotion (bits 12–14: 0 = none, 1 = knight, 2 = bishop, 3 = rook, 4 = queen) and special flags (bits 15–17: 0 = none, 1 = en passant, 2 = kingside castle, 3 = queenside castle). pack/4 encodes from atoms, pack_fast/4 from pre-encoded bit fields and pack_plain/2 for plain moves; unpack_from/1, unpack_to/1, unpack_promotion/1 and unpack_special/1 decode. to_struct/1 converts to %Move{} at the API boundary.

Summary

Types

t()

@type t() :: %Echecs.Move{
  from: Echecs.Board.square(),
  promotion: Echecs.Piece.type() | nil,
  special: :kingside_castle | :queenside_castle | :en_passant | nil,
  to: Echecs.Board.square()
}

Functions

decode_promo(arg1)

decode_special(arg1)

encode_promo(atom)

encode_special(atom)

new(from, to, promotion \\ nil, special \\ nil)

pack(from, to, promotion, special)

(macro)

pack_fast(from, to, promo_bits, special_bits)

(macro)

pack_plain(from, to)

(macro)

to_struct(int)

unpack_from(int)

(macro)

unpack_promotion(int)

(macro)

unpack_special(int)

(macro)

unpack_to(int)

(macro)