Image of a stylistized jerboa holding a golden nugget
‘Nugget’ aka Sahra of the Desert

The First Completed Milestone

This milestone is part of the claim engine, which makes mining in GoldClaim deterministic, fair and most importantly, strategic. You can still lowball your mining operations and hit a motherlode given enough time or sheer luck though.

Author’s note: First milestone for GoldClaim” – actually not quite, as it’s the first externalized milestone. Internal milestones would introduce clutter on this site.


Overview

First of all, this is a technical section.

I need to explain the upper layer, which is the claim engine. A major enabler of this engine is actual prospecting as result of deterministic mining. As mining games and simulators incorporate randomness to both mining and prospecting, I wanted to design the level beyond that to give meaning to prospecting and finding resources. Being able to actually read the terrain allows one to narrow down where to dig next. The resource generator is one of the two major modules inside the claim engine to make it happen.

During the early design-phase, the resource generator was simply a nugget generator. Now it not only handles the creation of nuggets, but any other type of resources as well. It does so bi-directionally, meaning it can also be told to recreate an existing resource – this reduces the required memory to both run and save the game. This keeps the runtime memory and save files very small – critical for console performance.


Claim Engine Modules

The resource generator is one of the claim engine modules I am building. It’s composed of these modules:

Claim Engine
├─ ClaimChunkRepository -> backlog
├─ ClaimContracts -> on-going
├─ ClaimGenerator -> next up
└─ ResourceGenerator -> this page

Chunk Repository: This one is done lastly when all requirements are detailed enough. The chunk repo just manages the chunks, just like a single block in Minecraft or 7DTD is stored for example. It has a position and has certain properties, and must be managed by a repo.

Claim contracts: Literally software contracts. This one gets too technical, but let’s assume this tells the other modules how they should interact internally and with each other – it even extends beyond this engine which is the beauty of contracts.

Claim generator: Not yet started one, but the next module to be tackled once the resource generator is finished. It’s to create the actual claims in such a way that mining is made as intuitive and gameplay-rich as an indie game should go. The fine balance between utmost realism and non-tediousness for lack of a better word.

And finally the module represented by this page, the resource generator – let’s continue.


Engine capabilities

The resource generator is capable of handling a biome’s composition, or rather the exact geomorph-type present on that biome to generate resources within that setting. This is what it’s now capable of:

  • Resources will reflect the biome, meaning you can even trace back where a specific type of nugget came from
  • In GoldClaim, not one nugget will (statistically) be the same
  • There’s no AI involved – this is pure mathematical- and art prowess created by a mad scientist
  • It supports modding out-of-the-box for new types of resources with simple, intuitive JSON-scripts
  • Generated resources can be regenerated using the output JSON, with less than 1 KByte of data (this means great flexibility with both savegames and ability to (re)generate the resources on-the-fly)
  • It allows custom textures per resource – I’ve hand-designed all of the resource textures already
  • It allows any shape to be generated within the defined threshold, and there are many levers for modders available

Modding support

Do you like modding? If yes then you might want to read this, otherwise it’s fine to skip ahead to the generated resources as it gets more technical.

GoldClaim will embrace the modding community, to be as creative as possible. A single resource can be regenerated with the tiny JSON script below:

{
  "Version": [1,0,0],
  "Seed": 774548,
  "ResourceType": 1,
  "GeomorphType": 2,
  "QualityType": 0,
  "Purity": 0.6868,
  "Quality": 0.5512
}

The seed parameter is to feed the RNG (random generator) for creating a singular resource. You can use your own RNG, or let the engine handle it. The types will be made public once the game is released to prevent spoilers for now. ResourceTypes can be gold, silver and various types of minerals.

GeomorphTypes are for example fluvial, lowlands and highlands (temperate biomes). There are currently 6 biomes, 9 geomorph types and tons of resource types, which is an ongoing list actually. Geomorph types influence the resulting shape of the resource as well. For example, gold found in the mountains tend to be more angular and have more cavities/holes as gold is more closer to its source. Newly formed gold travels in streams of lava, which tends to cool unevenly, come across sharp edges and therefore define its primary shape. In rivers, gold is washed, tumbled and smashed into obstacles which gives it the rounded more solid shape. You can actually narrow down where a specific nugget in GoldClaim originated from.

