Games_Chess
[ class tree: Games_Chess ] [ index: Games_Chess ] [ all elements ]

File: Chess.php

Source Location: /Games_Chess-1.0.1/Chess.php

Classes:

Games_Chess
ABSTRACT parent class - use Games_Chess_Standard for a typical chess game

Page Details:

The Games_Chess Package

The logic of handling a chessboard and parsing standard FEN (Forsyth-Edwards Notation) for describing a position as well as SAN (Standard Algebraic Notation) for describing individual moves is handled. This class can be used as a backend driver for playing chess, or for validating and/or creating PGN files using the File_ChessPGN package. Although this package is alpha, it is fully unit-tested. The code works, but the API is fluid, and may change dramatically as it is put into use and better ways are found to use it. When the API stabilizes, the stability will increase.

To learn how to play chess, there are many sites online, try searching for "chess." To play online, I use the Internet Chess Club at http://www.chessclub.com as CelloJi, look me up sometime :). Don't worry, I'm not very good.

  • Author: Gregory Beaver <cellog@php.net>
  • Version: @VER@
  • Copyright: 2003
  • Todo: implement special class Games_Chess_Chess960 for Fischer Random Chess
  • Todo: implement special class Games_Chess_Wild23 for ICC Wild variant 23
  • Filesource: Source Code for this file
  • License: PHP License 3.0

GAMES_CHESS_CASTLE [line 50]

GAMES_CHESS_CASTLE = 1
Castling move (O-O or O-O-O)

Move constants


[ Top ]



GAMES_CHESS_ERROR_CANT_CAPTURE_OWN [line 146]

GAMES_CHESS_ERROR_CANT_CAPTURE_OWN = 19
An attempt (however misguided) was made to capture one's own piece, illegal

Error Constants


[ Top ]



GAMES_CHESS_ERROR_CANT_CK [line 118]

GAMES_CHESS_ERROR_CANT_CK = 12
Can't castle kingside, either king or rook has moved

Error Constants


[ Top ]



GAMES_CHESS_ERROR_CANT_CQ [line 126]

GAMES_CHESS_ERROR_CANT_CQ = 14
Can't castle kingside, either king or rook has moved

Error Constants


[ Top ]



GAMES_CHESS_ERROR_CANT_MOVE_THAT_WAY [line 159]

GAMES_CHESS_ERROR_CANT_MOVE_THAT_WAY = 22
A request was made to move a piece from one square to another, but it can't

Error Constants move to that square legally


[ Top ]



GAMES_CHESS_ERROR_CANT_PLACE_18 [line 227]

GAMES_CHESS_ERROR_CANT_PLACE_18 = 37
When a pawn placement on the first or back rank is attempted

Error Constants


[ Top ]



GAMES_CHESS_ERROR_CASTLE_WOULD_CHECK [line 134]

GAMES_CHESS_ERROR_CASTLE_WOULD_CHECK = 16
Castling would place the king in check, which is illegal

Error Constants


[ Top ]



GAMES_CHESS_ERROR_CK_PIECES_IN_WAY [line 122]

GAMES_CHESS_ERROR_CK_PIECES_IN_WAY = 13
Can't castle kingside, pieces are in the way on the f and/or g files

Error Constants


[ Top ]



GAMES_CHESS_ERROR_CQ_PIECES_IN_WAY [line 130]

GAMES_CHESS_ERROR_CQ_PIECES_IN_WAY = 15
Can't castle queenside, pieces are in the way on the d, c and/or b files

Error Constants


[ Top ]



GAMES_CHESS_ERROR_DUPESQUARE [line 173]

GAMES_CHESS_ERROR_DUPESQUARE = 25
An attempt was made to add a piece to the chessboard on top of an existing piece

Error Constants


[ Top ]



GAMES_CHESS_ERROR_EMPTY_FEN [line 81]

GAMES_CHESS_ERROR_EMPTY_FEN = 3
A FEN containing multiple spaces in a row was parsed

