Ok, I think I’m done at least for now… I just can’t get something out of my head once I start, this kind of mini projects hijack my mind and derail me from other things I really should be doing, but I’m ready to give this a rest.
It’s done! You can check it out online at http://slashie.net/ultimacastlegen (images are not preloaded so it may take one or two generated maps for graphics to show up)
You can also check the source code at github (It’s not super beautiful, but it was fun!).
As it stands, it generates a single floor layout of a castle based on the design of the old Ultima games, specially Ultima 5. It goes roughly through 4 phases:
- Defining a high level structure of the rooms to be placed.
- Splitting the available space into rooms, based on the high level structure.
- Assign the rooms a given function.
- Fill the rooms with the appropriate furniture and contents, based on its function.
During day 8, I did the following
- Fill the remaining space after the initial room expansion, to ensure most of the space in the castle is used to place rooms.
- Build throne room, staff quarters, guest rooms, castle lord quarters, dining rooms, kitchens, libraries and halls, furnishing them with all sort of stuff based on the reference material.
- Render 14×16 pixels sprites instead of 16×16 (high fidelity)
- Enhance connection of the central feature with the rest of rooms
- Clean spaces in front of doors to ensure walk-ability.
- Add treasure chests with secret doors
- Remove some room types belonging to other floors (forge, for instance)
There is certain room for improvement, and there’s of course the question of adding the basement and additional floors (and connecting all together!). But from what I see, that would take a bit of time.
Doing this generator was pretty interesting… I learned a couple of new tricks I hope will be useful for other projects in the future.