1. We start with a horizontal segment.
2. We divide the segment into three equally sized segments.
3. We remove the segment in the middle
4. Repeat from step (2) for the two remaining segments
This produces a set of segments that puzzled mathematicians for a while. I am more interested in the fractal properties of the whole construct. It shows how a simple rule operating at multiple scales can generate complex structures. This set is too primitive to be used for realistic content, but it is the seed of many techniques you will require to achieve that.
This is how you would code the Cantor set using our grammars:
Here you can see the output:
Let's make it more interesting. First let's add depth to it. Instead of segments we will use 3D boxes:
This already looks like we were growing little towers. We can make the towers taller if there is enough room:
Let's add a random element. We will not split into three equal spaces anymore, instead we will pick a random value for each iteration:
For a microsecond this image can fool you into thinking you have seen a city. I think that is pretty cool if you consider it is only a few lines of grammar code.
Of course this is not a replacement for a city or buildings. The cantor grammars are probably the simplest you can have. You will need a lot of more code to produce somethings that can pass as a city. But odds are it will be mostly variations of the Cantor dust.