Module app
Package app.chess

Class PredicateChecker

java.lang.Object
app.chess.PredicateChecker

final class PredicateChecker extends Object
  • Method Details

    • safelyCheckPredicate

      public static <T> T safelyCheckPredicate(Function<ChessPiece[][],T> predicate, ChessMove move, ChessPiece[][] board, StateManager manager, Mover mover)
      A function that performs a given move, checks predicate, rolls back said move and then returns result of said predicate. Please note that internal states of pieces/pawns are also going to be modified while performing the move (but they will be rolled back as well).
      Type Parameters:
      T - Return type of the predicate.
      Parameters:
      predicate - A predicate to be checked for; MUST NOT modify board in any way. If it does modify board, its predicate's responsibility to properly roll it back (including ChessPieces internal states).
      move - A legal move that is to be performed. Note that there are no checks performed, if illegal move is passed the result is going to be undefined behaviour.
      board - A board on which to perform move. It should match the first argument of the predicate, otherwise it makes absolutely no sense.
      manager - StateManager of the game.
      Returns:
      The result of performing the predicate on the modified board.