http://lj.rossia.org/users/sadkov/268920.htmlOk. You have random() function. But how to use it? If you just place map tiles or terrain heights at random, you will get white noise result, that would be unrealistic unfun garbage, similar to Anton Myrzin's "Chaos". If you launch some cellular automata with random rules to produce caves in your roguelike, these caves would look unnatural. So to properly generate world for your video game, you can't use pure randomness, but need laws of physics, which will declare what is possible given the context - i.e. you need to have statistics of chances of some world even happening; for example, a chance there will be a lake or a mountain at a given point on the planet. Here we naturally come to stochastic algorithms, like Markov Chains and ANNs.
So to create realistic looking caves, you need an example of real caves layout in a euclidean space (likely broken into some discrete graph noes, because working with pixels would be hard). Now you train Markov Chains on that space, producing probabilities, that of tunnel going at given angle, distance, curvature or forking, given the previous state of the tunnel. Now, you can start from cave entrance, and use the random() with probabilities to generating realistically looking cave system.
Similarly you can use ANNs, which will work on more complex context, or just modify the Markov Chains concept to capture more complex data cross-correlation.
There is just no simpler way - random() without probabilities and physics is useless. You need statistics. Even superficially simpler algorithms, like the one used in Spelunky, still use this concept, but hardcode most values and have unrealistic training set.