Class: BoardPosition

BoardPosition

represents a full position of the board

Constructor

new BoardPosition()

Author:
  • mark.veltzer@gmail.com (Mark Veltzer)
Source:

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.
Author:
  • mark.veltzer@gmail.com (Mark Veltzer) TODO - add more sanity tests (regexp) for the whole input. - parse the 5 other blocks after the position itself (what do I do with that ?!?).
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.
Author:
  • mark.veltzer@gmail.com (Mark Veltzer)
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).
Author:
  • mark.veltzer@gmail.com (Mark Veltzer)
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.
Author:
  • mark.veltzer@gmail.com (Mark Veltzer)
Source:

initialize() → {BoardPosition}

constructs a new object
This:
Author:
  • mark.veltzer@gmail.com (Mark Veltzer)
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:
Author:
  • mark.veltzer@gmail.com (Mark Veltzer)
Source:
Returns:
a string representation of this object.
Type
string