AbstractChess2D

abstract class AbstractChess2D(rules: List<SpecialRules2D<AbstractChess2D>>, endConditions: List<EndCondition2D<AbstractChess2D>>, startPlayer: Int) : AbstractChess<Board2D, MoveGenerator2D, Piece2D, Coordinate2D> , GameType2D

Represents a standard n-player game, which contains no special rules and standard end conditions.

Constructors

AbstractChess2D
Link copied to clipboard
fun AbstractChess2D(rules: List<SpecialRules2D<AbstractChess2D>> = listOf(), endConditions: List<EndCondition2D<AbstractChess2D>> = listOf(StandardEndConditions()), startPlayer: Int = 0)

Functions

concede
Link copied to clipboard
abstract fun concede(player: Player)
Sets the concedeWinner to opponent (a player that is not current player)
equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
getCurrentPlayer
Link copied to clipboard
open fun getCurrentPlayer(): Player
Returns the current player
getNextPlayer
Link copied to clipboard
open fun getNextPlayer(): Player
Returns the next player without incrementing the turn.
getOpponentPlayer
Link copied to clipboard
fun getOpponentPlayer(player: Player): Player
getOpponentPlayers
Link copied to clipboard
open fun getOpponentPlayers(player: Player): List<Player>
Returns a list of opponent players for a given player.
getOutcome
Link copied to clipboard
open fun getOutcome(): Outcome?
Returns the outcome of the game for the current player, which can be either Win or Draw (null if the game is not over)
abstract fun getOutcome(player: Player): Outcome?
Returns the outcome of the game for the given player, which can be either Win or Draw (null if the game is not over)
getValidMoves
Link copied to clipboard
open fun getValidMoves(): List<Move<Board2D, MoveGenerator2D, Piece2D, Coordinate2D>>
Returns a list of all possible valid moves of the current player
abstract fun getValidMoves(player: Player): List<Move<Board2D, MoveGenerator2D, Piece2D, Coordinate2D>>
Returns a list of all possible valid moves of the given player
hashCode
Link copied to clipboard
open fun hashCode(): Int
inCheck
Link copied to clipboard
abstract fun inCheck(player: Player): Boolean
Returns if the given player's Royal piece is is check or not, assuming that the Royal piece is present on the board.
initBoard
Link copied to clipboard
abstract fun initBoard()
Initialises the board Places pieces on the initial position of the board
initGame
Link copied to clipboard
abstract fun initGame()
Initialises the game by clearing and initialising the board
isOver
Link copied to clipboard
abstract fun isOver(): Boolean
Returns if the game is over or not
makeMove
Link copied to clipboard
abstract fun makeMove(move: Move<Board2D, MoveGenerator2D, Piece2D, Coordinate2D>)
Makes the given move on the current board and add the move to the move log.
nextPlayer
Link copied to clipboard
open fun nextPlayer()
Increments the turn
playerMakeMove
Link copied to clipboard
open fun playerMakeMove(move: Move<Board2D, MoveGenerator2D, Piece2D, Coordinate2D>)
Makes a given move and increments the turn
prevPlayer
Link copied to clipboard
open fun prevPlayer()
Decrements the turn
toString
Link copied to clipboard
open fun toString(): String
undoMove
Link copied to clipboard
abstract fun undoMove()
Reverts the last move and removes it from the move log.

Properties

board
Link copied to clipboard
abstract val board: Board2D
the board of the game
endConditions
Link copied to clipboard
moveLog
Link copied to clipboard
abstract val moveLog: MutableList<Move<Board2D, MoveGenerator2D, Piece2D, Coordinate2D>>
the list of all moves played
name
Link copied to clipboard
abstract val name: String
the name of the game
players
Link copied to clipboard
abstract val players: List<Player>
the list of all participants of the game
playerTurn
Link copied to clipboard
abstract var playerTurn: Int
the current turn of the game
rules
Link copied to clipboard
seed
Link copied to clipboard
abstract var seed: Double?
the random seed

Inheritors

Checkers
Link copied to clipboard
AntiChess
Link copied to clipboard
BalbosGame
Link copied to clipboard
CapablancaChess
Link copied to clipboard
Chess960
Link copied to clipboard
GrandChess
Link copied to clipboard
StandardChess
Link copied to clipboard
Janggi
Link copied to clipboard
Xiangqi
Link copied to clipboard