()
| 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 |
no outgoing calls