Thursday, August 7, 2025

Deep House Exploitation – An asteroid mining recreation

Hey!
Lately I have been busy engaged on procedural era 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 sort of factor for a free-form atmosphere and never one which’s good and grid primarily based, which I am going to discuss extra beneath. Regardless that I am nonetheless planning handy design loads of the degrees, this may actually assist so as to add some additional alternative for gamers, and even open up the chance for an limitless 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 may count on for a scrap job.

Deciding on Proc-Gen
Initially I solely deliberate on utilizing procedural era for the textures of the asteroids and never the degrees themselves. My concept was that because the recreation is not going to be infinitely lengthy, and procedural era is tough to really make good and attention-grabbing, I might hand design every stage as an alternative and reap the advantages of a human contact (like putting assets particularly to trick gamers or give them an enormous payoff). I had an enormous love of procedural era once I first began programming, and made a number of little experiments but in addition wasted loads of time making an attempt to get the outcomes good 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 truly pull off.

Now although, first rate procedural era began to look extra attainable. After engaged on the sport all this time I felt I had a significantly 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 loads of ranges, and partly from having extra instruments out there 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 present myself one week (which became one and a half after different commitments) to have a critical go at it, so what you are seeing right here is the results of that. I am fairly happy with the outcome, and I feel it might solely get higher with tweaks and added options.

Step 0 – Parameterisation
The era is definitely fairly closely parameterised, with me specifying precisely what number of asteroids of every dimension and kind, what number of assets of every kind, what destruction to use, and at last what different entities to put. Due to this, I am just a little reluctant to name this “procedural era” because it’s extra simply intelligent placement of issues. Once I consider procedural era I consider the massive worlds of video games like Dwarf Fortress. However this strategy works effectively for me as a result of I do need to actually specify what goes right into a stage for the aim of steadiness and a few type of predictability.

Step 1 – Asteroids
Step one is the location of asteroids, since they’re the most important objects on every stage and every little thing revolves round them. There are 4 totally different sizes of asteroids (Giant, Medium, Small, and Tiny) and presently three differing types (Purple, Crimson, 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 most important asteroid dimension out there
2. Choose an out there asteroid kind for this dimension
3. Discover a random place for this asteroid with some extra padding round it
4. Determine whether or not we’ll use a preset
4.1. Discover all presets which we now have out there asteroids for
4.2. Place a preset which does not intersect with different asteroids
5. Determine the entire variety of asteroids on this cluster
6. Place asteroids on this cluster till we attain the entire 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 steadiness between being random, attention-grabbing, enjoyable to fly round, and likewise semi-natural wanting. 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 completed some mining. That is completed earlier than putting any assets 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 assets however then determined to not take them. The destruction can also be bodily simulated in order that asteroids appear to be they’ve truly been moved by what’s been damaging them, and having assets/entities positioned whereas that’s occurring could make issues look just a little too random.

In the meanwhile there are two sorts of destruction for randomisation; explosive expenses, and bullet impacts. The destruction for explosive expenses is positioned on the circumference of Giant or Medium asteroids, since putting 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 affect, after which creating small destructions for these positions. After every destruction there is a random probability to put some particles related to it, corresponding to shrapnel from explosive expenses, or un-detonated bullets from bullet impacts.

Step 3 – Entities
These are the totally different entities that we’d need in a stage, 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 would like one stage to have a container that is all the time empty, I would specify rule CONTAINER_EMPTY within the parameters, or if I desire a later stage to have a container with some good loot in I would specify rule CONTAINER_LOOT_3.

Step 4 – Sources
And at last there are the assets, that are parameterised by kind (Blue, Inexperienced, or Crimson), amount, and the vary of depths they are often positioned at. Presently, there are guidelines stating which asteroid sorts a useful resource could 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 terms of putting assets we do the next:

1. Select a useful resource to put
2. Get all asteroids this useful resource could 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 present useful resource
5. Place the useful resource there
6. Repeat till all assets are positioned

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


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

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

First I attempted throwing it on a separate thread and locking between updates in order that the primary thread and the era thread weren’t combating for a similar assets, however even that did not work due to some restrictions to utilizing graphics parts 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 stage era right into a C# Generator Methodology, 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 ahead to a timer to elapse between every stage era step or placement. Enjoyable!

What’s Subsequent?
Now that I’ve this working I can 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 era outputs is totally editable utilizing my makeshift stage editor, so if I see it producing one thing that I do know might be higher, I can do just a few guide tweaks and voila.

This additionally units the sport up effectively for a possible limitless 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 truly get there.

If you have to this level, thanks a lot for studying, and I hope you discovered this all even barely attention-grabbing. If you happen to did, be sure you 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