A Board represents the squares of a chess board. it also handles coversion of
indicies <=> cords. The internal representation is a contiguous array
Constants
LETTERS = ('a'..'z').to_a
Constructors
new(width : Int16 = 8, height : Int16 = 8)
SourceClass methods
cord(index : Int, width = 8)
Convert an index into a human coordinate (ex: a1)
SourceInstance methods
[](index : Int)
Retrieve a piece at an index
Source[](cord : String)
Retrieve a piece at a human cord ex: a1
Source[]=(index : Int, piece : Piece | Nil)
Set a piece on the board at a certain index
Source[]=(cord : String, piece : Piece | Nil)
Set a piece on the board at a certain human readable cord
Sourceat(x : Int, y : Int)
Retrieve a piece at an x and y cord
Sourceborder_left(index)
Border to the left of a given index
Sourceborder_right(index)
Border to the right of a given index
Sourcecord(index : Int)
Convert an index into a human coordinate (ex: a1)
Sourcedist_left(index)
Distance to the left border from an index
Sourcedist_right(index)
Distance to the right border from an index
Sourceeach
Must yield this collection's elements to the block.
Sourcefile(index : Int16)
The file of a given index
file(4) # => 4
file(8) # => 0
Sourceindex_of(x : Int, y : Int)
Convert an x and y position into an index.
Ex: 4, 4 => 36
Sourceindex_of(cord : String)
Convert human cord into an index on the board.
Ex: a1 => 0
Sourceindexes_of(cords : Array(String))
Sourcemove(from : String | Int16, to : String | Int16)
Move a piece from a position to a new position
Sourcepieces(color : Nil | Symbol = nil)
Select pieces from the board by specifying an option color
Sourcerank(index : Int16)
The rank of a given index
rank(4) # => 0
rank(8) # => 1
Sourcerel_index(index : Int, x : Int, y : Int)
Source