I was playing pirates with my 4 year old daughter, and she buried some treasure for us to find.
She had put a lock on the treasure, and we also had to find the key. LIGHTBULB! I started thinking
about adventure games where you need the red key to unlock the red chest, etc. Then I
started thinking about force fields and switches in Approaching Infinity.
![](https://media.moddb.com/images/articles/1/156/155503/auto/new-random-force-field-example.jpg)
I realized that I could randomly place force-fielded areas on shipwrecks at random. Algorithms
started messing around in my head, and while she was drawing a treasure map, I quickly
wrote down the steps i would need to create Treasure Rooms! (I do this sort of thing a lot.
I wrote down a text-sorting algorithm at work a few nights ago. If's and for's and while's
on a little slip of paper.)
![](https://media.moddb.com/images/articles/1/156/155503/auto/coding-example-part-1.gif)
Now it's possible to find areas of shipwrecks that are cordoned off by force fields,
that are also full of treasure and monsters. They appear randomly, and can be both
challenging and rewarding.
![](https://media.moddb.com/images/articles/1/156/155503/auto/new-random-force-field-example-2.jpg)
The basic idea is this:
- Find an isolated area of the ship that is not near the player's start position.
- Make sure it has an appropriate amount of empty space
- That will be the treasure room's location
- Then use dijkstra maps to find a place that is both far from the treasure, and far from the player.
- That's where the switch goes. Place it now. Then give it a guardian ;)
- Surround the treasure room with a force field, and then fill it with loot and monsters!
That's it. So thanks, little girl, you are a continuing inspiration! And when Beta 04 comes out this weekend, you might just find some of these ;)