Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Ideas for beginners to proc gen and programming?

A topic by Cam created Nov 06, 2016 Views: 1,293 Replies: 16
Viewing posts 1 to 5
(1 edit)

Hi everyone!

I'm an inexperienced programmer that is learning C# in Unity. I'm really inspired to try to do something for ProcJam but I'm unsure where to start, as most of the things you find on procgen require considerable programming experience. (I've read the "5 ways..." post but I guess I need a bit more of a helping hand or understanding to get me on the right path and the creative juices flowing.)

Perhaps this might even develop into a resource for following ProcJams for people like myself.

So if you have any tinsy-tiny ideas, explanations etc, please, I'd love to hear them. It doesn't matter how small the idea is I'd just love to submit and come out the other side having learnt something about procedural generation.

Thanks for your time.

Cam

I'm a big fan of http://catlikecoding.com/unity/tutorials/

He explains stuff really well too.

I like Jasper's tutorials too. I began his procedural tutorials a few months ago but found I was just copying the code instead of understanding what I was doing and why (cave generation typically requires intermediate programming experience, which seems to be ~90% of procgen tutorials).

I believe I need to have a better foundation in programming before tackling procgen of that complexity. That's where I'm struggling; finding it difficult to grasp the full gamut of what procgen could be and mean. What it is in its simplest form. Is it simply using random elements within a semi designed constraint?

