Skip to content

Instantly share code, notes, and snippets.

@LoganArnett
Last active August 29, 2015 14:07
Show Gist options
  • Save LoganArnett/e0ac61cea993af38055e to your computer and use it in GitHub Desktop.
Save LoganArnett/e0ac61cea993af38055e to your computer and use it in GitHub Desktop.
Working through the Javascript Chessboard

Chessboard Interface

  • @constructor Chess: Setup a board with Pieces representing an initial chessboard.
    • @method getPlayer()
      • @return String either "white" or "black" representing current player
    • @method move(piece, destination): Move piece to destination and...?
      • @param Piece piece to move
      • @param Position destination to move piece to
    • @method opening(): Advance the board to Catalan Opening, Closed Variation
    • @method display()
      • @return String representation of board
R,N,B,Q,K,B,N,R
P,P,P,P,P,P,P,P
 , , , , , , ,
 , , , , , , ,
 , , , , , , ,
 , , , , , , ,
p,p,p,p,p,p,p,p
r,n,b,q,k,b,n,r
  • @constructor Position(x,y): Represent a position on a chessboard with coordinates
    • usage: new Position(1,1)
    • @property Number x coordinate
    • @property Number y coordinate
  • @constructor Piece(name, color): Represent a chesspiece on the board with name and color and appropriate starting position
    • usage: new Piece('Queen', 'black')
    • @method getName()
      • @return String name of Piece, e.g. 'Queen', 'Pawn'
    • @method getColor():
      • @return String player 'black' or 'white'
    • @method setPosition(position): Set Piece to position on board
      • @param Position position
    • @method toString()
      • @return String representation of Piece
      • example: "Q" === String(new Piece("Queen", "white"))
      • example: "r" === String(new Piece("Rook", "black"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment