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

Method getMoveList

src/main/java/pieces/Knight.java:21–37  ·  view source on GitHub ↗
(Board board, Piece piece)

Source from the content-addressed store, hash-verified

19 };
20
21 public static LegalMoves getMoveList(Board board, Piece piece) {
22 final Set<Move> moves = new HashSet<>(8);
23 final Set<Move> guards = new HashSet<>(8);
24 for (final int[] coordinate : diff) {
25 final int row = piece.position.row + coordinate[0], col = piece.position.col + coordinate[1];
26 if (Utils.withinBoardLimits(row, col)) {
27 if (board.isEmpty(row, col)) {
28 moves.add(Move.get(piece, Cell.get(row, col), false));
29 } else if (board.getPiece(row, col).color != piece.color) {
30 moves.add(Move.get(piece, Cell.get(row, col), true));
31 } else {
32 guards.add(Move.get(piece, Cell.get(row, col), false));
33 }
34 }
35 }
36 return new LegalMoves(moves, guards);
37 }
38}

Callers 2

getMoveListMethod · 0.95
getLegalMovesMethod · 0.95

Calls 5

withinBoardLimitsMethod · 0.95
getMethod · 0.95
getMethod · 0.95
isEmptyMethod · 0.80
getPieceMethod · 0.80

Tested by

no test coverage detected