Entries for Reddit Procedural Generation Monthly Challenge # 2 (Castles)

I participated on /r/proceduralgeneration January challenge: Castle Generator; based on the structure of the castles from the classic Ultima V game, a first component generates the desired structure (what rooms the castle should have and what sizes they should be).

A second component takes this specification and tries to place the desired rooms in a 32×32 tiles space. (Again following design patterns derived from the original game). Some of the spaces are placed in a semi-fixed way (the towers, the halls connecting the towers, the central room and the entrance halls to the castle), the rest of rooms are placed in the remaining space and then are grown randomly to occupy as much space as possible. Once they can grow no more, additional rooms will be allocated to fill the remaining space.

The layout is then validated vs the specs, to see if all the required rooms can be placed (including preferences such as rooms to be placed at the top, and minimum size considerations). If the second component is unable to place the rooms required by the first component, generation fails and a new layout is generated by the first component.

The rooms will then be connected to the central room following a recursive flooding algorithm which scans the walls of each room looking for close rooms, and then picks a random spot in the wall to place a door.

Then comes the third component which is in charge of adding the contents to each room based on its type. The central feature can be a courtyard or a main hall and follows specific parameters for generation defining what kind of features should be placed in the center, what kind of paths connect with the other features including the terrain, and many other parameters. Throne Rooms place the throne at the top with optional features such as carpet, columns and torches leading to it.

The rest of the rooms are split into a number of vertical and horizontal spaces, which can be 2 or 3 tiles big depending on the room size. Then, according to the type of the room, smaller features such as beds, tables and other furniture, are selected and placed on these spaces. Some rooms like the living quarters or the dining room have special rules to place for example long tables and chairs by the tables. Torch lighting is also included randomly in most rooms.


Here are pics of the results of some of other generators submitted, take a look here for more info!

A new challenge has been proposed! I’m wondering if I’ll be in 🙂





Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s