class

LxChess::Game

Inherits Reference < Object

Represents a standard game of Chess

Constructors

new(board : Board = Board.new, players : Array(LxChess::Player) = [] of Player)
Source

Instance methods

board
Source
board=(board : Board)
Source
can_castle_king?(piece)
Source
can_castle_queen?(piece)
Source
castling
Source
castling=(string : String)
Source
checkmate?(turn = @turn)

TODO: Optimize Make every move and test for check, if any move results in check=false, stop checking and return false

Source
current_player
Source
disambiguate_candidates(notation : Notation, move_sets : Array(MoveSet))

Attempt to reduce ambiguities in candidate moves

Source
en_passant_target
Source
en_passant_target=(en_passant_target : Int16 | Nil)
Source
en_passant_target=(cord : String)
Source
fifty_move_rule
Source
fifty_move_rule=(fifty_move_rule : Int8)
Source
find_king(turn = @turn)

Find the king, optionally specifying turn

Source
full_moves
Source
in_check?(turn = @turn)
Source
make_move(from : String, to : String, promotion : Char | Nil = nil)
Source
make_move(from : Int16, to : Int16, promotion : Char | Nil = nil)

Make a move given a set of coordinates

Source
move_clock
Source
move_clock=(move_clock : Int16)
Source
move_to_san(from : String, to : String, promotion : Char | Nil = nil, turn = @turn)
Source
move_to_san(from : Int, to : Int, promotion : Char | Nil = nil, turn = @turn)
Source
moves(square : String | Int)

Generate the psuedo-legal moves for a given square

Source
next_turn(turn = @turn)

Get the next turn index

Source
next_turn!

Increment the turn index

Source
parse_san(notation : String)

Parse SAN from a string

Source
parse_san(notation : Notation)

Parse standard algebraic notation

Source
pieces_for(turn = @turn)

Return the pieces for a specified player

Source
players
Source
remove_illegal_moves(move_set : MoveSet)

Removes moves that reveal check from a MoveSet TODO: optimize this? Maybe don't generate illegal moves and stop early for sliding pieces

Source
set_fen_attributes(fen : Fen)
Source
tmp_move(from : String, to : String, promotion : Char | Nil = nil, &)
Source
tmp_move(from : Int16, to : Int16, promotion : Char | Nil = nil, &)

Temporarily make a move

Source
turn
Source
turn=(turn : Int8)
Source
undo(changes : Array(Change))

Undo a move

Source

Nested types