static int mineralTypeFor(Outcrop outcrop, World world) {
    //
    //  First, we sum up the total for each mineral type in the surrounding
    //  area (including the rockiness of the terrain.)
    float amounts[] = new float[4] ;
    int numTiles = 0 ;
    for (Tile t : outcrop.surrounds()) if (t != null) {
      final byte type = world.terrain().mineralType(t) ;
      final float amount = world.terrain().mineralsAt(t, type) ;
      amounts[type] += amount ;
      amounts[0] += t.habitat().rockiness ;
      numTiles++ ;
    }
    amounts[0] *= Rand.num() / 2f ;
    //
    //  Then perform a weighted pick from the range of types (having tweaked
    //  the odds a little...)
    float sumAmounts = 0 ;
    for (int i = 4 ; i-- > 0 ;) {
      final float a = amounts[i] ;
      sumAmounts += (amounts[i] = (a + (a * a)) / 2) ;
    }
    float pickRoll = Rand.num() * sumAmounts ;
    int pickType = 0 ;
    int type = 0 ; for (float f : amounts) {
      if (pickRoll < f) { pickType = type ; break ; }
      pickRoll -= f ;
      type++ ;
    }
    return pickType ;
  }