This is my personal view on your last question (writing on phone we'll see if it assists me in some of the text).


To me it is about emergence.

You have some sort of non-predictable input and rules to interpret/constrain it.

The input can be ununiform random like random.value or random.range, or it can be pseudo random like perlin noise.

It can also be player input, most recent tweets, time of day.

Or many other things and maths transformations of these or combinations.

The rules will of course depend on what tickles your imagination. In the simplest forms they are schema in which you select content from some database. But maybe they are distributed like cellular automata, boids or maybe they have a memory and build up a bias for certain outcomes over time.

So this might not have been helpful, but in principle I'm trying in a very convoluted way to answer yes!

There's nothing much mystic about it all. Just letting go and see what comes out .


As an example, I'm trying to make a poet that will write song lyrics based on a word graph I constructed from 10k songs and some ad hoc rules so it will rhyme and such.

Oh wow, that poetry project sounds cool. I'd love to see it when it's done.

I looked up what boids are and that stuff really interests me. I also really like the idea of something that learns from experience. Sadly, I've a long way to go before I'm capable of doing that sort of stuff. I don't even know where to start because everything seems to be targeted at intermediate to advanced programmers!

(1 edit)

You are probably right that many tutorials and descriptions assume quite a lot of previous knowledge. Admittedly I've probably levelled a bit from the beginner programmer and Unity user by now but my general way of solving my own lack in skills is simply allowing for spectacular failure and/or boring results. In all (?) cases, my adventures into procedural generation stems from more or less explicit questions following the structure "What would happen if I did X?"

As an example, let's say I wanted to do random mesh generation in Unity. Reading some on it one learns that meshes are constructed from triangles. Well, how would it look if I on every frame just decided on a random number of triangles I wanted the mesh to have (e.g. between 1 and 10), and just made a Vector3[] verticies array 3 x number of triangles. And for each vertex I simply made a random Vector3, not caring at all about those rotation rules. Finally update the mesh with the new array.

Like this

That would probably be utter chaos, so maybe one could slow down the update frequency somehow or maybe one would only update some of the Vector3 in the array from the previous iteration and keep the rest.

It wouldn't be hard to get some results and see what happens when tweaking the parameters. Maybe hard to go from there to a full experience that could be called a game, but that is besides the point. In the process one learns some about procedural mesh generation and next time one can try to add more constraints and/or different sources or random. The procgen entity could be placed in a room on a pillar, drop a default FPS controller on the camera and you have an exhibition.

As for my song-writer, it is struggling with sounding human, but I don't mind:

"like forty miles a-a-away You crackin' Like ripples run everything
I've robbed a puddle.
Something something cooking inside of desire burning matches Lifting latches"

Thank you for the reply. That's an interesting way to look at things; How can I break things and what will the results look like? Best of luck with your poet project!

There's a famous quote that goes, "There are only two hard things in Computer Science: cache invalidation and naming things." Of course, the real problem is naming things sensibly. With that restriction lifted, naming something becomes one of the easiest projects you can do! It really only requires that you know how to do three basic things: how to choose a random element from a list, how to concatenate strings, and how to print strings. That's the bare minimum to get something up and running. Anything you add on from there, like turning it into a logo or reading from an external list of words, is just gravy.

A name generator is also very well-suited to command line programs or twitter bots.

Genre and specificity is definitely your friend when it comes to picking a concept for your name generators. A movie title generator is probably too general to be very interesting. Limiting your scope to pulp adventure movies is better, but a bot that makes up names for Indiana Jones sequels immediately suggests a few specific forms and word types: Indiana Jones and the {noun} of {noun}. Indiana Jones and the {adjective} {noun}. Nouns: temple, doom, crusade, skull, cathedral, city, death, bones, gold, silver, ruby, emerald magic. Adjectives: lost, last, spooky, crystal, deserted, magic, golden.

Thanks! A name generator could certainly be a good fall back as it doesn't require any art. I've never done anything like that before. Would you pull names from an online resource, or just hard code arrays of (copy and pasted) categorised words and chose them randomly?

That's pretty much up to you! Writing out arrays of words directly into your source file is the least difficult thing to do, but it's also not very flexible. Creating and then reading from .json files is only barely more difficult, at least in python.

If you have a file like birds_north_america.json, you could load its list of birds in python 2.7 with the following:

import json

#assumes birds_north_america.json is in the same directory as your script
bird_json = json.load(open("birds_north_america.json))

#this will print "Birds of North America, grouped by family"
print(bird_json["description"])

#this gets the list of bird families
families = bird_json["birds"]

#this gets the first bird family from the list
ducks = birds[0]

#this prints the first member of the duck/geese/swam family
#which is "Black-bellied Whistling-Duck".
print(ducks["members"][0])

"ducks = birds[0]" should actually read "ducks = families[0]". I'd edit the post directly but itch.io's post edit feature messes up code pretty badly

Thanks for the tips! I think for now I'll stick to doing things the nasty way as I don't want to introduce too many ways to fail when I'm already going to be struggling! That could be a refactor later. :)

Submitted (2 edits)

Ok, I'm playing Dark Souls 3 now, so here is an idea about one-button Dark Souls.

You have one button - Attack. Attack takes some time (~1sec), during which you are vulnerable. If during this time enemy does not attack too, you score and enemy loses HP. If he DOES attack, then your attack is interrupted, and YOU are damaged. If you are attacked when not attacking yourself, you automatically block, receiving no damage.

Enemy attacks in pattern - same one each time, or he can have several patterns that he uses back-to-back, choosing randomly. Patterns can be generated procedurally.

Gameplay is basically learning the patterns and finding openings in them.

Graphics can be very simple, or there can be no graphics at all - it can be all done with just sounds.

Sounds interesting, thank you for the reply. To me it almost sounds like a Punch Out type game where learning the pattern and avoiding it until the gap is the key to winning.

If you don't mind me asking, how would you (pseudo) code the pattern? Would it be an array of (say) 5 ints, where each int is decided by a percentage chance to attack? I can't see in my head how to get the individual chances into a stream that plays out.

Submitted

I was thinking no "chance of attack" - if there is an attack in that time in pattern, it happens.

So, something like - choose randomly the duration of pattern, add attacks at random times in this pattern;s duration. Then check that there is no attacks too close to each other, and there is right amount of gaps wide enough that player can squeeze his attack. At lower difficulties you will want more, wider gaps and vice versa.

You make several patterns for a monster like that and don't change them afterwards - all randomness after that is how patterns chain together.

I think I actually understand how you're explaining you would do it! Sounds like something I could probably do over a longer period of time than the jam, but I'd like to try this if not just for a challenge. Thank you again for your idea.

Submitted

Scratch.mit.edu is good for entry level programmers.