public static void addCraters(IBoard board,int minRadius,int maxRadius,int minCraters,int maxCraters){
  int numberCraters=minCraters;
  if (maxCraters > minCraters) {
    numberCraters+=Compute.randomInt(maxCraters - minCraters);
  }
  int width=board.getWidth();
  int height=board.getHeight();
  Map<Coords,Integer> usedHexes=new HashMap<>();
  for (int i=0; i < numberCraters; i++) {
    Point center=new Point(Compute.randomInt(width),Compute.randomInt(height));
    int radius=Compute.randomInt(maxRadius - minRadius) + minRadius;
    int divisor=Compute.randomInt(2) + 8;
    int radiusM=radius * 30;
    int maxDepthM=Math.max(6,radiusM / divisor);
    int maxDepth=maxDepthM / 6;
    int cratDepth[]=new int[radius];
    for (int x=0; x < radius; x++) {
      cratDepth[x]=craterProfile(x,radius,maxDepth);
    }
    for (int h=0; h < height; h++) {
      for (int w=0; w < width; w++) {
        int distance=(int)distance(center,new Point(w,h));
        if (distance < radius) {
          IHex field=board.getHex(w,h);
          int baseElevation;
          if (usedHexes.containsKey(field.getCoords())) {
            baseElevation=usedHexes.get(field.getCoords());
          }
 else {
            baseElevation=field.getLevel();
            usedHexes.put(field.getCoords(),baseElevation);
          }
          int newElevation=baseElevation + cratDepth[distance];
          field.setLevel(Math.min(newElevation,field.getLevel()));
        }
      }
    }
  }
}

public static void addCraters ( IBoard board , int minRadius , int maxRadius , int minCraters , int maxCraters ) { int numberCraters = minCraters ; if ( maxCraters > minCraters ) { numberCraters += Compute . randomInt ( maxCraters - minCraters ) ; } int width = board . getWidth ( ) ; int height = board . getHeight ( ) ; Map < Coords , Integer > usedHexes = new HashMap < > ( ) ; for ( int i = 0 ; i < numberCraters ; i ++ ) { Point center = new Point ( Compute . randomInt ( width ) , Compute . randomInt ( height ) ) ; int radius = Compute . randomInt ( maxRadius - minRadius ) + minRadius ; int divisor = Compute . randomInt ( 2 ) + 8 ; int radiusM = radius * 30 ; int maxDepthM = Math . max ( 6 , radiusM / divisor ) ; int maxDepth = maxDepthM / 6 ; int cratDepth [ ] = new int [ radius ] ; for ( int x = 0 ; x < radius ; x ++ ) { cratDepth [ x ] = craterProfile ( x , radius , maxDepth ) ; } for ( int h = 0 ; h < height ; h ++ ) { for ( int w = 0 ; w < width ; w ++ ) { int distance = ( int ) distance ( center , new Point ( w , h ) ) ; if ( distance < radius ) { IHex field = board . getHex ( w , h ) ; int baseElevation ; if ( usedHexes . containsKey ( field . getCoords ( ) ) ) { baseElevation = usedHexes . get ( field . getCoords ( ) ) ; } else { baseElevation = field . getLevel ( ) ; usedHexes . put ( field . getCoords ( ) , baseElevation ) ; } int newElevation = baseElevation + cratDepth [ distance ] ; field . setLevel ( Math . min ( newElevation , field . getLevel ( ) ) ) ; } } } } }
add a crater to the board
