refactor: NCS-22 NCS-23 reworked modules and tests #17
@@ -1,29 +1,33 @@
|
||||
package de.nowchess.rules
|
||||
|
||||
import de.nowchess.chess.{Move, Situation, Square}
|
||||
import de.nowchess.api.game.GameContext
|
||||
import de.nowchess.api.board.Square
|
||||
import de.nowchess.api.move.Move
|
||||
|
||||
/** Extension point for chess rule variants. Implement to support Chess960, etc. */
|
||||
/** Extension point for chess rule variants (standard, Chess960, etc.).
|
||||
* All rule queries are stateless: given a GameContext, return the answer.
|
||||
*/
|
||||
trait RuleSet:
|
||||
/** All pseudo-legal moves for the piece on `square` (ignores check). */
|
||||
def candidateMoves(situation: Situation, square: Square): List[Move]
|
||||
def candidateMoves(context: GameContext, square: Square): List[Move]
|
||||
|
||||
/** Legal moves for `square`: candidates that don't leave own king in check. */
|
||||
def legalMoves(situation: Situation, square: Square): List[Move]
|
||||
def legalMoves(context: GameContext, square: Square): List[Move]
|
||||
|
||||
/** All legal moves for the side to move. */
|
||||
def allLegalMoves(situation: Situation): List[Move]
|
||||
def allLegalMoves(context: GameContext): List[Move]
|
||||
|
||||
/** True if the side to move's king is in check. */
|
||||
def isCheck(situation: Situation): Boolean
|
||||
def isCheck(context: GameContext): Boolean
|
||||
|
||||
/** True if the side to move is in check and has no legal moves. */
|
||||
def isCheckmate(situation: Situation): Boolean
|
||||
def isCheckmate(context: GameContext): Boolean
|
||||
|
||||
/** True if the side to move is not in check and has no legal moves. */
|
||||
def isStalemate(situation: Situation): Boolean
|
||||
def isStalemate(context: GameContext): Boolean
|
||||
|
||||
/** True if neither side has enough material to checkmate. */
|
||||
def isInsufficientMaterial(situation: Situation): Boolean
|
||||
def isInsufficientMaterial(context: GameContext): Boolean
|
||||
|
||||
/** True if halfMoveClock >= 100 (50-move rule). */
|
||||
def isFiftyMoveRule(situation: Situation): Boolean
|
||||
def isFiftyMoveRule(context: GameContext): Boolean
|
||||
|
||||
Reference in New Issue
Block a user