Tuesday, August 5, 2025

Deep House Exploitation – An asteroid mining recreation

Hi there!
Not too long ago I have been busy engaged on procedural technology for ranges, which is one thing I did not initially plan for however began to look extra attainable as time went on. Very like the earlier work I did on path discoveringthere are some difficulties that include doing this type of factor for a free-form surroundings and never one which’s good and grid primarily based, which I will speak about extra under. Although I am nonetheless planning at hand design a whole lot of the degrees, it will actually assist so as to add some further selection for gamers, and even open up the chance for an infinite mode as soon as the primary recreation is completed.

If you happen to like what you see right here, please check out Deep House Exploitation on Steam and maybe wishlist it! Deep House Exploitation – An asteroid mining recreation


Here’s a gif of random ranges you would possibly count on for a scrap job.

Deciding on Proc-Gen
Initially I solely deliberate on utilizing procedural technology for the textures of the asteroids and never the degrees themselves. My thought was that because the recreation is not going to be infinitely lengthy, and procedural technology is tough to truly make good and fascinating, I might hand design every degree as an alternative and reap the advantages of a human contact (like inserting sources particularly to trick gamers or give them an enormous payoff). I had an enormous love of procedural technology once I first began programming, and made a lot of little experiments but in addition wasted a whole lot of time making an attempt to get the outcomes excellent once I might have been placing extra effort into different issues. So this was partly influenced by me not eager to get caught with a process I wasn’t certain I might really pull off.

Now although, first rate procedural technology began to appear extra attainable. After engaged on the sport all this time I felt I had a a lot better understanding of what labored and what did not for ranges, and the way I might have that pieced collectively randomly. That is partly confidence from having hand-built a whole lot of ranges, and partly from having extra instruments obtainable to make use of for this (I say instruments, however I imply intelligent code for interacting with the bodily shapes of issues).

I made a decision to provide myself one week (which become one and a half after different commitments) to have a severe go at it, so what you are seeing right here is the results of that. I am fairly happy with the consequence, and I believe it will possibly solely get higher with tweaks and added options.

Step 0 – Parameterisation
The technology is definitely fairly closely parameterised, with me specifying precisely what number of asteroids of every dimension and sort, what number of sources of every kind, what destruction to use, and eventually what different entities to put. Due to this, I am a bit of reluctant to name this “procedural technology” because it’s extra simply intelligent placement of issues. Once I consider procedural technology I consider the large worlds of video games like Dwarf Fortress. However this method works nicely for me as a result of I do wish to actually specify what goes right into a degree for the aim of stability and a few type of predictability.

Step 1 – Asteroids
Step one is the location of asteroids, since they’re the biggest objects on every degree and every little thing revolves round them. There are 4 totally different sizes of asteroids (Giant, Medium, Small, and Tiny) and at the moment three differing kinds (Purple, Pink, and White), with parameterisation permitting to specify precisely what number of of every we wish. There are additionally asteroid presets, that are hand designed placements of asteroids, with every asteroid form having roughly 4 presets to select from.

Very roughly, that is the method for putting the asteroids:

1. Choose the biggest asteroid dimension obtainable
2. Choose an obtainable asteroid kind for this dimension
3. Discover a random place for this asteroid with some further padding round it
4. Determine whether or not we are going to use a preset
4.1. Discover all presets which we have now obtainable asteroids for
4.2. Place a preset which does not intersect with different asteroids
5. Determine the overall variety of asteroids on this cluster
6. Place asteroids on this cluster till we attain the overall quantity
6.1 Select a random asteroid on this cluster
6.2 Select a random dimension smaller than this asteroid that we nonetheless have availability for
6.3 Place a brand new asteroid of this dimension subsequent to the present asteroid
6.4 Repeat till we have positioned all asteroids on this cluster
7. Repeat till we have positioned all asteroids

I discover this strikes a good stability between being random, fascinating, enjoyable to fly round, and in addition semi-natural trying. I am pondering to experiment with broader guidelines, corresponding to making every little thing extra scattered or condensed.

