Documentation

Board
in package

Table of Contents

Constants

NX  = 8
NY  = 8

Properties

$board  : array<int, array<int, ChessPiece|null>>
$canCastle  : array<string|int, mixed>
$enPassantPawn  : array{X: int, Y: int}
$numMoves  : int

Methods

__construct()  : mixed
canCastle()  : bool
clearSquare()  : void
deepCopy()  : self
getBoardDisplay()  : array<int, array<int, ChessPiece|null>>
Get the board from the colour's perspective as an array.
getCurrentTurnColour()  : Colour
getEnPassantPawn()  : array{X: int, Y: int}
getFEN()  : string
getKing()  : ChessPiece
getPiece()  : ChessPiece
getPieces()  : array<string|int, ChessPiece>
hasPiece()  : bool
isChecked()  : bool
Is the $colour King being attacked by any enemy pieces?
isValidCoord()  : bool
movePiece()  : ChessPiece, EnPassant: bool, PawnPromotion: bool}
Move a piece. Note that legality of the move is not checked here.
setSquare()  : void
Change the position of a piece on the board
initialize()  : void

Constants

Properties

$canCastle

private array<string|int, mixed> $canCastle

array<value-of<Colour>, array<Castling>>

$enPassantPawn

private array{X: int, Y: int} $enPassantPawn

$numMoves

private int $numMoves = 0

Methods

__construct()

public __construct([bool $initialize = true ]) : mixed
Parameters
$initialize : bool = true

clearSquare()

public clearSquare(int $x, int $y) : void
Parameters
$x : int
$y : int

deepCopy()

public deepCopy() : self
Return values
self

getBoardDisplay()

Get the board from the colour's perspective as an array.

public getBoardDisplay(bool $playerIsWhite) : array<int, array<int, ChessPiece|null>>

The first dimension is the y-coordinate, second is x-coordinate.

Parameters
$playerIsWhite : bool
Return values
array<int, array<int, ChessPiece|null>>

getEnPassantPawn()

public getEnPassantPawn() : array{X: int, Y: int}
Return values
array{X: int, Y: int}

getFEN()

public getFEN() : string
Return values
string

hasPiece()

public hasPiece(int $x, int $y) : bool
Parameters
$x : int
$y : int
Return values
bool

isChecked()

Is the $colour King being attacked by any enemy pieces?

public isChecked(Colour $colour) : bool
Parameters
$colour : Colour
Return values
bool

isValidCoord()

public static isValidCoord(int $x, int $y) : bool
Parameters
$x : int
$y : int
Return values
bool

movePiece()

Move a piece. Note that legality of the move is not checked here.

public movePiece(int $x, int $y, int $toX, int $toY[, int $pawnPromotionPiece = ChessPiece::QUEEN ]) : ChessPiece, EnPassant: bool, PawnPromotion: bool}
Parameters
$x : int
$y : int
$toX : int
$toY : int
$pawnPromotionPiece : int = ChessPiece::QUEEN
Return values
ChessPiece, EnPassant: bool, PawnPromotion: bool}

setSquare()

Change the position of a piece on the board

public setSquare(int $x, int $y, ChessPiece $piece) : void
Parameters
$x : int
$y : int
$piece : ChessPiece

initialize()

private initialize() : void

        
On this page

Search results