MCPcopy Index your code
hub / github.com/coding-parrot/chess-engine / makeMove

Method makeMove

src/main/java/game/Board.java:406–430  ·  view source on GitHub ↗
(Move move)

Source from the content-addressed store, hash-verified

404 }
405
406 public void makeMove(Move move) {
407 //remove captured pieces
408 final Set<Cell> affectedCells = new HashSet<>();
409 if (move.captureMove) {
410 final Piece delete = pieces.remove(move.captureCell);
411 playerPieces.get(Color.opponent(move.piece.color)).remove(delete);
412 updateHashForRemove(delete);
413 affectedCells.add(move.captureCell);
414 }
415 pieces.remove(move.piece.position);
416 playerPieces.get(move.piece.color).remove(move.piece);
417 updateHashForRemove(move.piece);
418 affectedCells.add(move.piece.position);
419 for (final Cell affectedCell : affectedCells) {
420 //todo: don't remove all the moves and guards, just the ones affected
421 updateForClearCell(affectedCell);
422 }
423 updateForBlockedCell(move);
424 for (final Piece king : kings) {
425 updateKingMoves(move, king);
426 }
427 removeUnusedEnpassant();
428 moveOrPromote(move);
429 postMoveUpdates(move);
430 }
431
432 private void updateKingMoves(Move move, Piece king) {
433 final Cell target = move.target;

Callers 15

captureOnEdgeMethod · 0.95
canCastleLeftMethod · 0.95
canCastleRightMethod · 0.95
castleBlockedLeftSideMethod · 0.95
captureAndReturnCheckMethod · 0.95
castleFailMethod · 0.95
pawnIsPinnedMethod · 0.95
doubleCheckMethod · 0.95
pawnPromotionMethod · 0.95

Calls 9

opponentMethod · 0.95
updateHashForRemoveMethod · 0.95
updateForClearCellMethod · 0.95
updateForBlockedCellMethod · 0.95
updateKingMovesMethod · 0.95
removeUnusedEnpassantMethod · 0.95
moveOrPromoteMethod · 0.95
postMoveUpdatesMethod · 0.95
getMethod · 0.45

Tested by 15

captureOnEdgeMethod · 0.76
canCastleLeftMethod · 0.76
canCastleRightMethod · 0.76
castleBlockedLeftSideMethod · 0.76
captureAndReturnCheckMethod · 0.76
castleFailMethod · 0.76
pawnIsPinnedMethod · 0.76
doubleCheckMethod · 0.76
pawnPromotionMethod · 0.76