class LxChess::Board
- LxChess::Board
- Reference
- Object
Overview
A Board represents the squares of a chess board. it also handles coversion of indicies <=> cords. The internal representation is a contiguous array
Included Modules
- Enumerable(LxChess::Piece?)
Defined in:
lx_chess/board.crConstant Summary
-
LETTERS =
('a'..'z').to_a
Constructors
Class Method Summary
-
.cord(index : Int, width = 8)
Convert an index into a human coordinate (ex:
a1
)
Instance Method Summary
-
#[](index : Int)
Retrieve a piece at an index
-
#[](cord : String)
Retrieve a piece at a human cord ex:
a1
-
#[]=(index : Int, piece : Piece | Nil)
Set a piece on the board at a certain index
-
#[]=(cord : String, piece : Piece | Nil)
Set a piece on the board at a certain human readable cord
-
#at(x : Int, y : Int)
Retrieve a piece at an x and y cord
-
#border_left(index)
Border to the left of a given index
-
#border_right(index)
Border to the right of a given index
-
#cord(index : Int)
Convert an index into a human coordinate (ex:
a1
) -
#dist_left(index)
Distance to the left border from an index
-
#dist_right(index)
Distance to the right border from an index
-
#each(&)
Must yield this collection's elements to the block.
-
#file(index : Int16)
The file of a given index
file(4) # => 4
file(8) # => 0
- #height : Int16
- #height=(height : Int16)
-
#index_of(x : Int, y : Int)
Convert an x and y position into an index.
-
#index_of(cord : String)
Convert human cord into an index on the board.
- #indexes_of(cords : Array(String))
-
#move(from : String | Int16, to : String | Int16)
Move a piece from a position to a new position
-
#pieces(color : Nil | Symbol = nil)
Select pieces from the board by specifying an option color
-
#rank(index : Int16)
The rank of a given index
rank(4) # => 0
rank(8) # => 1
- #rel_index(index : Int, x : Int, y : Int)
- #squares : Array(LxChess::Piece?)
- #squares=(squares : Array(Nil | LxChess::Piece))
- #width : Int16
- #width=(width : Int16)
Constructor Detail
Class Method Detail
Instance Method Detail
Set a piece on the board at a certain index
Set a piece on the board at a certain human readable cord
Must yield this collection's elements to the block.
Move a piece from a position to a new position