Error Constants }


[ Top ]



GAMES_CHESS_ERROR_FEN_CASTLETOOLONG [line 94]

GAMES_CHESS_ERROR_FEN_CASTLETOOLONG = 6
The list of castling indicators was too long (longest is KQkq) of a FEN

Error Constants


[ Top ]



GAMES_CHESS_ERROR_FEN_CASTLEWRONG [line 98]

GAMES_CHESS_ERROR_FEN_CASTLEWRONG = 7
Something other than K, Q, k or q was in the castling indicators of a FEN

Error Constants


[ Top ]



GAMES_CHESS_ERROR_FEN_COUNT [line 76]

GAMES_CHESS_ERROR_FEN_COUNT = 2
The number of space-separated fields in a FEN passed to

Error Constants } resetGame() was incorrect, should be 6


[ Top ]



GAMES_CHESS_ERROR_FEN_INVALIDPIECE [line 177]

GAMES_CHESS_ERROR_FEN_INVALIDPIECE = 26
An invalid piece indicator was used in a FEN

Error Constants


[ Top ]



GAMES_CHESS_ERROR_FEN_INVALID_EP [line 102]

GAMES_CHESS_ERROR_FEN_INVALID_EP = 8
The en passant square was neither "-" nor an algebraic square in a FEN

Error Constants


[ Top ]



GAMES_CHESS_ERROR_FEN_INVALID_MOVENUMBER [line 110]

GAMES_CHESS_ERROR_FEN_INVALID_MOVENUMBER = 10
The move count (pairs of white/black moves) was not a number in a FEN

Error Constants


[ Top ]



GAMES_CHESS_ERROR_FEN_INVALID_PLY [line 106]

GAMES_CHESS_ERROR_FEN_INVALID_PLY = 9
The ply count (number of half-moves) was not a number in a FEN

Error Constants


[ Top ]



GAMES_CHESS_ERROR_FEN_MULTIPIECE [line 169]

GAMES_CHESS_ERROR_FEN_MULTIPIECE = 24
An attempt was made to add a piece to the chessboard through the parsing of

Error Constants a FEN, but there are too many pieces of that type already on the chessboard


[ Top ]



GAMES_CHESS_ERROR_FEN_TOMOVEWRONG [line 90]

GAMES_CHESS_ERROR_FEN_TOMOVEWRONG = 5
The indicator of which side to move in a FEN was neither "w" nor "b"

Error Constants


[ Top ]



GAMES_CHESS_ERROR_FEN_TOOLITTLE [line 181]

GAMES_CHESS_ERROR_FEN_TOOLITTLE = 27
Not enough piece data was passed into the FEN to explain every square on the board

Error Constants


[ Top ]



GAMES_CHESS_ERROR_FEN_TOOMUCH [line 86]

GAMES_CHESS_ERROR_FEN_TOOMUCH = 4
Too many pieces were passed in for the chessboard to fit them in a FEN

Error Constants


[ Top ]



GAMES_CHESS_ERROR_INVALID_COLOR [line 185]

GAMES_CHESS_ERROR_INVALID_COLOR = 28
Something other than "W" or "B" was passed to a method needing a color

Error Constants


[ Top ]



GAMES_CHESS_ERROR_INVALID_PIECE [line 195]

GAMES_CHESS_ERROR_INVALID_PIECE = 30
Something other than "P", "Q", "R", "B", "N" or "K" was passed to a method

Error Constants needing a piece type


[ Top ]



GAMES_CHESS_ERROR_INVALID_PROMOTE [line 200]

GAMES_CHESS_ERROR_INVALID_PROMOTE = 31
Something other than "Q", "R", "B", or "N" was passed to a method

Error Constants needing a piece type for pawn promotion


[ Top ]



GAMES_CHESS_ERROR_INVALID_SAN [line 71]

GAMES_CHESS_ERROR_INVALID_SAN = 1
Invalid Standard Algebraic Notation was used

