public static ArrayList generateDistinctSpeakers(int vectorSize, int vectorsCount, int speakersCount) { java.util.Random random = new java.util.Random(); ArrayList arrayList = new ArrayList(); float[] array = new float[vectorSize]; for (int i = 0; i < speakersCount; i++) { for (int j = 0; j < vectorSize; j++) { array[j] = (float)(i + 1) / 10f + (float)random.nextInt(5000) / 50000f; } array[0] = 3f + (float)(i + 1) / 10f; for (int j = 0; j < vectorsCount; j++) { float[] array2 = new float[vectorSize]; for (int k = 0; k < vectorSize; k++) { array2[k] = array[k] + (float)random.nextInt(5000) / 50000f; } arrayList.add(array2); } } return(arrayList); }
public override void updateTick(World world, int i, int j, int k, Random random) { if (world.singleplayerWorld) { return; } if (world.getBlockLightValue(i, j + 1, k) < 4 && world.getBlockMaterial(i, j + 1, k).getCanBlockGrass()) { if (random.nextInt(4) != 0) { return; } world.setBlockWithNotify(i, j, k, dirt.blockID); } else if (world.getBlockLightValue(i, j + 1, k) >= 9) { int l = (i + random.nextInt(3)) - 1; int i1 = (j + random.nextInt(5)) - 3; int j1 = (k + random.nextInt(3)) - 1; if (world.getBlockId(l, i1, j1) == dirt.blockID && world.getBlockLightValue(l, i1 + 1, j1) >= 4 && !world.getBlockMaterial(l, i1 + 1, j1).getCanBlockGrass()) { world.setBlockWithNotify(l, i1, j1, grass.blockID); } } }
public Font getFont(int index) { java.util.Random r = new java.util.Random(); string family = families[r.nextInt(families.Count)]; bool bold = r.nextBoolean() && randomStyle; int size = minSize; if (maxSize - minSize > 0) { size += r.nextInt(maxSize - minSize); } return(new Font(family, bold ? Font.BOLD : Font.PLAIN, size)); }
public override WorldGenerator getRandomWorldGenForTrees(Random random) { if (random.nextInt(5) == 0) { return new WorldGenForest(); } if (random.nextInt(3) == 0) { return new WorldGenBigTree(); } else { return new WorldGenTrees(); } }
public override bool generate(World world, Random random, int i, int j, int k) { if (world.getBlockMaterial(i, j, k) != Material.water) { return false; } float f = random.nextFloat()*3.141593F; double d = (i + 8) + (MathHelper.sin(f)*numberOfBlocks)/8F; double d1 = (i + 8) - (MathHelper.sin(f)*numberOfBlocks)/8F; double d2 = (k + 8) + (MathHelper.cos(f)*numberOfBlocks)/8F; double d3 = (k + 8) - (MathHelper.cos(f)*numberOfBlocks)/8F; double d4 = j + random.nextInt(3) + 2; double d5 = j + random.nextInt(3) + 2; for (int l = 0; l <= numberOfBlocks; l++) { double d6 = d + ((d1 - d)*l)/numberOfBlocks; double d7 = d4 + ((d5 - d4)*l)/numberOfBlocks; double d8 = d2 + ((d3 - d2)*l)/numberOfBlocks; double d9 = (random.nextDouble()*numberOfBlocks)/16D; double d10 = (MathHelper.sin((l*3.141593F)/numberOfBlocks) + 1.0F)*d9 + 1.0D; double d11 = (MathHelper.sin((l*3.141593F)/numberOfBlocks) + 1.0F)*d9 + 1.0D; for (var i1 = (int) (d6 - d10/2D); i1 <= (int) (d6 + d10/2D); i1++) { for (var j1 = (int) (d7 - d11/2D); j1 <= (int) (d7 + d11/2D); j1++) { for (var k1 = (int) (d8 - d10/2D); k1 <= (int) (d8 + d10/2D); k1++) { double d12 = ((i1 + 0.5D) - d6)/(d10/2D); double d13 = ((j1 + 0.5D) - d7)/(d11/2D); double d14 = ((k1 + 0.5D) - d8)/(d10/2D); if (d12*d12 + d13*d13 + d14*d14 >= 1.0D) { continue; } int l1 = world.getBlockId(i1, j1, k1); if (l1 == Block.sand.blockID) { world.setBlock(i1, j1, k1, clayBlockId); } } } } } return true; }
public override int idDropped(int i, Random random) { if (random.nextInt(10) == 0) { return Item.flint.shiftedIndex; } else { return blockID; } }
public override int quantityDropped(Random random) { if (blockID == oreLapis.blockID) { return 4 + random.nextInt(5); } else { return 1; } }
public override WorldGenerator getRandomWorldGenForTrees(Random random) { if (random.nextInt(3) == 0) { return new WorldGenTaiga1(); } else { return new WorldGenTaiga2(); } }
public override bool generate(World world, Random random, int i, int j, int k) { for (int l = 0; l < 20; l++) { int i1 = (i + random.nextInt(4)) - random.nextInt(4); int j1 = j; int k1 = (k + random.nextInt(4)) - random.nextInt(4); if (!world.isAirBlock(i1, j1, k1) || world.getBlockMaterial(i1 - 1, j1 - 1, k1) != Material.water && world.getBlockMaterial(i1 + 1, j1 - 1, k1) != Material.water && world.getBlockMaterial(i1, j1 - 1, k1 - 1) != Material.water && world.getBlockMaterial(i1, j1 - 1, k1 + 1) != Material.water) { continue; } int l1 = 2 + random.nextInt(random.nextInt(3) + 1); for (int i2 = 0; i2 < l1; i2++) { if (Block.reed.canBlockStay(world, i1, j1 + i2, k1)) { world.setBlock(i1, j1 + i2, k1, Block.reed.blockID); } } } return true; }
public void func_21027_b(World world, int i, int j, int k, Random random) { world.setBlock(i, j, k, 0); object obj = new WorldGenTrees(); if (random.nextInt(10) == 0) { obj = new WorldGenBigTree(); } if (!((WorldGenerator) (obj)).generate(world, random, i, j, k)) { world.setBlock(i, j, k, blockID); } }
public static int func_21066_a(Random random) { int i = random.nextInt(100); if (i < 5) { return 15; } if (i < 10) { return 7; } return i >= 15 ? 0 : 8; }
public override void updateTick(World world, int i, int j, int k, Random random) { base.updateTick(world, i, j, k, random); if (world.getBlockLightValue(i, j + 1, k) >= 9 && random.nextInt(5) == 0) { int l = world.getBlockMetadata(i, j, k); if (l < 15) { world.setBlockMetadataWithNotify(i, j, k, l + 1); } else { func_21027_b(world, i, j, k, random); } } }
public override bool generate(World world, Random random, int i, int j, int k) { for (int l = 0; l < 64; l++) { int i1 = (i + random.nextInt(8)) - random.nextInt(8); int j1 = (j + random.nextInt(4)) - random.nextInt(4); int k1 = (k + random.nextInt(8)) - random.nextInt(8); if (world.isAirBlock(i1, j1, k1) && world.getBlockId(i1, j1 - 1, k1) == Block.grass.blockID && Block.pumpkin.canPlaceBlockAt(world, i1, j1, k1)) { world.setBlockAndMetadata(i1, j1, k1, Block.pumpkin.blockID, random.nextInt(4)); } } return true; }
public NoiseGeneratorPerlin(Random random) { permutations = new int[512]; xCoord = random.nextDouble()*256D; yCoord = random.nextDouble()*256D; zCoord = random.nextDouble()*256D; for (int i = 0; i < 256; i++) { permutations[i] = i; } for (int j = 0; j < 256; j++) { int k = random.nextInt(256 - j) + j; int l = permutations[j]; permutations[j] = permutations[k]; permutations[k] = l; permutations[j + 256] = permutations[j]; } }
public NoiseGenerator2(Random random) { field_4316_e = new int[512]; field_4313_a = random.nextDouble()*256D; field_4312_b = random.nextDouble()*256D; field_4318_c = random.nextDouble()*256D; for (int i = 0; i < 256; i++) { field_4316_e[i] = i; } for (int j = 0; j < 256; j++) { int k = random.nextInt(256 - j) + j; int l = field_4316_e[j]; field_4316_e[j] = field_4316_e[k]; field_4316_e[k] = l; field_4316_e[j + 256] = field_4316_e[j]; } }
public override bool generate(World world, Random random, int i, int j, int k) { for (int l = 0; l < 64; l++) { int i1 = (i + random.nextInt(8)) - random.nextInt(8); int j1 = (j + random.nextInt(4)) - random.nextInt(4); int k1 = (k + random.nextInt(8)) - random.nextInt(8); if (world.isAirBlock(i1, j1, k1) && world.getBlockId(i1, j1 - 1, k1) == Block.bloodStone.blockID) { world.setBlockWithNotify(i1, j1, k1, Block.fire.blockID); } } return true; }
public override bool generate(World world, Random random, int i, int j, int k) { for (int l = 0; l < 10; l++) { int i1 = (i + random.nextInt(8)) - random.nextInt(8); int j1 = (j + random.nextInt(4)) - random.nextInt(4); int k1 = (k + random.nextInt(8)) - random.nextInt(8); if (!world.isAirBlock(i1, j1, k1)) { continue; } int l1 = 1 + random.nextInt(random.nextInt(3) + 1); for (int i2 = 0; i2 < l1; i2++) { if (Block.cactus.canBlockStay(world, i1, j1 + i2, k1)) { world.setBlock(i1, j1 + i2, k1, Block.cactus.blockID); } } } return true; }
public override bool generate(World world, Random random, int i, int j, int k) { for (int l = 0; l < 64; l++) { int i1 = (i + random.nextInt(8)) - random.nextInt(8); int j1 = (j + random.nextInt(4)) - random.nextInt(4); int k1 = (k + random.nextInt(8)) - random.nextInt(8); if (world.isAirBlock(i1, j1, k1) && (Block.blocksList[plantBlockId]).canBlockStay(world, i1, j1, k1)) { world.setBlock(i1, j1, k1, plantBlockId); } } return true; }
public override void updateTick(World world, int i, int j, int k, Random random) { if (random.nextInt(5) == 0) { if (isWaterNearby(world, i, j, k)) { world.setBlockMetadataWithNotify(i, j, k, 7); } else { int l = world.getBlockMetadata(i, j, k); if (l > 0) { world.setBlockMetadataWithNotify(i, j, k, l - 1); } else if (!isCropsNearby(world, i, j, k)) { world.setBlockWithNotify(i, j, k, dirt.blockID); } } } }
public override int quantityDropped(Random random) { return 4 + random.nextInt(2); }
public virtual WorldGenerator getRandomWorldGenForTrees(Random random) { if (random.nextInt(10) == 0) { return new WorldGenBigTree(); } else { return new WorldGenTrees(); } }
public override bool generate(World world, Random random, int i, int j, int k) { byte byte0 = 3; int l = random.nextInt(2) + 2; int i1 = random.nextInt(2) + 2; int j1 = 0; for (int k1 = i - l - 1; k1 <= i + l + 1; k1++) { for (int j2 = j - 1; j2 <= j + byte0 + 1; j2++) { for (int i3 = k - i1 - 1; i3 <= k + i1 + 1; i3++) { Material material = world.getBlockMaterial(k1, j2, i3); if (j2 == j - 1 && !material.isSolid()) { return false; } if (j2 == j + byte0 + 1 && !material.isSolid()) { return false; } if ((k1 == i - l - 1 || k1 == i + l + 1 || i3 == k - i1 - 1 || i3 == k + i1 + 1) && j2 == j && world.isAirBlock(k1, j2, i3) && world.isAirBlock(k1, j2 + 1, i3)) { j1++; } } } } if (j1 < 1 || j1 > 5) { return false; } for (int l1 = i - l - 1; l1 <= i + l + 1; l1++) { for (int k2 = j + byte0; k2 >= j - 1; k2--) { for (int j3 = k - i1 - 1; j3 <= k + i1 + 1; j3++) { if (l1 == i - l - 1 || k2 == j - 1 || j3 == k - i1 - 1 || l1 == i + l + 1 || k2 == j + byte0 + 1 || j3 == k + i1 + 1) { if (k2 >= 0 && !world.getBlockMaterial(l1, k2 - 1, j3).isSolid()) { world.setBlockWithNotify(l1, k2, j3, 0); continue; } if (!world.getBlockMaterial(l1, k2, j3).isSolid()) { continue; } if (k2 == j - 1 && random.nextInt(4) != 0) { world.setBlockWithNotify(l1, k2, j3, Block.cobblestoneMossy.blockID); } else { world.setBlockWithNotify(l1, k2, j3, Block.cobblestone.blockID); } } else { world.setBlockWithNotify(l1, k2, j3, 0); } } } } for (int i2 = 0; i2 < 2; i2++) { for (int l2 = 0; l2 < 3; l2++) { int k3 = (i + random.nextInt(l*2 + 1)) - l; int l3 = j; int i4 = (k + random.nextInt(i1*2 + 1)) - i1; if (!world.isAirBlock(k3, l3, i4)) { continue; } int j4 = 0; if (world.getBlockMaterial(k3 - 1, l3, i4).isSolid()) { j4++; } if (world.getBlockMaterial(k3 + 1, l3, i4).isSolid()) { j4++; } if (world.getBlockMaterial(k3, l3, i4 - 1).isSolid()) { j4++; } if (world.getBlockMaterial(k3, l3, i4 + 1).isSolid()) { j4++; } if (j4 != 1) { continue; } world.setBlockWithNotify(k3, l3, i4, Block.crate.blockID); var tileentitychest = (TileEntityChest) world.getBlockTileEntity(k3, l3, i4); int k4 = 0; do { if (k4 >= 8) { goto label0; } ItemStack itemstack = pickCheckLootItem(random); if (itemstack != null) { tileentitychest.setInventorySlotContents( random.nextInt(tileentitychest.getSizeInventory()), itemstack); } k4++; } while (true); } label0: ; } world.setBlockWithNotify(i, j, k, Block.mobSpawner.blockID); var tileentitymobspawner = (TileEntityMobSpawner) world.getBlockTileEntity(i, j, k); tileentitymobspawner.setMobID(pickMobSpawner(random)); return true; }
private ItemStack pickCheckLootItem(Random random) { int i = random.nextInt(11); if (i == 0) { return new ItemStack(Item.saddle); } if (i == 1) { return new ItemStack(Item.ingotIron, random.nextInt(4) + 1); } if (i == 2) { return new ItemStack(Item.bread); } if (i == 3) { return new ItemStack(Item.wheat, random.nextInt(4) + 1); } if (i == 4) { return new ItemStack(Item.gunpowder, random.nextInt(4) + 1); } if (i == 5) { return new ItemStack(Item.silk, random.nextInt(4) + 1); } if (i == 6) { return new ItemStack(Item.bucketEmpty); } if (i == 7 && random.nextInt(100) == 0) { return new ItemStack(Item.appleGold); } if (i == 8 && random.nextInt(2) == 0) { return new ItemStack(Item.redstone, random.nextInt(4) + 1); } if (i == 9 && random.nextInt(10) == 0) { return new ItemStack(Item.itemsList[Item.record13.shiftedIndex + random.nextInt(2)]); } else { return null; } }
public override bool generate(World world, Random random, int i, int j, int k) { int l = random.nextInt(3) + 4; bool flag = true; if (j < 1 || j + l + 1 > 128) { return false; } for (int i1 = j; i1 <= j + 1 + l; i1++) { byte byte0 = 1; if (i1 == j) { byte0 = 0; } if (i1 >= (j + 1 + l) - 2) { byte0 = 2; } for (int i2 = i - byte0; i2 <= i + byte0 && flag; i2++) { for (int l2 = k - byte0; l2 <= k + byte0 && flag; l2++) { if (i1 >= 0 && i1 < 128) { int j3 = world.getBlockId(i2, i1, l2); if (j3 != 0 && j3 != Block.leaves.blockID) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } int j1 = world.getBlockId(i, j - 1, k); if (j1 != Block.grass.blockID && j1 != Block.dirt.blockID || j >= 128 - l - 1) { return false; } world.setBlock(i, j - 1, k, Block.dirt.blockID); for (int k1 = (j - 3) + l; k1 <= j + l; k1++) { int j2 = k1 - (j + l); int i3 = 1 - j2/2; for (int k3 = i - i3; k3 <= i + i3; k3++) { int l3 = k3 - i; for (int i4 = k - i3; i4 <= k + i3; i4++) { int j4 = i4 - k; if ((Math.abs(l3) != i3 || Math.abs(j4) != i3 || random.nextInt(2) != 0 && j2 != 0) && !Block.opaqueCubeLookup[world.getBlockId(k3, k1, i4)]) { world.setBlock(k3, k1, i4, Block.leaves.blockID); } } } } for (int l1 = 0; l1 < l; l1++) { int k2 = world.getBlockId(i, j + l1, k); if (k2 == 0 || k2 == Block.leaves.blockID) { world.setBlock(i, j + l1, k, Block.wood.blockID); } } return true; }
private void UnknownB(int i, int j, byte[] abyte0, double d, double d1, double d2, float f, float f1, float f2, int k, int l, double d3) { double d4 = i * 16 + 8; double d5 = j * 16 + 8; float f3 = 0.0F; float f4 = 0.0F; Random random = new Random(rand.nextLong()); if (l <= 0) { int i1 = field_947_a * 16 - 16; l = i1 - random.nextInt(i1 / 4); } bool flag = false; if (k == -1) { k = l / 2; flag = true; } int j1 = random.nextInt(l / 2) + l / 4; bool flag1 = random.nextInt(6) == 0; for (; k < l; k++) { double d6 = 1.5D + (double)(MathHelper.Sin(((float)k * 3.141592f) / (float)l) * f * 1.0f); double d7 = d6 * d3; float f5 = MathHelper.cos(f2); float f6 = MathHelper.Sin(f2); d += MathHelper.cos(f1) * f5; d1 += f6; d2 += MathHelper.Sin(f1) * f5; if (flag1) { f2 *= 0.92F; } else { f2 *= 0.7F; } f2 += f4 * 0.1F; f1 += f3 * 0.1F; f4 *= 0.9F; f3 *= 0.75F; f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F; f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4F; if (!flag && k == j1 && f > 1.0F) { UnknownB(i, j, abyte0, d, d1, d2, random.nextFloat() * 0.5F + 0.5F, f1 - 1.570796F, f2 / 3F, k, l, 1.0D); UnknownB(i, j, abyte0, d, d1, d2, random.nextFloat() * 0.5F + 0.5F, f1 + 1.570796F, f2 / 3F, k, l, 1.0D); return; } if (!flag && random.nextInt(4) == 0) { continue; } double d8 = d - d4; double d9 = d2 - d5; double d10 = l - k; double d11 = f + 2.0F + 16F; if ((d8 * d8 + d9 * d9) - d10 * d10 > d11 * d11) { return; } if (d < d4 - 16D - d6 * 2D || d2 < d5 - 16D - d6 * 2D || d > d4 + 16D + d6 * 2D || d2 > d5 + 16D + d6 * 2D) { continue; } d8 = MathHelper.floor_double(d - d6) - i * 16 - 1; int k1 = (MathHelper.floor_double(d + d6) - i * 16) + 1; d9 = MathHelper.floor_double(d1 - d7) - 1; int l1 = MathHelper.floor_double(d1 + d7) + 1; d10 = MathHelper.floor_double(d2 - d6) - j * 16 - 1; int i2 = (MathHelper.floor_double(d2 + d6) - j * 16) + 1; if (d8 < 0) d8 = 0; if (k1 > 16) k1 = 16; if (d9 < 1) d9 = 1; if (l1 > 120) l1 = 120; if (d10 < 0) d10 = 0; if (i2 > 16) i2 = 16; for (int j2 = (int)d8; j2 < k1; j2++) { for (int l2 = (int)d10; l2 < i2; l2++) { for (int i3 = l1 + 1; i3 >= d9 - 1; i3--) { int j3 = (j2 * 16 + l2) * 128 + i3; if (i3 < 0 || i3 >= 128) continue; if (abyte0[j3] == (byte)BlockData.Blocks.Still_Water || abyte0[j3] == (byte)BlockData.Blocks.Water) goto cont; if (i3 != d9 - 1 && j2 != d8 && j2 != k1 - 1 && l2 != d10 && l2 != i2 - 1) i3 = (int)d9; } } } for (int k2 = (int)d8; k2 < k1; k2++) { double d12 = (((double)(k2 + i * 16) + 0.5D) - d) / d6; for (int k3 = (int)d10; k3 < i2; k3++) { double d13 = (((double)(k3 + j * 16) + 0.5D) - d2) / d6; int l3 = (k2 * 16 + k3) * 128 + l1; bool flag3 = false; if (d12 * d12 + d13 * d13 >= 1.0D) continue; int i4 = l1 - 1; while (i4 >= d9) { double d14 = (((double)i4 + 0.5D) - d1) / d7; if (d14 > -0.7 && d12 * d12 + d14 * d14 + d13 * d13 < 1.0) { byte byte0 = abyte0[l3]; if (byte0 == (byte)BlockData.Blocks.Grass) { flag3 = true; } if (byte0 == (byte)BlockData.Blocks.Stone || byte0 == (byte)BlockData.Blocks.Dirt || byte0 == (byte)BlockData.Blocks.Grass) { if (i4 < 10) { abyte0[l3] = (byte)BlockData.Blocks.Still_Lava; } else { abyte0[l3] = 0; if (flag3 && abyte0[l3 - 1] == (byte)BlockData.Blocks.Dirt) { abyte0[l3 - 1] = (byte)BlockData.Blocks.Grass; } } } } l3--; i4--; } } } if (flag) { break; } cont: continue; } }
public override bool generate(World world, Random random, int i, int j, int k) { int l = random.nextInt(4) + 6; int i1 = 1 + random.nextInt(2); int j1 = l - i1; int k1 = 2 + random.nextInt(2); bool flag = true; if (j < 1 || j + l + 1 > 128) { return false; } for (int l1 = j; l1 <= j + 1 + l && flag; l1++) { int j2 = 1; if (l1 - j < i1) { j2 = 0; } else { j2 = k1; } for (int l2 = i - j2; l2 <= i + j2 && flag; l2++) { for (int j3 = k - j2; j3 <= k + j2 && flag; j3++) { if (l1 >= 0 && l1 < 128) { int k3 = world.getBlockId(l2, l1, j3); if (k3 != 0 && k3 != Block.leaves.blockID) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } int i2 = world.getBlockId(i, j - 1, k); if (i2 != Block.grass.blockID && i2 != Block.dirt.blockID || j >= 128 - l - 1) { return false; } world.setBlock(i, j - 1, k, Block.dirt.blockID); int k2 = random.nextInt(2); int i3 = 1; bool flag1 = false; for (int l3 = 0; l3 <= j1; l3++) { int j4 = (j + l) - l3; for (int l4 = i - k2; l4 <= i + k2; l4++) { int j5 = l4 - i; for (int k5 = k - k2; k5 <= k + k2; k5++) { int l5 = k5 - k; if ((Math.abs(j5) != k2 || Math.abs(l5) != k2 || k2 <= 0) && !Block.opaqueCubeLookup[world.getBlockId(l4, j4, k5)]) { world.setBlockAndMetadata(l4, j4, k5, Block.leaves.blockID, 1); } } } if (k2 >= i3) { k2 = ((flag1) ? 1 : 0); flag1 = true; if (++i3 > k1) { i3 = k1; } } else { k2++; } } int i4 = random.nextInt(3); for (int k4 = 0; k4 < l - i4; k4++) { int i5 = world.getBlockId(i, j + k4, k); if (i5 == 0 || i5 == Block.leaves.blockID) { world.setBlockAndMetadata(i, j + k4, k, Block.wood.blockID, 1); } } return true; }
private void kMeansClustering(Loader loader, int num) { Pool meansPool = loader.getMeansPool(); ArrayList arrayList = new ArrayList(this.numberOfClusters); ArrayList arrayList2 = new ArrayList(this.numberOfClusters); int num2 = meansPool.size(); int num3 = num; int[] array = new int[this.numberOfClusters]; int num4 = this.numberOfClusters; int num5 = num2; int[] array2 = new int[2]; int num6 = num5; array2[1] = num6; num6 = num4; array2[0] = num6; float[][][] array3 = (float[][][])ByteCodeHelper.multianewarray(typeof(float[][][]).TypeHandle, array2); int num7 = 0; java.util.Random random = new java.util.Random(); for (int i = 0; i < this.numberOfClusters; i++) { int num8 = random.nextInt(num2); arrayList2.add(meansPool.get(num8)); arrayList.add(meansPool.get(num8)); array[i] = 0; } while (num7 == 0 && num3 > 0) { this.corespondingClass = new int[meansPool.size()]; int num9 = this.numberOfClusters; int num10 = num2; array2 = new int[2]; num6 = num10; array2[1] = num6; num6 = num9; array2[0] = num6; float[][][] array4 = (float[][][])ByteCodeHelper.multianewarray(typeof(float[][][]).TypeHandle, array2); for (int i = 0; i < this.numberOfClusters; i++) { arrayList.set(i, arrayList2.get(i)); array[i] = 0; } for (int i = 0; i < meansPool.size(); i++) { float[] array5 = (float[])meansPool.get(i); double num11 = (double)this.euclidianDistance((float[])arrayList.get(0), array5); int num8 = 0; for (int j = 1; j < this.numberOfClusters; j++) { double num12 = (double)this.euclidianDistance((float[])arrayList.get(j), array5); if (num12 < num11) { num11 = num12; num8 = j; } } array4[num8][array[num8]] = array5; this.corespondingClass[i] = num8; int[] array6 = array; num6 = num8; array2 = array6; array2[num6]++; } for (int i = 0; i < this.numberOfClusters; i++) { float[] array7 = new float[((float[])meansPool.get(0)).Length]; if (array[i] > 0) { for (int j = 0; j < array[i]; j++) { for (int k = 0; k < ((float[])meansPool.get(0)).Length; k++) { float[] array8 = array7; num6 = k; float[] array9 = array8; array9[num6] += array4[i][j][k]; } } for (int j = 0; j < ((float[])meansPool.get(0)).Length; j++) { float[] array10 = array7; num6 = j; float[] array9 = array10; array9[num6] /= (float)array[i]; } arrayList2.set(i, array7); } } num7 = 1; for (int i = 0; i < this.numberOfClusters; i++) { num7 = ((num7 == 0 || !this.isEqual((float[])arrayList2.get(i), (float[])arrayList.get(i))) ? 0 : 1); } num3--; } }
public void releaseEntitySkin(int i, int j, byte[] abyte0, double d, double d1, double d2, float f, float f1, float f2, int k, int l, double d3) { double d4 = i*16 + 8; double d5 = j*16 + 8; float f3 = 0.0F; float f4 = 0.0F; var random = new Random(rand.nextLong()); if (l <= 0) { int i1 = field_947_a*16 - 16; l = i1 - random.nextInt(i1/4); } bool flag = false; if (k == -1) { k = l/2; flag = true; } int j1 = random.nextInt(l/2) + l/4; bool flag1 = random.nextInt(6) == 0; for (; k < l; k++) { double d6 = 1.5D + (MathHelper.sin((k*3.141593F)/l)*f*1.0F); double d7 = d6*d3; float f5 = MathHelper.cos(f2); float f6 = MathHelper.sin(f2); d += MathHelper.cos(f1)*f5; d1 += f6; d2 += MathHelper.sin(f1)*f5; if (flag1) { f2 *= 0.92F; } else { f2 *= 0.7F; } f2 += f4*0.1F; f1 += f3*0.1F; f4 *= 0.9F; f3 *= 0.75F; f4 += (random.nextFloat() - random.nextFloat())*random.nextFloat()*2.0F; f3 += (random.nextFloat() - random.nextFloat())*random.nextFloat()*4F; if (!flag && k == j1 && f > 1.0F) { releaseEntitySkin(i, j, abyte0, d, d1, d2, random.nextFloat()*0.5F + 0.5F, f1 - 1.570796F, f2/3F, k, l, 1.0D); releaseEntitySkin(i, j, abyte0, d, d1, d2, random.nextFloat()*0.5F + 0.5F, f1 + 1.570796F, f2/3F, k, l, 1.0D); return; } if (!flag && random.nextInt(4) == 0) { continue; } double d8 = d - d4; double d9 = d2 - d5; double d10 = l - k; double d11 = f + 2.0F + 16F; if ((d8*d8 + d9*d9) - d10*d10 > d11*d11) { return; } if (d < d4 - 16D - d6*2D || d2 < d5 - 16D - d6*2D || d > d4 + 16D + d6*2D || d2 > d5 + 16D + d6*2D) { continue; } d8 = MathHelper.floor_double(d - d6) - i*16 - 1; int k1 = (MathHelper.floor_double(d + d6) - i*16) + 1; d9 = MathHelper.floor_double(d1 - d7) - 1; int l1 = MathHelper.floor_double(d1 + d7) + 1; d10 = MathHelper.floor_double(d2 - d6) - j*16 - 1; int i2 = (MathHelper.floor_double(d2 + d6) - j*16) + 1; if (d8 < 0) { d8 = 0; } if (k1 > 16) { k1 = 16; } if (d9 < 1) { d9 = 1; } if (l1 > 120) { l1 = 120; } if (d10 < 0) { d10 = 0; } if (i2 > 16) { i2 = 16; } bool flag2 = false; for (var j2 = (int) d8; !flag2 && j2 < k1; j2++) { for (var l2 = (int) d10; !flag2 && l2 < i2; l2++) { for (int i3 = l1 + 1; !flag2 && i3 >= d9 - 1; i3--) { int j3 = (j2*16 + l2)*128 + i3; if (i3 < 0 || i3 >= 128) { continue; } if (abyte0[j3] == Block.waterStill.blockID || abyte0[j3] == Block.waterMoving.blockID) { flag2 = true; } if (i3 != d9 - 1 && j2 != d8 && j2 != k1 - 1 && l2 != d10 && l2 != i2 - 1) { i3 = (int) d9; } } } } if (flag2) { continue; } for (var k2 = (int) d8; k2 < k1; k2++) { double d12 = (((k2 + i*16) + 0.5D) - d)/d6; for (var k3 = (int) d10; k3 < i2; k3++) { double d13 = (((k3 + j*16) + 0.5D) - d2)/d6; int l3 = (k2*16 + k3)*128 + l1; bool flag3 = false; if (d12*d12 + d13*d13 >= 1.0D) { continue; } int i4 = l1 - 1; do { if (i4 < d9) { goto label0; } double d14 = ((i4 + 0.5D) - d1)/d7; if (d14 > -0.69999999999999996D && d12*d12 + d14*d14 + d13*d13 < 1.0D) { byte byte0 = abyte0[l3]; if (byte0 == Block.grass.blockID) { flag3 = true; } if (byte0 == Block.stone.blockID || byte0 == Block.dirt.blockID || byte0 == Block.grass.blockID) { if (i4 < 10) { abyte0[l3] = (byte) Block.lavaStill.blockID; } else { abyte0[l3] = 0; if (flag3 && abyte0[l3 - 1] == Block.dirt.blockID) { abyte0[l3 - 1] = (byte) Block.grass.blockID; } } } } l3--; i4--; } while (true); label0: ; } } if (flag) { break; } } }
public override bool generate(World world, Random random, int i, int j, int k) { i -= 8; for (k -= 8; j > 0 && world.isAirBlock(i, j, k); j--) { } j -= 4; var aflag = new bool[2048]; int l = random.nextInt(4) + 4; for (int i1 = 0; i1 < l; i1++) { double d = random.nextDouble()*6D + 3D; double d1 = random.nextDouble()*4D + 2D; double d2 = random.nextDouble()*6D + 3D; double d3 = random.nextDouble()*(16D - d - 2D) + 1.0D + d/2D; double d4 = random.nextDouble()*(8D - d1 - 4D) + 2D + d1/2D; double d5 = random.nextDouble()*(16D - d2 - 2D) + 1.0D + d2/2D; for (int j4 = 1; j4 < 15; j4++) { for (int k4 = 1; k4 < 15; k4++) { for (int l4 = 1; l4 < 7; l4++) { double d6 = (j4 - d3)/(d/2D); double d7 = (l4 - d4)/(d1/2D); double d8 = (k4 - d5)/(d2/2D); double d9 = d6*d6 + d7*d7 + d8*d8; if (d9 < 1.0D) { aflag[(j4*16 + k4)*8 + l4] = true; } } } } } for (int j1 = 0; j1 < 16; j1++) { for (int j2 = 0; j2 < 16; j2++) { for (int j3 = 0; j3 < 8; j3++) { bool flag = !aflag[(j1*16 + j2)*8 + j3] && (j1 < 15 && aflag[((j1 + 1)*16 + j2)*8 + j3] || j1 > 0 && aflag[((j1 - 1)*16 + j2)*8 + j3] || j2 < 15 && aflag[(j1*16 + (j2 + 1))*8 + j3] || j2 > 0 && aflag[(j1*16 + (j2 - 1))*8 + j3] || j3 < 7 && aflag[(j1*16 + j2)*8 + (j3 + 1)] || j3 > 0 && aflag[(j1*16 + j2)*8 + (j3 - 1)]); if (!flag) { continue; } Material material = world.getBlockMaterial(i + j1, j + j3, k + j2); if (j3 >= 4 && material.getIsLiquid()) { return false; } if (j3 < 4 && !material.isSolid() && world.getBlockId(i + j1, j + j3, k + j2) != field_15005_a) { return false; } } } } for (int k1 = 0; k1 < 16; k1++) { for (int k2 = 0; k2 < 16; k2++) { for (int k3 = 0; k3 < 8; k3++) { if (aflag[(k1*16 + k2)*8 + k3]) { world.setBlock(i + k1, j + k3, k + k2, k3 < 4 ? field_15005_a : 0); } } } } for (int l1 = 0; l1 < 16; l1++) { for (int l2 = 0; l2 < 16; l2++) { for (int l3 = 4; l3 < 8; l3++) { if (aflag[(l1*16 + l2)*8 + l3] && world.getBlockId(i + l1, (j + l3) - 1, k + l2) == Block.dirt.blockID && world.getSavedLightValue(EnumSkyBlock.Sky, i + l1, j + l3, k + l2) > 0) { world.setBlock(i + l1, (j + l3) - 1, k + l2, Block.grass.blockID); } } } } if (Block.blocksList[field_15005_a].blockMaterial == Material.lava) { for (int i2 = 0; i2 < 16; i2++) { for (int i3 = 0; i3 < 16; i3++) { for (int i4 = 0; i4 < 8; i4++) { bool flag1 = !aflag[(i2*16 + i3)*8 + i4] && (i2 < 15 && aflag[((i2 + 1)*16 + i3)*8 + i4] || i2 > 0 && aflag[((i2 - 1)*16 + i3)*8 + i4] || i3 < 15 && aflag[(i2*16 + (i3 + 1))*8 + i4] || i3 > 0 && aflag[(i2*16 + (i3 - 1))*8 + i4] || i4 < 7 && aflag[(i2*16 + i3)*8 + (i4 + 1)] || i4 > 0 && aflag[(i2*16 + i3)*8 + (i4 - 1)]); if (flag1 && (i4 < 4 || random.nextInt(2) != 0) && world.getBlockMaterial(i + i2, j + i4, k + i3).isSolid()) { world.setBlock(i + i2, j + i4, k + i3, Block.stone.blockID); } } } } } return true; }
public override void updateTick(World world, int i, int j, int k, Random random) { int l = func_301_g(world, i, j, k); byte byte0 = 1; if (blockMaterial == Material.lava && !world.worldProvider.isHellWorld) { byte0 = 2; } bool flag = true; if (l > 0) { int i1 = -100; field_659_a = 0; i1 = func_307_e(world, i - 1, j, k, i1); i1 = func_307_e(world, i + 1, j, k, i1); i1 = func_307_e(world, i, j, k - 1, i1); i1 = func_307_e(world, i, j, k + 1, i1); int j1 = i1 + byte0; if (j1 >= 8 || i1 < 0) { j1 = -1; } if (func_301_g(world, i, j + 1, k) >= 0) { int l1 = func_301_g(world, i, j + 1, k); if (l1 >= 8) { j1 = l1; } else { j1 = l1 + 8; } } if (field_659_a >= 2 && blockMaterial == Material.water) { if (world.isBlockOpaqueCube(i, j - 1, k)) { j1 = 0; } else if (world.getBlockMaterial(i, j - 1, k) == blockMaterial && world.getBlockMetadata(i, j, k) == 0) { j1 = 0; } } if (blockMaterial == Material.lava && l < 8 && j1 < 8 && j1 > l && random.nextInt(4) != 0) { j1 = l; flag = false; } if (j1 != l) { l = j1; if (l < 0) { world.setBlockWithNotify(i, j, k, 0); } else { world.setBlockMetadataWithNotify(i, j, k, l); world.func_22074_c(i, j, k, blockID, tickRate()); world.notifyBlocksOfNeighborChange(i, j, k, blockID); } } else if (flag) { func_22024_i(world, i, j, k); } } else { func_22024_i(world, i, j, k); } if (func_312_l(world, i, j - 1, k)) { if (l >= 8) { world.setBlockAndMetadataWithNotify(i, j - 1, k, blockID, l); } else { world.setBlockAndMetadataWithNotify(i, j - 1, k, blockID, l + 8); } } else if (l >= 0 && (l == 0 || func_309_k(world, i, j - 1, k))) { bool[] aflag = func_4035_j(world, i, j, k); int k1 = l + byte0; if (l >= 8) { k1 = 1; } if (k1 >= 8) { return; } if (aflag[0]) { func_311_f(world, i - 1, j, k, k1); } if (aflag[1]) { func_311_f(world, i + 1, j, k, k1); } if (aflag[2]) { func_311_f(world, i, j, k - 1, k1); } if (aflag[3]) { func_311_f(world, i, j, k + 1, k1); } } }
private string pickMobSpawner(Random random) { int i = random.nextInt(4); if (i == 0) { return "Skeleton"; } if (i == 1) { return "Zombie"; } if (i == 2) { return "Zombie"; } if (i == 3) { return "Spider"; } else { return ""; } }
/* Public: */ public AlgorithmsTest() { DateTime t0 = DateTime.Now; int MazeCount = 5; int TotalSearchs = 0; int SuccessCount = 0; for (int c = 0; c < MazeCount; c++) { int OneSearch = 0; HashSet blocked_cells = new HashSet(), unblocked_cells = new HashSet(); long seed = DateTime.Now.Ticks; //seed = 27261468842294L; LightCell maze_cell; java.util.Random random = new java.util.Random(seed); System.Console.WriteLine("Seed: " + seed); Maze maze = new Maze(seed, MAZE_W, MAZE_H, PROBABILITY_TO_BLOCK_A_CELL, MAZE_CELL_MAX_COST); //GAAStarLazy gaa_star_lazy = new GAAStarLazy(maze , true , false , tie_breaking_strategy , // ManhattanDistanceHeuristic.GetManhattanDistanceHeuristic() , Maze.N_DIRECTIONS_WITHOUT_DIAGONALS); for (maze_cell = maze.GetStart(); maze_cell != maze.GetGoal();) { AStar a_star = new AStar(maze, true, false, tie_breaking_strategy, ManhattanDistanceHeuristic.GetManhattanDistanceHeuristic(), Maze.N_DIRECTIONS_WITHOUT_DIAGONALS); a_star.Solve(); OneSearch++; //System.Console.WriteLine("A*:\n" + maze); //System.Console.WriteLine("A*:\n"); //maze.CleanPath(); //gaa_star_lazy.Solve(); //System.Console.WriteLine("GAA*:\n"); //System.Console.WriteLine("GAA*:\n" + maze); if (!a_star.HasSolution()) { System.Console.WriteLine("No solution."); //System.err.println("Fail: Some algorithms found the solution."); //System.err.println("A*: " + a_star.HasSolution()); //System.exit(1); Application.Restart(); } else { SuccessCount++; //System.Console.WriteLine(OneSearch + " The solution has the following cost: " + a_star.GetPathCost()); } for (int distance = 0; maze_cell != maze.GetGoal(); distance += 1, maze_cell = maze_cell.GetNextMazeCell()) { if (distance >= DISTANCE_BEFORE_CHANGE || !a_star.HasSolution()) { LightCell new_goal; maze.CleanPath(); maze.SetStart(maze_cell); //gaa_star_lazy.InformNewStart(maze_cell); blocked_cells.clear(); unblocked_cells.clear(); /* Block some cells. */ for (int i = 0; i < N_CHANGED_CELLS; i++) { LightCell blocked_maze_cell; int x, y; x = random.nextInt(maze.GetW()); y = random.nextInt(maze.GetH()); blocked_maze_cell = maze.GetMazeCell(x, y); if (blocked_maze_cell != maze.GetStart() && blocked_maze_cell != maze.GetGoal() && !blocked_maze_cell.IsBlocked() && !blocked_cells.contains(blocked_maze_cell)) { blocked_maze_cell.Block(); blocked_cells.add(blocked_maze_cell); } } /* Unblock or change the cost of some cells. */ for (int i = 0; i < N_CHANGED_CELLS; i++) { LightCell unblocked_maze_cell; int x, y; x = random.nextInt(maze.GetW()); y = random.nextInt(maze.GetH()); unblocked_maze_cell = maze.GetMazeCell(x, y); if (!blocked_cells.contains(unblocked_maze_cell) && !unblocked_cells.contains(unblocked_maze_cell)) { int new_cost = random.nextInt(MAZE_CELL_MAX_COST) + 1; if (unblocked_maze_cell.IsBlocked() || unblocked_maze_cell.GetCost() > new_cost) { unblocked_cells.add(unblocked_maze_cell); } unblocked_maze_cell.SetCost(new_cost); } } /* Change the goal. */ do { int x, y; x = random.nextInt(maze.GetW()); y = random.nextInt(maze.GetH()); new_goal = maze.GetMazeCell(x, y); } while (blocked_cells.contains(new_goal) || unblocked_cells.contains(new_goal) || new_goal == maze.GetGoal() || new_goal == maze.GetStart()); if (new_goal.IsBlocked()) { unblocked_cells.add(new_goal); maze.SetGoal(new_goal); } else { int old_cost = maze.GetGoal().GetCost(); maze.SetGoal(new_goal); if (old_cost > maze.GetGoal().GetCost()) { unblocked_cells.add(maze.GetGoal()); } } //gaa_star_lazy.InformNewGoal(new_goal); //if(unblocked_cells.size() > 0) gaa_star_lazy.InformUnblockedCells(unblocked_cells); break; } } } TotalSearchs += OneSearch; System.Console.WriteLine(c + " Goal is : [" + maze.GetGoal().X + ", " + maze.GetGoal().Y + "] Current is : [" + maze_cell.X + ", " + maze_cell.Y + "]" ); }//End of produce 100 maze TimeSpan diff = (DateTime.Now - t0); System.Console.WriteLine("Total RunTime : " + diff.ToString()); System.Console.WriteLine("RunTime per search : " + (diff.TotalMilliseconds * 1000 / TotalSearchs) + " micro second"); System.Console.WriteLine("Average count of search is : " + (TotalSearchs / MazeCount)); }
public override bool generate(World world, Random random, int i, int j, int k) { int l = random.nextInt(5) + 7; int i1 = l - random.nextInt(2) - 3; int j1 = l - i1; int k1 = 1 + random.nextInt(j1 + 1); bool flag = true; if (j < 1 || j + l + 1 > 128) { return false; } for (int l1 = j; l1 <= j + 1 + l && flag; l1++) { int j2 = 1; if (l1 - j < i1) { j2 = 0; } else { j2 = k1; } for (int l2 = i - j2; l2 <= i + j2 && flag; l2++) { for (int k3 = k - j2; k3 <= k + j2 && flag; k3++) { if (l1 >= 0 && l1 < 128) { int j4 = world.getBlockId(l2, l1, k3); if (j4 != 0 && j4 != Block.leaves.blockID) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } int i2 = world.getBlockId(i, j - 1, k); if (i2 != Block.grass.blockID && i2 != Block.dirt.blockID || j >= 128 - l - 1) { return false; } world.setBlock(i, j - 1, k, Block.dirt.blockID); int k2 = 0; for (int i3 = j + l; i3 >= j + i1; i3--) { for (int l3 = i - k2; l3 <= i + k2; l3++) { int k4 = l3 - i; for (int l4 = k - k2; l4 <= k + k2; l4++) { int i5 = l4 - k; if ((Math.abs(k4) != k2 || Math.abs(i5) != k2 || k2 <= 0) && !Block.opaqueCubeLookup[world.getBlockId(l3, i3, l4)]) { world.setBlockAndMetadata(l3, i3, l4, Block.leaves.blockID, 1); } } } if (k2 >= 1 && i3 == j + i1 + 1) { k2--; continue; } if (k2 < k1) { k2++; } } for (int j3 = 0; j3 < l - 1; j3++) { int i4 = world.getBlockId(i, j + j3, k); if (i4 == 0 || i4 == Block.leaves.blockID) { world.setBlockAndMetadata(i, j + j3, k, Block.wood.blockID, 1); } } return true; }
public override bool generate(World world, Random random, int i, int j, int k) { if (!world.isAirBlock(i, j, k)) { return false; } if (world.getBlockId(i, j + 1, k) != Block.bloodStone.blockID) { return false; } world.setBlockWithNotify(i, j, k, Block.lightStone.blockID); for (int l = 0; l < 1500; l++) { int i1 = (i + random.nextInt(8)) - random.nextInt(8); int j1 = j - random.nextInt(12); int k1 = (k + random.nextInt(8)) - random.nextInt(8); if (world.getBlockId(i1, j1, k1) != 0) { continue; } int l1 = 0; for (int i2 = 0; i2 < 6; i2++) { int j2 = 0; if (i2 == 0) { j2 = world.getBlockId(i1 - 1, j1, k1); } if (i2 == 1) { j2 = world.getBlockId(i1 + 1, j1, k1); } if (i2 == 2) { j2 = world.getBlockId(i1, j1 - 1, k1); } if (i2 == 3) { j2 = world.getBlockId(i1, j1 + 1, k1); } if (i2 == 4) { j2 = world.getBlockId(i1, j1, k1 - 1); } if (i2 == 5) { j2 = world.getBlockId(i1, j1, k1 + 1); } if (j2 == Block.lightStone.blockID) { l1++; } } if (l1 == 1) { world.setBlockWithNotify(i1, j1, k1, Block.lightStone.blockID); } } return true; }