Important is that generation is based on an extendable ruleset. This can therefore be extended with custom textures and new shape definitions. Also due to its compressable format and swapping to the custom format I’ve designed, you can literally generate millions of resources, while the engine won’t flinch and still only have a couple of tens of MB (compressed) as your asset metadata.

The actual script only needs to be called during close examination (so after the gold cleanup and examining the spoils of the day). That’s when the regeneration takes place, and it can be instantiated on a separate CPU thread as well. This result is being able to go nuts on deterministic, unique resource entities and still touch it all, for tons of claims even running on the background (e.g. by competitor NPCs). You can even put its unique shape on display in your cabin/office if you want to, as the script provides information regarding its aesthetics.


Resource generation

So the question might be how it translates to the game: This little furry desert-rodent below holds something shiny – a golden nugget which is a direct output from the resource generator. The second image displays the actual used nugget among the others:

The resulting nuggets have a flat texture. I will let the game engine account for lighting/specular/shadow FX, just like I did during the post-editing with the jerboa.


Uniquely generated resources

A follow-up question might be: How many different types of resources? — Let’s do the math: The RNG positions can be 100000 to 999999. That’s already 899.999 different types.

As explained, its geomorph type further defines it shape. This is where the math gets messy: We have to multiply the ~900k with the geomorph’s definition. These definitions are ranges however. For gold, I narrowed it down to ~40 more configuration possibilities with just 2 categories: Rounded and angular shape types. With those categories included, we hit 3.6M variants.

Then there are more ingredients like cavities and texture positions – the math then explodes as it no longer makes sense to determine how many unique gold nuggets are possible – that’s just gold.

Furthermore we have 6 more precious minerals which get the luxury of being modeled in full like gold and silver. However, these don’t get as many variants as gold/silver, as it doesn’t make sense for them. These are for cutting, polishing and jewelry crafting. Textures will play the main role for them. However, I’d say it should be nearly impossible to find 2 of the same shape and texture in a single playthrough.


Inner workings of the texture variations

Textures are ‘stamped’ out of a large texture map (not an atlas), and the engine can rotate/flip it and apply it to a custom silhouette. This results in additional variations, without the extensive complexity of generating a random texture map per type of material. The engine first generates the silhouette based on geomorph parameters limited by its current biome, determines the quality, size and even whether it’s rounded or angular (e.g. rivers produce more rounded nuggets, where mountains produce angular + perforated ones).


Other generated resources

With the image below I want to demonstrate 4 other resources the engine is capable of producing in its current state, and I can truthfully state that they’re a direct output from the resource generator as well:

other generated resources

Other resources actually generated by the resource generator (prototyped — not all will appear in the actual game)

It’s already capable of generating more resources, virtually any solid resource. That said, the presence of gold and silver is a given, but simply adding other resources isn’t that simple, as it has to maintain economic balance and integrate with both the biomes and mining machinery. I might do another pass on texturing and lighting/shadows for the 9 current resources, but for now I call this MVP-worthy.


Mining simulation

GoldClaim is a top-down RPG mining game which organically incorporated mining simulation aspects. At certain stages it can be called a mining simulator. It sports a fully deterministic resource allocation engine, it has both extensive mining operations and paydirt washing operations, and even more extensive paydirt processing operations.

This page however covers the resource allocation, to keep the content to sane

Deterministic Claim Resource Allocation

Claims and their resources like gold nuggets, silver nuggets and others will be determined at that very moment, which separates it from the average mining game and sometimes even actual simulators:

  • Average mining game – They involve having an RNG (random generator) the moment you’re mining or washing. It keeps the logic simple and performance high, but has random behavior as trade-off which defeats the purpose of prospecting and tracing. This is the go-to model for most mining games, especially in an RPG setting.
  • Simulators — Gold mining simulator games usually have deterministic claim resource allocation and washing operations, but then still switch to RNG with panning results and determining gold piece sizes.

GoldClaim — The engine tackles all:

  • The composition of claims are deterministically created with a new game.
  • Mining, washing, panning, prospecting, their results are based on what’s geologically determined by the engine.
  • Events, RPG stories and even the game difficulty setting will not meddle with this.
  • Tailings will always be tailings. If you have missed gold, it’ll be in your tailings and you can reprocess it.
  • Once you start the game, the world of Valaenia has been determined. Every player will have a unique experience of the land’s composition.