Step 2 – Destruction
Subsequent there’s the possibility for some destruction to be added, in order that the extent seems to be like another person might need been right here earlier than and finished some mining. That is finished earlier than inserting any sources or entities in order that we do not place something precisely the place we make the destruction and make it appear to be somebody excavated some sources however then determined to not take them. The destruction can also be bodily simulated in order that asteroids appear to be they’ve really been moved by what’s been damaging them, and having sources/entities positioned whereas that’s occurring could make issues look a bit of too random.

In the intervening time there are two sorts of destruction for randomisation; explosive costs, and bullet impacts. The destruction for explosive costs is positioned on the circumference of Giant or Medium asteroids, since inserting them on smaller ones can utterly obliterate them, making it pointless to even place them. And the destruction for bullet impacts are positioned ranging from an empty level in house after which casting rays out in a fan to see the place bullets might impression, after which creating small destructions for these positions. After every destruction there is a random likelihood to put some particles related to it, corresponding to shrapnel from explosive costs, or un-detonated bullets from bullet impacts.

Step 3 – Entities
These are the totally different entities that we’d need in a degree, just like the scrap processor or random items of scrap mendacity round. I plan so as to add particular person guidelines for every of those in order that I can have particular outcomes, as an alternative of making an attempt to give you one grasp rule for every little thing. So if I need one degree to have a container that is at all times empty, I’d specify rule CONTAINER_EMPTY within the parameters, or if I desire a later degree to have a container with some good loot in I’d specify rule CONTAINER_LOOT_3.

Step 4 – Assets
And at last there are the sources, that are parameterised by kind (Blue, Inexperienced, or Pink), amount, and the vary of depths they are often positioned at. Presently, there are guidelines stating which asteroid varieties a useful resource may be positioned on (Blue crystals solely on purple asteroids, for instance), and for every asteroid form I pre-compute the useful resource placement positions and their depths, so in the case of inserting sources we do the next:

1. Select a useful resource to put
2. Get all asteroids this useful resource may be positioned on
3. Get all placement positions for the given depth vary for these asteroids
4. Select a placement place out of those positions that does not overlap with an current useful resource
5. Place the useful resource there
6. Repeat till all sources are positioned

That is pretty easy however permits for good distribution of sources within the degree. I do wish to enhance this by forcing some clusters of sources, or giving a bigger weighted vary of depths, so you possibly can specify {that a} useful resource may very well be positioned at depth 1, but it surely’s more likely to be positioned at depths 4 to six.


This technology is a little more busy and compact to point out extra of what it is doing.

Hacking these Gifs collectively
I wished to point out gifs of the technology occurring in considerably gradual movement, so you possibly can see what is going on on. Within the precise recreation this technology occurs in a short time (Below 100ms in debug, which makes me assume I’ve much more room if I wish to use extra sophisticated logic) so I wanted to gradual it down and in addition present it occurring in actual time whereas the extent is working.

First I attempted throwing it on a separate thread and locking between updates in order that the primary thread and the technology thread weren’t combating for a similar sources, however even that did not work due to some restrictions to utilizing graphics elements off of the primary thread (I generate every asteroid’s texture because it’s created).

So what I ended up doing is popping every technique within the degree technology right into a C# Generator Technique, which principally implies that execution can pause and return at particular factors. With this I can do every little thing on a single thread and look forward to a timer to elapse between every degree technology step or placement. Enjoyable!

What’s Subsequent?
Now that I’ve this working I will very simply add extra “filler” ranges between the extra hand designed ranges. It additionally means I can hand design extra ranges as regardless of the procedural technology outputs is totally editable utilizing my makeshift degree editor, so if I see it producing one thing that I do know may very well be higher, I can do a couple of guide tweaks and voila.

This additionally units the sport up nicely for a possible infinite mode after launch. Although I will not go so far as to vow this, as a result of I do not know what the state of issues will likely be as soon as I really get there.

If you have to this level, thanks a lot for studying, and I hope you discovered this all even barely fascinating. If you happen to did, remember to take a look at Deep House Exploitation on Steam!

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles