
Procedural Building Generation in Unreal Engine 3 - grinich
http://udn.epicgames.com/Three/ProceduralBuildings.html
======
bhickey
The results look amazing! I've always wished SimCity had done this.

The semantics for describing buildings seem a bit clunky. CityEngine uses (or
used) shape grammars implemented as stochastic context-free grammars for
building generation.

Suppose we want to design some buildings: Building ::= [1.0 First Floor + Rest
of Floors] First Floor ::= [0.4 Door | 0.6 Door + Windows] Rest of Floors ::=
[0.6 Roof | 0.4 Windows + Rest of Floors]

With three rules we can churn out buildings, where 60% are 1 story, 24% are 2
story, 14.4% are 3 story, and so on.

Here's a video of Pompeii built from a shape grammar.
[<http://www.youtube.com/watch?v=iDsSrMkW1uc>]

------
smcl
This is a really interesting insight into an aspect of a game I'd normally
never give much though to. Very good article indeed.

However I noticed something in this that I HATE seeing in real life, variables
(ok "properties", here) prepended with a character or characters indicating
type (seems only booleans here, bBlah and such). I honestly can't say why it
bothers me, but it makes code really tough to read. It really shouldn't, I
mean it technically should be useful as it gives a bit more info to the person
reading the code, but I find it infuriating. I wonder if anyone else has this
possibly irrational hatred.

~~~
wmf
That's <http://en.wikipedia.org/wiki/Hungarian_notation> — it seems to be
popular among Windows programmers.

------
wmf
If you like that, check out Subversion. Not only does it procedurally generate
cities, but they look totally sci-fi.
[http://forums.introversion.co.uk/introversion/viewtopic.php?...](http://forums.introversion.co.uk/introversion/viewtopic.php?t=1837)

------
johnwatson11218
What do people think about the results of procedural generation in terms of
information theory? If I get a CD that has code on in that lets me generate
level upon level how much information is that CD carrying?

For doing data compression has anyone ever heard about using these techniques
to generate other things besides 3D game levels?

~~~
partition
You touch on a very interesting and general concept, and that is the
correspondence between lossless compression algorithms and probability
distributions, and the subsequent correspondence between probability
distributions and procedural generation algorithms.

Consider the first correspondence. Suppose you knew a certain class of strings
arose from a probability distribution. Then you can talk about the strings
that are most likely to occur, or, more useful in general, about the
individual characters that are most likely to occur given a history of
previous characters. Using this, you can make a compression algorithm that
will map (symbol, probability) or (symbol + history, conditional probability)
starting from the highest probability, to the numbers 0, 1, 2 ...

This is arithmetic coding.

<http://en.wikipedia.org/wiki/Arithmetic_coding>

The result is optimal in terms of expected compressed string length assuming
the strings you use this on really do come from that distribution.

Now consider the other way around. Suppose you have a lossless compression
algorithm. Find the (uncompressed symbol, compressed symbol) pair (possibly
with context) that achieves the highest compression. Assign that a high
probability. Then find the next pair. Assign that a slightly lower probability
(This can be done in a more principled manner than I'm alluding here). Then
you have yourself a probability distribution.

More on data compression theory:

<http://en.wikipedia.org/wiki/Data_compression>

But what happens once you have a probability distribution over some data type,
is that you may cast the problem of automatically generating instance of that
data type as sampling from the distribution. Many procedural generation
algorithms that give nondeterministic results (and the useful ones do,
otherwise the work the modeler has to do is fundamentally the same) can be re-
cast as sampling from a probability distribution; look at what the algorithm
is generating and learn the distribution.

Note that this is uncomputable in general for the same reason Kolmogorov
complexity is. This is known as Solomonoff induction:

<http://singinst.org/blog/2007/06/25/solomonoff-induction/>

So to answer your original questions:

1\. The information (as in information entropy) in the algorithm in the CD is
the entropy of the true probability distribution from which your levels
originate.

2\. And yes, in principle you can use the correspondence between data
compression and procedural generation to generate instances of any arbitrary
data type, not just 3D game levels. It may be hard to design a probability
distribution that will create well-formatted instances though :)

~~~
johnwatson11218
Thank you for this thoughtful and detailed reply. I have read about Arithmetic
Coding and Data Compression. I haven't read about Solomonoff-Induction but I
will definitely read up on it.

I think another way of thinking about my original comment would be to imagine
that you had an image of the Mandelbrot Set up on your monitor (assume you
have drilled down a few times). If you knew the parameters that had generated
that view you could write a very concise description suitable for transmission
over a network. If you have forgotten the params and had to make due with a
screen print saved to jpeg it would appear to contain more 'information'. Not
only would the algorithmic version be shorter (so long as you hadn't drilled
down to the point at which the numbers representing the view port had millions
of degrees of precision) but you would be able to keep zooming in to view
arbitrary detail. That is something you wouldn't be able to do with the jpeg.
I guess what I'm driving at is that I don't understand how Information Theory
is able to account for things like fractals without saying that either the
Mandelbrot Set is random or that it contains infinite information. Am I
looking at this problem correctly?

~~~
jacques_chester
> I guess what I'm driving at is that I don't understand how Information
> Theory is able to account for things like fractals without saying that
> either the Mandelbrot Set is random or that it contains infinite
> information. Am I looking at this problem correctly?

This is (I think) the "coastline paradox": coast lines have different lengths
depending on scale. Length grows with resolution, so in a sense the length of
a coastline can be infinite.

I think the escape hatch is that the information conveyed is not the points on
the screen, but the rule on how to generate those points. Going back to my
other post this means that the city builder conveys no information about a
particular city map.

~~~
partition
> I think the escape hatch is that the information conveyed is not the points
> on the screen, but the rule on how to generate those points. Going back to
> my other post this means that the city builder conveys no information about
> a particular city map.

Yep. The amount of information conveyed can be considered 'equivalent' to the
length of the _shortest_ algorithm used to get from one string to the other.

The field that is concerned about thinking about this problem in a disciplined
manner is algorithmic information theory:

<http://en.wikipedia.org/wiki/Algorithmic_information_theory>

In particular, they show that the quantity is incomputable (the Komolgorov
complexity).

------
spyder
Here is an another cool city generator:
[http://www.youtube.com/watch?v=VnWUp9JnLyc&feature=relat...](http://www.youtube.com/watch?v=VnWUp9JnLyc&feature=related)
This is for the Subversion game that is in development since long ago:
<http://www.introversion.co.uk/subversion/>

------
razh
Direct link to the GDC 2010 slides (.pptx):

[http://unrealtechnology.com/Downloads/Slides/GDC2010_Golding...](http://unrealtechnology.com/Downloads/Slides/GDC2010_Golding_ArtistDrivenProceduralBuildings.pptx)

------
d5tryr
Interesting read, I'd love to get the same insight in to the Assassin's Creed
team's methods...

------
iwwr
Would we be seeing live procedural generation of this sort in games in the
near future?

~~~
bonzoesc
If Epic's building it, you can expect it. They're one of the biggest
middleware providers for games.

IIRC, many games use a procedural foliage generator for trees and shrubberies.

~~~
bhickey
You do recall correctly. Speed tree brings us shrubbery to plenty of games.
[<http://www.speedtree.com/>]