This means that when resources are in the ground, you can trust it will always be there until it’s taken away. It’s up to your sluicing skills, machinery and wittiness whether you’ll have it in your pan or tailings.

Tailings aren’t indefinite waste. This does mean that performance issues will creep up, but like I said, this has been tackled gracefully while even still supporting modding capabilities.

The true trade-off? The design phase: More logic means extensively longer design times, implementations and testing. And this is a completed phase.

True motherlodes

When you’re prospecting or mining, you can visually determine depth, which is useful for determining where you exactly are in a comprehensible 3D-axis. The engine mixes both sprites and 3D geometry for claims thanks to its hybrid-approach. What’s important, is that resources can therefore be placed at depth, while it still feels like a regular pixel-art game.

The engine supports limitless depth actually (or technically how far a float-value would go), but system memory has to be considered — especially as claims can be a ridiculously whopping 1 x 1 km. Currently a mining depth of at least 20 meters can be guaranteed. And yes, you can dig a deep hole and quickly reach the bedrock after stripping the overburden, but what are the chances you’ll find the motherlode? Is there a motherlode? You will have to either prospect or dig at multiple areas to find out where the gold is — this is the way of GoldClaim.

What we get in return is:

  • Enable true motherlodes — my personal favorite
  • Prospecting suddenly becomes meaningful
  • Accurate balancing — less post-MVP balancing, less bugs to be fixed
  • Decrease ‘reroll’ exploit temptation when acquiring a claim or even mining a chunk in a suspected motherlode

Here’s a visualization of how a claim will actually be generated computationally:

The golden spheres represent nuggets injected into the 3D-space of a claim, whereas the ellipsoids represents the motherlodes. Note the composition layers of the motherlode, and also note that a higher density of nuggets indicate the possibility of a nearby motherlode when prospecting or mining.

Resource generator internals – for the architectural enthusiasts

Messy technical details below, so skip ahead if you want the short version.

In the image above we saw a large claim in wireframe: 100×100 meter grid, 20 meters deep. Every sector is actually locked to already defined parameters, from the very beginning, buried deep in the design documents:

1 sector = 1 chunk. A chunk is 1x1x1 meter, 1500 kg cap if overburden or paydirt, 1000kg fixed if water. While players and machines mine per chunk, the actual contents of a chunk can be less than the weight cap. It’s a composition of dirt, rocks, minerals and precious resources.

I’ve hidden the chunks in the claim above and you can clearly see it’s quite nugget-rich with the nuggets displayed as noise (the tiny spheres) in the paydirt, and 2 large ellipsoids. These are not super-giant nuggets. These are the radii in which gold dust, flakes and nuggets have the largest concentration -> this is what you want to find in a claim. Even I can no longer tell where these motherlodes will occur once I let the engine do what it’s made to do – they can even intersect each other. Also, it will be biome-dependent on whether they’d rather sit deep onto the bedrock, or rather in deep abrasive river pockets.

I believe this alone is a big win for mining enthusiasts like myself, as it makes sense to actually prospect a claim, determine whether you want to acquire it at all at your current stage. But perhaps even more exciting, hone in on the actual motherlode and believing it either is there or isn’t – No real-time reroll randomness manipulating outcomes. A should-be mental switch for enthusiasts as the world won’t be cheating you at all, and like I stated before, not even the game difficulty will change a thing.

The reason this method may not have been applied before, is because it increases the logic immensely and requires extensive mathematics, but it’s more easily solvable using code.


Summary

So to wrap it up: The resource generator is part of a larger claim engine composed of chunk management and deterministic generation logic, capable of placing motherlodes at any place. Anyway, this is how it translates:

  • ellipsoids with a certain falloff have to be cast to create the motherlode
  • additional richer deposits could overlap others
  • the regular resource allocation’s ‘noise’ has to be either deducted from or added to those ellipsoids

Next up: Claim engine

The next milestone is finish programming it. It should be done next month, unless I find an unforeseen dependency which is still allowed to happen at this mixed stage of design and implementation.

Also, kudos to whoever has read this far – I have trouble holding back whenever I can open up on engine internals for a project like this and it will get technical then.

– Litanic

Leave a Reply

Your email address will not be published. Required fields are marked *