DoujinStars
ShadowRx
ShadowRx

patreon


HL - Hashes, Seedable RNGs, and (later) Fractals

 Working on string-hashing and seedable-RNG functions for more consistent content generation and compression.

A use-case I have in mind is to use an NPC's name to generate their starting stats and other details, such that whenever that exact name was used in the generation, you would always get that person.

A similar case might be the weather for a given date, should you go back in time somehow, the weather would be exactly the same.

This helps create the illusion and consistency of a much larger city/world, without having to generate potentially millions of NPCs ahead of time and deal with the overhead.

It also means you could, in theory, go looking for an NPC you encountered in a previous playthrough and FIND them exactly where you would expect to, and exactly HOW you would expect to, given you had not yet interacted with them and forever changed their destiny.

To make the function/method name easy to remember and type, I made an acronym out of it. It is a [S]eedable [P]suedo-[R]andom ([I]ndexed) [N]umber [G]enerator. And it is designed to take either numeric or sting seeds, storing the current state of that seed at an INDEXED position so that different contexts could avoid collisions with each other's RNG seed-sequences/states.

If anyone has ever played SimCity 1 for the SNES or Diablo II, you've seen maps created by Seedable/Repeatable RNG systems. Every time you select the map with that ID#, you get the same map. And this is done without having to create (in the case of SimCity) 1,000 premade maps- which would have been a NIGHTMARE to store with the ~2-3MB limit of an SNES cartridge.

The only other piece needed to create those types of map-generators would be some kind of fractal/procedural tiling function that helped to logically group the otherwise random tile sequences into usable/navigable patterns.

The applications for these relatively simple technologies are quite extensive, which makes it truly shocking that they are not natively available in Javascript/ECMAScript.

We'll save the figuring out fractal generators portion for a much later date, of course, but we now have a few more dev tricks to work with in our content generation. (Though I do suspect they involve seeding the field with a relatively small number of random elements, maybe 1-10% of the field, then branching out [multi-dimensionally] to fill in the gaps, similar to a lot of noise generator functions. Come to think of it, Perlin Noise would probably make  a decent tile-map for SimCity, with the right resolution and layers for different factors [such as land:water noise, desert:forest noise, flat:hilly noise].)

Anyway, wanted to share a quick update while I'm converting the game's data to the new object format, refactoring several interconnected systems, and preparing to move to the new UI and CMS.

Who here has tried all 4[5] characters? What do you think of each? (Did I go a little too far with the new one?) 


More Creators