Example #1
0
 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));
   }
 }
Example #2
0
 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();
 }
Example #3
0
 private Coordinate randomBorder() {
   final int number = (int) GaUtil.random(1, boardSize - 2);
   return directionCoordinate(number, randomDirection());
 }
Example #4
0
 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);
 }