Board2D

class Board2D(rows: Int, cols: Int, outOfBoundsRegion: Region2D?) : Board<Board2D, MoveGenerator2D, Piece2D, Coordinate2D>

Implementation of the Board interface for a 2d square board. The board size is rows x cols and each coordinate can have upto one Piece2D.

Constructors

Board2D
Link copied to clipboard
fun Board2D(rows: Int, cols: Int, outOfBoundsRegion: Region2D? = null)

Functions

addPiece
Link copied to clipboard
open override fun addPiece(coordinate: Coordinate2D, piece: Piece2D)
clearBoard
Link copied to clipboard
open override fun clearBoard()
Reinitialise the board by assigning null to all valid coordinate of the board
equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
getBoardState
Link copied to clipboard
open override fun getBoardState(): Map<Coordinate2D, Piece2D?>
Returns the current status of the board in terms of board
getPiece
Link copied to clipboard
open override fun getPiece(coordinate: Coordinate2D): Piece2D?
Returns the piece placed on a given coordinate by reference
getPieceCoordinate
Link copied to clipboard
open override fun getPieceCoordinate(piece: Piece2D): Coordinate2D?
Returns the coordinate of a given piece by reference
getPieces
Link copied to clipboard
open override fun getPieces(): List<Pair<Piece2D, Coordinate2D>>
Returns a list of pairs of all pieces and the corresponding coordinate that the piece is placed on
open override fun getPieces(player: Player): List<Pair<Piece2D, Coordinate2D>>
Returns a list of pairs of all pieces that a given player owns and the corresponding coordinate that the piece is placed on
hashCode
Link copied to clipboard
open fun hashCode(): Int
isInBounds
Link copied to clipboard
fun isInBounds(coordinate: Coordinate2D): Boolean
Returns true if the given coordinate is valid on the board
removePiece
Link copied to clipboard
open override fun removePiece(coordinate: Coordinate2D, piece: Piece2D)
toString
Link copied to clipboard
open fun toString(): String

Properties

cols
Link copied to clipboard
val cols: Int
the number of columns
rows
Link copied to clipboard
val rows: Int
the number of rows