class LxChess::Game

Overview

Represents a standard game of Chess

Defined in:

lx_chess/game.cr

Constructors

Instance Method Summary

Constructor Detail

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

[View source]

Instance Method Detail

def board : Board #

[View source]
def board=(board : Board) #

[View source]
def can_castle_king?(piece) #

[View source]
def can_castle_queen?(piece) #

[View source]
def castling #

[View source]
def castling=(string : String) #

[View source]
def checkmate?(turn = @turn) #

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


[View source]
def current_player #

[View source]
def disambiguate_candidates(notation : Notation, move_sets : Array(MoveSet)) #

Attempt to reduce ambiguities in candidate moves


[View source]
def en_passant_target : Int16 | Nil #

[View source]
def en_passant_target=(en_passant_target : Int16 | Nil) #

[View source]
def en_passant_target=(cord : String) #

[View source]
def fifty_move_rule : Int8 #

[View source]
def fifty_move_rule=(fifty_move_rule : Int8) #

[View source]
def find_king(turn = @turn) #

Find the king, optionally specifying turn


[View source]
def full_moves #

[View source]
def in_check?(turn = @turn) #

[View source]
def make_move(from : String, to : String, promotion : Char | Nil = nil) #

[View source]
def make_move(from : Int16, to : Int16, promotion : Char | Nil = nil) #

Make a move given a set of coordinates


[View source]
def move_clock : Int16 #

[View source]
def move_clock=(move_clock : Int16) #

[View source]
def move_to_san(from : String, to : String, promotion : Char | Nil = nil, turn = @turn) #

[View source]
def move_to_san(from : Int, to : Int, promotion : Char | Nil = nil, turn = @turn) #

[View source]
def moves(square : String | Int) #

Generate the psuedo-legal moves for a given square


[View source]
def next_turn(turn = @turn) #

Get the next turn index


[View source]
def next_turn! #

Increment the turn index


[View source]
def parse_san(notation : String) #

Parse SAN from a string


[View source]
def parse_san(notation : Notation) #

Parse standard algebraic notation


[View source]
def pieces_for(turn = @turn) #

Return the pieces for a specified player


[View source]
def players : Array(Player) #

[View source]
def 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


[View source]
def set_fen_attributes(fen : Fen) #

[View source]
def tmp_move(from : String, to : String, promotion : Char | Nil = nil, &) #

[View source]
def tmp_move(from : Int16, to : Int16, promotion : Char | Nil = nil, &) #

Temporarily make a move


[View source]
def turn : Int8 #

[View source]
def turn=(turn : Int8) #

[View source]
def undo(changes : Array(Change)) #

Undo a move


[View source]