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

Method copy

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

Source from the content-addressed store, hash-verified

648 }
649
650 public Board copy() {
651 final Board board = new Board();
652 pieces.forEach(board.pieces::put);
653 playerPieces.forEach((color, pieces) -> board.playerPieces.put(color, new ArrayList<>(pieces)));
654 moves.forEach((cell, moves) -> board.moves.put(cell, new HashSet<>(moves)));
655 guards.forEach((cell, moves) -> board.guards.put(cell, new HashSet<>(moves)));
656 System.arraycopy(positions, 0, board.positions, 0, positions.length);
657 board.positionIndex = positionIndex;
658 board.moveList.addAll(moveList);
659 System.arraycopy(kings, 0, board.kings, 0, 2);
660 for (int i = 0; i < 2; i++) {
661 System.arraycopy(canCastle[i], 0, board.canCastle[i], 0, 2);
662 }
663 board.previousMove = previousMove;
664 board.zobristHash = zobristHash;
665 board.playerToMove = playerToMove;
666 board.isThreeFoldRepetition = isThreeFoldRepetition;
667 board.halfMoves = halfMoves;
668 board.fiftyMoveDraw = fiftyMoveDraw;
669 board.inCheck = inCheck;
670 return board;
671 }
672
673 //todo: idea: Should we compare a list of positions and choose the best? We do not evaluate positions in isolation,
674 // but rather rank them by comparing the top 20 positions possible

Callers 8

captureOnEdgeMethod · 0.95
kingAndQueenOutMethod · 0.95
kingAndKnightOutMethod · 0.95
kingAndPawnOutMethod · 0.95
otherBoardMethod · 0.95
countAllMovesMethod · 0.80
minMaxMethod · 0.80
alphaBetaMethod · 0.80

Calls

no outgoing calls

Tested by 5

captureOnEdgeMethod · 0.76
kingAndQueenOutMethod · 0.76
kingAndKnightOutMethod · 0.76
kingAndPawnOutMethod · 0.76
otherBoardMethod · 0.76