I was curious as to just how many ores are exposed in caves, inspired by posts like this, and decided to find out. I did this by modifying the code that generates veins of ore (WorldGenMinable) so it counted every block of ore placed (successful placements only, I also restricted it to below sea level), and also checked the six adjacent faces for air blocks, and if any air was found it would flag it as "exposed" and add the total number of ore blocks to a running total; I used a modified form of a mod I'd made to track how many ores were mined by a player to list the counts in-game, as well as the number of chunks populated.
This shows some of the modifications I did, using 1.6.4 code:
Added where the game places a block of ore (first line); this is within an "if" statement which checks to see if it can replace another block, usually stone, so this will only run on successful placement:
I excluded dirt and gravel by limiting the block ID to 14 or higher (gold is 14) to help avoid lag due to them being far more common; I didn't actually notice any decease in performance due to all of the extra checks for air blocks.
I then add the number of blocks to a running total based in the block ID after the vein has been generated:
if (exposed) BlocksMined.updateBlocksMinedCount(this.minableBlockId, blocks);
"BlocksMined" is a simply utility class I made that adds the value to a total which is then displayed using code in GuiInventory.
In ChunkProviderGenerate I added another BlocksMined call to the populate method to count the number of chunks populated.
Here are the results for a new world; 576 chunks were populated (the game generates a 25x25, 625 chunk area when a new world is created; only an inner 24x24 chunk-sized is populated, thus 576 chunks):
A map of the world for size perspective; the entire area is 400x400 blocks (note the half-chunk wide border visible around the edge, especially around the taigas; this is due to the aforementioned population of chunks):
I then flew around to generate more chunks with this as the result:
Here are the results of an MCEdit analysis of the whole world below sea level (some additional coal can be found above sea level, but I did not count that in either case since I'm mainly looking at caves; about 96% of all coal was below sea level). I also included some other resources that can be found by caving, such as wood planks, mob spawners, mossy cobblestone, rails, etc:
-The amount of coal exposed is considerably higher than suggested by per-chunk counts, which suggests a ratio of 1.75:1 while it is closer to 2.75:1. This is likely due to coal's larger veins being more likely to intersect a cave and closely matches what I find in-game so this is likely accurate.
-Conversely, this does not account for ores that are covered up or exposed by falling gravel, which doesn't actually fall until after chunks have generated. Presumably, this slightly increases the amount of exposed ore since the pocket left behind by gravel has more area than the ground it covers (diamond and redstone are less likely to generate higher up though). The same applies to ore which are hidden behind other ores (e.g. a vein of diamond which is exposed after mining a coal vein; only the coal is initially exposed), further increasing the amount of ores found.
-Caves become more common deeper down, so deeper ores have a higher chance of being exposed; however, less of their range is exposed (diamond generates between 0-15, only 10-15 are exposed). In the absence of ravines or mineshafts cave density reaches a maximum just above y=10 (ravines do not generate below y=20 (vertical center) and mineshafts average around y=30), which is shown on this chart for Beta 1.7.3.
-The MCEdit analysis is not completely accurate with respect to resources from abandoned mineshafts since they are less common near the origin of the world, only reaching their maximum frequency 80 chunks away; in 1.6.4 they reach a maximum frequency of one every 100 chunks (one every 250 in 1.7 and later). Dungeons are also around 3 times rarer since 1.7; this still leaves mob spawners fairly common, one per 29.3 chunks in the analysis I did here, so perhaps one every 80 or so chunks for a 1.7+ world.
-Note that this was in 1.6.4, with more caves, mineshafts, and dungeons than 1.7 and later worlds, so they may be expected to have less exposed ores per chunk; 1.8 increased the size of veins though, and as seen with coal this increases the amount of exposed ore more than the increase in size would suggest (the ore counts I found were all slightly larger than what the Wiki says; e.g. 88.6 iron vs 77 in the Wiki; by contrast in a 1.8 world I found 111 iron ore per chunk. Part of this may be due to the presence of oceans in the Wiki's analysis but that fails to explain the increases in other ores in 1.8).
-This also makes it clear how I can mine around 3,000 ores per play session, day after day - there is just a LOT of ore exposed in caves! To mine 3,000 ore only requires exploring an average of 100 chunks, or just 1/6 the size of a brand-new world, which is also what I've previously estimated that I explore in an average play session, which may include an entire average sized cave system, mineshaft, and/or a couple ravines. For perspective, a fully zoomed (level 4) map is 16,384 chunks, so it would take about 164 days to fully explore, with nearly half a million ore mined.
But it's interesting that there is that tiny number more diamonds than redstone...I usually find redstone easier than diamonds...
Are you referring to this?
Redstone ore: 4.48%
Diamond ore: 4.59%
That's an insignificant (2.4%) difference and is not the actual amount of ore exposed; redstone is about 8 times more common, as expected from the per-chunk numbers (36 times more common when considering drops; even with Fortune, which works better on diamond, you still have a 22:1 ratio); 6,625 chunks is a lot but it isn't quite enough to completely eliminate all randomness. For example, this chart from the Wiki shows data from over 12,000 chunks - you'd expect the curves to be nearly flat across much of their range but you see a lot of peaks and dips, which are not real (charts like this also contribute to myths like "diamonds are most common at y=12"):
(Updated with Minecraft 1.1. Generated from 12853 chunks in a 1024 block radius around 0,0.)
Which form of mining is better? Branch (not strip mining) mining is indisputably better than caving for diamonds - I've mined thousands of diamonds but that is over real-life weeks of continuous gameplay and it would take several days of caving at 3 hours a day to get enough diamonds to meet my initial needs on a new world, so even I branch-mine at first (plus I like to save my caving for the end-game, not doing it until I've defeated the Ender Dragon, built a base, and enchanted my everyday gear). Sure, you can be lucky and find enough in a lot less time; in this thread somebody claims to have found 82 diamonds in 2.5 hours, more than I've ever found myself; on the other hand, you may not; for example, here are the results of a couple of my play sessions (in a modded world but ores and caves are similar enough for comparisons):
Note that I explore everything, regardless of whether it is deep enough for diamonds or above sea level in a mountain - I just cave for fun, not to get resources, so what I get during varies significantly from play session to play session (even the relative amounts of coal and iron vary quite a bit due to random variation). Also, in the aforementioned thread they apparently only mined diamonds, if they are telling the truth; either way, to find 82 diamonds requires exploring an average of about 560 chunks; of course, they are randomly distributed so you could find that many in just 56 chunks.
If you just want iron or coal caving is clearly better, and in either case caving can be better in terms of tool wear (total blocks mined per ore found) - I can easily mine more iron than stone while caving, and a lot of the stone could be avoided if I used ladders more often (mainly to scale sheer walls, like in ravines, not for permanent use). Branch-mining is also safer; the only mobs you need to worry about are silverfish and tiny slimes (if you stick with 1 block wide tunnels) and some common sense and a water bucket will avoid accidents in lava.
Also, it is possible to apply my method of counting exposed ores to branch-mining - pick a fixed x or z coordinate; e.g. x = 0 (perhaps several to speed things up; x = 0, x = 16, x = 32, etc), and y-coordinate, e.g. 11 and 12, then count the number of ore in veins that would be exposed to those coordinates along the z-axis.
I decided to check an even larger area; 23,137 chunks:
Among other things (see my last post about diamond and redstone), the ratio of diamond to redstone has reversed; there was 8.7 redstone ore exposed for every diamond ore (i.e. more redstone than expected), and the ratio of iron to diamond increased from about 49:1 to 53:1 (which in turn are both higher than the 44:1 ratio found around spawn; I used the same seed but with large biomes this time to exclude oceans, which will reduce this ratio).
Also, I decided to try this with branch-mining; I assumed a 1x2 tunnel dug at y=11 and 12 and any vein that would be exposed at one of the six faces was counted; to make things easier I used a Superflat preset so only pure branch-mining was included (caves would reduce the amounts of ores slightly since they replace stone with air; practically, they would increase exposure if you explored them) and used 33 "tunnels", each 4 blocks apart:
The "length" is the number of chunks populated south of z=0 times 16 blocks per chunk times 33 tunnels; I only ran the exposure check on ores generated south of z=0; I flew straight to the south along x=0, with the "tunnels" at x = -64 to x = +64. 4 blocks was used since that is often given as the most efficient spacing to get the most ores out of a given area with the least mining (a single 1x2 tunnel, or tunnels spaced further apart, would ensure that no ores ever intersected two tunnels, as will often happen with coal, or ores that are combined in multiple-ore veins, but is not very space-efficient).
Compared to caving, you can see that compared to coal and iron you'll mine far more rarer ores, as expected, and also less coal compared to iron, only about twice as much. The exception is lapis, which is more common than diamond when caving, although this doesn't necessarily mean it is easier to find. The total area covered was about 1,390 chunks.
In addition, this is what happens with a tunnel spacing of 8 blocks; to make comparison easier I went a bit further so the amount of iron was nearly the same; the biggest change is the amount of coal, which is now closer that what I found for caves, as expected due to aforementioned reasons (if you are wondering about the skin, I'm using MCP, which uses a random player name and will load their skin if they exist; otherwise, it uses my skin which I added with a resource pack):