As part of the monthly procedural generation challenge at /r/proceduralgeneration I wrote a castle generator. It was voted to first place and brought me the title King of the Castle.
The algorithm is working on a grid. I start by generating house parts in form of cuboids with different dimensions. After that I generate towers with a given likelyhood at all building corner positions.
Next I instantiate the mesh tiles according to the generated building and towers. In a last step I randomly replace some tiles with special ones, such as windows, doors or decoration like flags.