private void resetPiece(OrientedPiece[] pieces, EternityBoard board, int x, int y) { OrientedPiece piece = (OrientedPiece) board.getPieceAt(x, y); if (piece == null) { throw new RuntimeException("Piece to rever not here !"); } if (!piece.isLock()) { board.setPieceAt(null, x, y); // La pièce doit être dans bon orientation et dans le bonne ordre // dans la liste piece.resetOrientation(); pieces[piece.getId()] = piece; } }
public HistoPlacing revert(OrientedPiece[] pieces, EternityBoard board) { resetPiece(pieces, board, x * 2, y * 2); resetPiece(pieces, board, x * 2 + 1, y * 2); resetPiece(pieces, board, x * 2 + 1, y * 2 + 1); resetPiece(pieces, board, x * 2, y * 2 + 1); if (nbTry + 1 >= heat) { for (int i = 0; i < board.getSIZE() / 2; i++) { for (int j = 0; j < board.getSIZE() / 2; j++) { if (this.g2Possible[i][j] != null) { this.g2Possible[i][j].clear(); } } } return this.previous.revert(pieces, board); } this.isReverted = true; return this; }