Error Constants


[ Top ]



GAMES_CHESS_ERROR_INVALID_SQUARE [line 190]

GAMES_CHESS_ERROR_INVALID_SQUARE = 29
Something that isn't SAN ([a-h][1-8]) was passed to a function requiring a

Error Constants square location


[ Top ]



GAMES_CHESS_ERROR_IN_CHECK [line 114]

GAMES_CHESS_ERROR_IN_CHECK = 11
An illegal move was attempted, the king is in check

Error Constants


[ Top ]



GAMES_CHESS_ERROR_MOVE_MUST_CAPTURE [line 215]

GAMES_CHESS_ERROR_MOVE_MUST_CAPTURE = 34
In loser's chess, and the current move does not capture a piece although capture is possible.

Error Constants


[ Top ]



GAMES_CHESS_ERROR_MOVE_WOULD_CHECK [line 138]

GAMES_CHESS_ERROR_MOVE_WOULD_CHECK = 17
Performing a requested move would place the king in check

Error Constants


[ Top ]



GAMES_CHESS_ERROR_MULTIPIECE [line 164]

GAMES_CHESS_ERROR_MULTIPIECE = 23
An attempt was made to add a piece to the chessboard, but there are too many

Error Constants pieces of that type already on the chessboard


[ Top ]



GAMES_CHESS_ERROR_NOPIECES_TOPLACE [line 219]

GAMES_CHESS_ERROR_NOPIECES_TOPLACE = 35
When piece placement is attempted, but no pieces exist to be placed

Error Constants


[ Top ]



GAMES_CHESS_ERROR_NOPIECE_CANDOTHAT [line 210]

GAMES_CHESS_ERROR_NOPIECE_CANDOTHAT = 33
No piece of the current color can execute the SAN (as in, if Na3 is passed

Error Constants in, but there are no knights that can reach a3


[ Top ]



GAMES_CHESS_ERROR_NO_PIECE [line 150]

GAMES_CHESS_ERROR_NO_PIECE = 20
An attempt was made to capture a piece on a square that does not contain a piece

Error Constants


[ Top ]



GAMES_CHESS_ERROR_PIECEINTHEWAY [line 223]

GAMES_CHESS_ERROR_PIECEINTHEWAY = 36
When piece placement is attempted, but there is a piece on the desired square already

Error Constants


[ Top ]



GAMES_CHESS_ERROR_STILL_IN_CHECK [line 142]

GAMES_CHESS_ERROR_STILL_IN_CHECK = 18
The requested move does not remove a check on the king

Error Constants


[ Top ]



GAMES_CHESS_ERROR_TOO_AMBIGUOUS [line 205]

GAMES_CHESS_ERROR_TOO_AMBIGUOUS = 32
SAN was passed in that is too ambiguous - multiple pieces could execute

Error Constants the move, and no disambiguation (like Naf3 or Bf3xe4) was used


[ Top ]



GAMES_CHESS_ERROR_WRONG_COLOR [line 154]

GAMES_CHESS_ERROR_WRONG_COLOR = 21
A attempt to move an opponent's piece was made, illegal

Error Constants


[ Top ]



GAMES_CHESS_PAWNMOVE [line 54]

GAMES_CHESS_PAWNMOVE = 2
Pawn move (e4, e8=Q, exd5)

Move constants


[ Top ]



GAMES_CHESS_PIECEMOVE [line 58]

GAMES_CHESS_PIECEMOVE = 3
Piece move (Qa4, Nfe6, Bxe5, Re2xe6)

Move constants


[ Top ]



GAMES_CHESS_PIECEPLACEMENT [line 62]

GAMES_CHESS_PIECEPLACEMENT = 4
Special move type used in Wild23 like P@a4 (place a pawn at a4)

Move constants


[ Top ]



Documentation generated on Sun, 17 Jun 2007 02:00:40 -0400 by phpDocumentor 1.3.2. PEAR Logo Copyright © PHP Group 2004.