struct Chess::Position

Defined in:

chess/position.cr

Constant Summary

BLACK_KING_SIDE_CASTLE_FLAG = 1_u8 << 2
BLACK_QUEEN_SIDE_CASTLE_FLAG = 1_u8 << 3
EP_SQUARE_DIRECTION = [8, -8]
INITIAL = new(INITIAL_POSITION_IN_FEN)
INITIAL_POSITION_IN_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
KING_CASTLE_FLAGS = [BLACK_QUEEN_SIDE_CASTLE_FLAG | BLACK_KING_SIDE_CASTLE_FLAG, WHITE_QUEEN_SIDE_CASTLE_FLAG | WHITE_KING_SIDE_CASTLE_FLAG]
PIECE_CHARS = "pnbrqk."
ROOK_CASTLE_FLAGS = Array(UInt8).new(64) do |idx| case idx when Square::A1.value WHITE_QUEEN_SIDE_CASTLE_FLAG when Square::H1.value WHITE_KING_SIDE_CASTLE_FLAG when Square::A8.value BLACK_QUEEN_SIDE_CASTLE_FLAG when Square::H8.value BLACK_KING_SIDE_CASTLE_FLAG else 0_u8 end end
WHITE_KING_SIDE_CASTLE_FLAG = 1_u8
WHITE_QUEEN_SIDE_CASTLE_FLAG = 1_u8 << 1

Constructors

Instance Method Summary

Constructor Detail

def self.new(fen) #

[View source]
def self.new #

[View source]

Instance Method Detail

def bishops #

[View source]
def blacks #

[View source]
def colours : Array(UInt64) #

[View source]
def colours=(colours : Array(UInt64)) #

[View source]
def ep_square : Chess::Square #

[View source]
def ep_square=(ep_square : Chess::Square) #

[View source]
def fifty_move : Int32 #

[View source]
def fifty_move=(fifty_move : Int32) #

[View source]
def flags : UInt8 #

[View source]
def flags=(flags : UInt8) #

[View source]
def generate_moves #

[View source]
def generate_pseudolegal_moves #

[View source]
def generate_wrapped_moves #

[View source]
def insufficient_material? #

[View source]
def is_in_check? #

[View source]
def is_square_attacked?(square, colour) #

[View source]
def key : UInt64 #

[View source]
def key=(key : UInt64) #

[View source]
def kings #

[View source]
def knights #

[View source]
def last_move : Int32 #

[View source]
def last_move=(last_move : Int32) #

[View source]
def make_legal_move(move : MoveWrapper) #

[View source]
def make_legal_move(move : Int32) : Position #

Same as make_move but without legality check


[View source]
def make_move(move : MoveWrapper) #

[View source]
def make_move(move : Int32) : Position | Nil #

[View source]
def move_count : Int32 #

[View source]
def move_count=(move_count : Int32) #

[View source]
def pawn_key : UInt64 #

[View source]
def pawn_key=(pawn_key : UInt64) #

[View source]
def pawns #

[View source]
def pieces : Array(UInt64) #

[View source]
def pieces=(pieces : Array(UInt64)) #

[View source]
def pretty #

[View source]
def queens #

[View source]
def rooks #

[View source]
def side_to_move : Chess::Colour #

[View source]
def side_to_move=(side_to_move : Chess::Colour) #

[View source]
def to_fen #

[View source]
def type_on_square(idx) #

[View source]
def whites #

[View source]