Board

Board
class Board

The board game.

The board contains a 8x8 matrix with every square containing a piece, either black, white or neutral.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def board: Array[Array[Piece]]

The board matrix.

The board matrix.

Attributes

Returns

The board matrix.

def initialize(): Unit

Initialize the chess board.

Initialize the chess board.

Put all the pieces on their starting square. White pieces on the 1st row, white pawns on the 2nd row, black pieces on the 8th row and black pawns on the 7th row.

Attributes

def movePiece(piece: Piece, newPos: Position): Unit

Move the piece on the board.

Move the piece on the board.

It first replaces its starting square with a neutral piece. It then replaces the target position with the piece.

Value parameters

newPos

The position the piece moves.

piece

The piece to move.

Attributes

override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
def visualizeBoard(side: String): String

Visualize the board.

Visualize the board.

Shows the chess board from either white or black perspective. Columns names are indicates at the bottom, and row numbers are on the left side of each row.

Every piece is represented as their toString() method.

Value parameters

side

The perspective of the board, either black or white.

Attributes

Returns

The chess board with all the pieces.