public ArrayList<Move> generatePossibleMoves() { ArrayList<Move> ans = new ArrayList<>(); for (Piece pc : pieces) { if (pc.isFinalized()) continue; for (int x = 0; x < 20; x++) { for (int y = 0; y < 20; y++) { Point place = new Point(x, y); Piece p = pc.getCopy(); p.place(x, y); for (int i = 0; i < p.data.rotations; i++) { if (game.getBoard().canPlace(p)) { ans.add(new Move(p, place, this)); } p.rotateCW(); } p.resetRotation(); if (p.data.flip) { p.flipHorizontal(); for (int i = 0; i < p.data.rotations; i++) { if (game.getBoard().canPlace(p)) { ans.add(new Move(p, place, this)); } p.rotateCW(); } p.resetRotation(); } } } } possibleMoves = ans; return ans; }