MCPcopy Create free account
hub / github.com/coding-parrot/chess-engine / removeUnusedEnpassant

Method removeUnusedEnpassant

src/main/java/game/Board.java:593–614  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

591 }
592
593 private void removeUnusedEnpassant() {
594 if (!moveList.isEmpty()) {
595 final Move previousMoveOfCurrentPlayer = moveList.get(moveList.size() - 1);
596 if (PieceType.PAWN.equals(previousMoveOfCurrentPlayer.piece.pieceType)) {
597 final Piece pawnLastMoved = previousMoveOfCurrentPlayer.piece;
598 if (Math.abs(previousMoveOfCurrentPlayer.target.row - pawnLastMoved.position.row) == 2) {
599 final int row = previousMoveOfCurrentPlayer.target.row;
600 for (int j = -1; j <= 1; j = j + 2) {
601 int col = previousMoveOfCurrentPlayer.target.col + j;
602 if (Utils.withinBoardLimits(row, col)) {
603 if (!isEmpty(row, col)) {
604 final Piece pawn = getPiece(row, col);
605 if (pawn.sameType(PieceType.PAWN) && pawn.color != previousMoveOfCurrentPlayer.piece.color) {
606 removeMoves(pawn.position);
607 }
608 }
609 }
610 }
611 }
612 }
613 }
614 }
615
616 private void removeMoves(Cell position) {
617 moves.remove(position);

Callers 1

makeMoveMethod · 0.95

Calls 7

isEmptyMethod · 0.95
withinBoardLimitsMethod · 0.95
getPieceMethod · 0.95
sameTypeMethod · 0.95
removeMovesMethod · 0.95
getMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected