Methods
(static) setupFEN(fen) → {BoardPosition}
Setup a position according to FEN notation.
See Forsyth–Edwards Notation in wikipedia for more details.
Example of start position is:
'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'
Parameters:
Name | Type | Description |
---|---|---|
fen |
string | a string describing a chess board position in FEN notation. |
- Source:
Returns:
A position object corresponding to the FEN
notation given.
- Type
- BoardPosition
(static) startPos() → {BoardPosition}
Static method that returns a starting position in standard chess.
- Source:
Returns:
A standard chess starting position.
- Type
- BoardPosition
addPiece(color, type, x, y)
Add a piece to the position
This:
Parameters:
Name | Type | Description |
---|---|---|
color |
string | the color of the piece (black/white). |
type |
string | the type of the piece (rook/knight/bishop/queen/king/pawn). |
x |
number | the x position of the piece [0..8). |
y |
number | the y position of the piece [0..8). |
- Source:
forEachPiece(f)
Run a function for each piece in this position
This:
Parameters:
Name | Type | Description |
---|---|---|
f |
function | function to run getting each piece in turn. |
- Source:
initialize() → {BoardPosition}
constructs a new object
This:
- Source:
Returns:
a new object of this type.
- Type
- BoardPosition
toString() → {string}
toString method that allows you to get a nice printout for this type
This:
- Source:
Returns:
a string representation of this object.
- Type
- string