Doodle Insights #6: On Procgen, Law and Order

--procgen numbers
--by trasevol_dog

print(flr(rnd(10000)))

Procedural generation, or “procgen” if you’re lazy, is about taking data and making different data based on that data. In most cases, the input data is pseudo-random numbers and the output data is something you can look at, whether it’s text, a texture, a 3D model or simply a data structure. (or maybe a procgen behavior but you don’t necessarily want to look at that)

The making of the output data is done with an algorithm. The idea being that any data can be in the input, the algorithm consists of a system of operations and rules to make sure that the output data fits our expectations more-or-less loosely.

These rules are the subject of today’s Doodle Insights!

For this we will be considering that the input data is random numbers.

 

Let’s start with that very short “procgen numbers” snippet of code from above. This lone line simply prints a random integral number between 0 and 9999.

By the way, this snippet and the derived doodle which you will see further down are a joke. Procgen is commonly based on random numbers in the first place, so making procgen numbers seems pretty useless. I am very funny.

What makes it interesting is the two rules applied to the raw Pico-8 RNG:
– The random number can only be between 0 and 10000.
– The random number is floored, so it will always end up as an integral on the screen.

These two rules, as simple as they may be, have a drastic impact on the final result. Removing the flooring rule will make it print float numbers, with points and more numbers after the points. This is just my opinion but I think that float numbers are generally hard to read and less exciting visually than integral numbers.

Modifying the rule about the number being between 0 and 10000 can have three different effects. Either you will set the maximum to some random value such as 4321 or 2548, which will only mess up the distribution of the digits in the output numbers. Setting it to a value of 100 or 10 will change the number of digits in the output numbers. And setting it to 100000 or anything above 32767 may give you surprising results. Pico-8 numbers only range from -32768 to 32767. If you try to print a number higher than that upper limit, it will wrap around and you will see a negative value instead.

So one rule is only for aesthetic reasons while the other one is also for technical reasons. These are your two main concerns when doing procgen. And these two concerns should shape the rules of your generation. (swap “aesthetic” for “functional” if you’re generating behaviours)

 

Let’s make our number generator a bit more interesting!

--procgen numbers
--by trasevol_dog

color(8+rnd(8))
local k=flr(rnd(8))
for i=0,k do
 print(flr(rnd(10000)))
end

pico-8_11

Now, running the program gives us a bunch of numbers fitting the same conditions as before, and each time in a random color from the second half of the Pico-8 palette. More randomness!

These two rules are fairly simple as well but make for much much more diversified results! The changes in colors and quantity are quickly noticed by the eye. Generally, when generating visuals, colors, shapes and sizes will be the three most important factors to be played with because that’s what you use to recognize things.

You may notice that I did limit the colors only to the 8 last colors of the Pico-8 palette and also that there cannot be more than 8 numbers produced at one time. The color rule is just personal preference, I like the colors 8-15 better than the rest, they look more happy. The quantity rule is also personal preference but I do think that more than 8 numbers becomes uninteresting as you really won’t bother to take a closer look at them anymore.

Each rule has a reason to be there. It doesn’t have to be a good reason, most of the reasons I have for my rules are very arbitrary. But as soon as you lose sight of the reasons for your rules, you may start to code contradicting rules and modifying rules that should not be modified. Your ruleset can become hell in a matter of minutes this way.

I did extend on that dumb idea of procgen numbers and did this doodle (which you can download on my Patreon as a 1$+ patron! ;D ):

procgennumbers
Pico-8 Doodle #64

Here are the different elements that can vary in this continuous generation: random numbers, of random sizes, with random colors, at different positions and different speeds. Each of these elements is limited to produce visually pleasant results. Most notably, every number generated has a discreet shadow and a black outlined, so it can be discerned from other numbers of the same color and also to avoid terrible clashes of colors. This is a non-procgen solution to natural procgen chaos.

 

Now when you get deeper into procgen you tend to imagine making everything procgen. So what would happen if we generated our procgen rules? While this calls for a more abstract architecture, this is very doable and here is one doodle that is partly based on this idea.

pico-8_254
Pico-8 Doodle #30+?

This is typing in a procgen language. The letters are procedurally generated, then words are generated from the letters, grammar is generated from the words and finally the typing is based on the grammar. It definitely works well if you want to give off a sort of alien or misunderstood feeling. It doesn’t really work if you want anything else.

But you don’t have to go that far either. Here is a glyph generator in which each glyph has a random one of three rulesets defining its symmetry or lack thereof.

pico-8_238
Pico-8 Doodle #20+?

And frankly, sometimes your procgen can really be as simple as choosing random indexes. In this next doodle, each character has random animation indexes and random color indexes used for palette swapping. But just with that they all already look so different!

socialexp
Pico-8 Doodle #57

Finally I’ll say that for more serious project, you should always make sure that your rules are strict enough to (almost) always generate “good” results, nothing looking *wrong* and more importantly, nothing that might break your game.

 

Procgen is made up of rules that treat input data and produces cool and diversified output data. You can have as many rules as you want but you should have a reason for each of them and you should keep track of them. You can also go full meta and make rules to generate rules but always make sure the results are in the scope of the wanted model and don’t break everything. Sometimes, just a few simple rules are the best way to do it.

If you want to see more procgen, I strongly encourage you to check out Orteil’s generators (he’s the guy who made Cookie Clicker but his generators are cool too) and the PROCJAM creations from last year!

 

I hope you enjoyed this Doodle Insights #6! If you have any questions or remarks, please put them on the Patreon post!

These Doodle Insights are here thanks to the awesome people supporting it on Patreon! Here are their names!

Joseph White, Adam M. Smith, Ryan Malm, Matthew, Tim and Alexandra, Sasha Bilton, berkfrei, Nick Hughes, Christopher Mayfield, Jearl, Dave Hoffman, Thomas Wright, Morgan Jensen, Zach Bracken, Anne Le Clech, Flo Devaux, Emerson Smith, Cathal O’Keeffe, Dan Sanderson, Andrew Reist, vaporstack, Dzozef, Cole Smith, Jared Butowsky, Tony Sarkees and Justin TerAvest!

I don’t know what the next Doodle Insights will be about but maybe recursive generation could be interesting? Let me know how that sounds to you!

The Procgen Numbers doodle can be downloaded here, the other ones are either in this pack or can be downloaded on Patreon by ‘Pico-8 Lover’ tier patrons!

Have fun with the procgen!

TRASEVOL_DOG

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: