private void rotate() { final Coordinate c = randomNormal(); final Piece piece = pieces[c.getY()][c.getX()]; if (piece.getType() == PieceType.NORMAL) { piece.rotate((int) GaUtil.random(1, 3)); } }
private Direction randomDirection() { final int ordinal = (int) GaUtil.random(0, 3); for (final Direction direction : Direction.values()) { if (direction.ordinal() == ordinal) { return direction; } } throw new IllegalStateException(); }
private Coordinate randomBorder() { final int number = (int) GaUtil.random(1, boardSize - 2); return directionCoordinate(number, randomDirection()); }
private Coordinate randomNormal() { final int x = (int) GaUtil.random(1, boardSize - 2); final int y = (int) GaUtil.random(1, boardSize - 2); return Coordinate.from(x, y); }