Coder Social home page Coder Social logo

jslou-1019's Introduction

Click Here for the Slides

Interesting Procedural Generation resources...

In computing, procedural generation is a method of creating data algorithmically as opposed to manually, typically through a combination of human-generated assets and algorithms coupled with computer-generated randomness and processing power.

What IS Proc Gen?

In Simple Terms, ProcGen -> Procedural Generation

A Process for Creation of Content

  • Uses curated rules or building blocks
  • Plus usually a Sprinkle of Randomization
  • An an Engine to make sense of it all.

.. it's usually code that uses small bits of content legos, put together in random ways to create dynamic content that can cover a wide range of possibilities in place of static content.

Some of my Favorite Things that Use ProcGen

Thing Details
Dwarf Fortress The deepest, most intricate simulation of a world that's ever been created.
Art Toy A beautiful animated flower generator, that relies on an array of ints as 'genes'.
Cave of Qud Is a science fantasy RPG & roguelike epic. It's set in a far future that's deeply simulated, richly cultured, and rife with sentient plants.
Spore Spore is a 2008 life simulation real-time strategy God game developed by Maxis, published by Electronic Arts and designed by Will Wright.
Nested A universe simulator.

But Proc Gen is not JUST for games.

If you can define it. You can generate it.

.... the problem is in the defining.

The Two Biggest Issues - SCOPE and OATMEAL!

SCOPE - The Problem

You've decided to SIMULATE THE WORLD!

Everything's so big!
And all the details so intricate.
And there's SO many edge cases!
I could be defining things FOREVER

SCOPE - The Solution

START SMALL!
Small parts.
Small pieces.
Small timeline!

OATMEAL - The Problem

You've got everything down to the smallest oat able to be generated in infinite detail!

There's lots of detail!
And SO much variation!
... but very little observable difference.
... and thus ultimately little impact.

OATMEAL - The Solution

FAIL FAST!
Try it.
Tweak it.
Expand it!

... basically this should sound a lot like writing most software. Find your MVP and iterate iterate iterate!

One of my Favorite Proc Gen Tools;

The Basics

An author-focused, curated, simple text generation tool by Kate Compton

  • Originally Written in Javascript (but 'ported to many others!)
  • Requires a JSON structured Grammar
  • Expands rules to generate text...
  • ... but remember, html is ultimately just a special text!

What does it mean to make an ‘author-focused’ generative text tool?

We consider the potential authors for such a generative tool to be creative persons who are interested in the expressivity of language and the aesthetics of prose. They may not self-identify as ‘programmers’ or want to write code, but they want to create generative text that is algorithmically combinatorial and surprising, while still seeing their authorial ‘voice’ in the finished text.

Grammar

Written in JSON

Tracery's backbone is built on the concept of grammars; written in JSON, a grammar is key value pairs. The key is the name of a rule, where the value is an array of options to choose from.

{
  “color”:[“blue”,”red”,“purple”]
}

Here we've described a rule color with three potential expansions: blue, red or purple.

Rule Expansions

Once defined, a rule can be triggered for expansion. Internally this triggering is done by using the rule name in a separate rule but surrounded by # symbols. (Ex: #color#). This expansion means that every rule triggered will be flattened - changing it from a potential choice across multiple options to one singluar option. (Ex: The expansion of #color# could turn into purple.)

Generally, the distribution of probability is even across the options within a rule, but you can reweight them by repeating options. (Ex: Changing color to choose from blue, blue, red, purple would result in blue being chose twice as often as the other colors.)

Also, the 'root' of your grammar is generally expected to be named 'origin'.

{
  “color”:[“blue”,”red”,“purple”],
  “origin”:[
    “I like #color# cake.,
    “I like #color# hats.
  ]
}

Here we have our original color rule, but now have our root story node origin that also utilizes that color rule.

Flattening #origin#

If we were to flatten #origin#...

  1. #origin# is our first expansion.
  2. #origin# then could be resolved as "I like #color# cake."
  3. This includes the rule expansion, #color#.
  4. #color# could then resolve into "purple".
  5. #origin# becomes "I like purple cake."

From this base understanding you can create much more complicated choice trees by nesting or combining rules.

{
  “color”:[“blue”,”red”,“purple”],
  “origin”:[
      “I #opinion# #obj#.
  ],
  “feel”:[“dislike”,”like”],
  “obj”:[#color# #thing#],
  “thing”:[“hats”,”cake”,”birds”]
}

Modifiers

Tracery has also been built to include a bunch of language specific modifiers, as creating understandable english prose can be hard if truly including a loosely coupled variance. Examples include things like capitilization, pluralization, addition of an indefinite article etc.

{
  “color”:[“blue”,”red”,“purple”],
  “origin”:[
      #color.capitalize# #thing.s# are lovely.
  ],
  “thing”:[“hat”,”cake”,”bird”]
}

#origin# here could become: "Blue birds are lovely" after the modifier applications, even though color's options are all lowercase, and all thing options are singular.

Conditional Rules

Sometimes though, you want to use a bit of saved state - usually for keeping track of a particular choice for reuse. (#color# expansion chooses a new color every time it's used!). You can instead, however, expand a rule into a new rule definition by using this definition syntax: [ruleName:#expansion#]

{
  “color”:[“blue”,”red”,“purple”],
  “origin”:[
      [chosenColor:#color#]I like #chosenColor# birds, but not #chosenColor# bananas.
  ]
}

#origin# here could become: "I like red birds, but not red bananas." because a color is expanded and stored into chosenColor before the rest of the rule evaluates.

Expansions work from left to right, so make sure to add rule definitions that the rest of your text might require to the beginning of your text expansions, rather than at the end.

Other Useful Resources

Here are some other useful resources to read up on (and try your hand at building) tracery & grammars.

jslou-1019's People

Contributors

lilacllama avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.