Ciro Durán A Live Archive

Traceryhx

Check out Traceryhx:

This is the port of the current (as of August 2016) tracery2 branch of galaxykate’s original javascript implementation. Tracery is a text expansion library. Starting from a data structure that defines strings, Tracery can expand those strings with elements at random. This offers a lot of creative possibilities with a very simple data definition.

Porting the library from Javascript to Haxe was relatively straightforward, as both languages are very similar. An excerpt of the original documentation, explaining how Tracery works, follows.

A text-expansion library

There are many new examples of Tracery in use There is also an interactive tutorial

Write grammar objects, get generative stories

An example grammar

{
	"name": ["Arjun","Yuuma","Darcy","Mia","Chiaki","Izzi","Azra","Lina"],
	"animal": ["unicorn","raven","sparrow","scorpion","coyote","eagle","owl","lizard","zebra","duck","kitten"],
	"mood": ["vexed","indignant","impassioned","wistful","astute","courteous"],
	"story": ["#hero# traveled with her pet #heroPet#.  #hero# was never #mood#, for the #heroPet# was always too #mood#."],
	"origin": ["#[hero:#name#][heroPet:#animal#]story#"]
}

Output of that grammar.

Of course, many grammars are more complex!

Lina traveled with her pet duck. Lina was never indignant, for the duck was always too indignant.
Yuuma traveled with her pet unicorn. Yuuma was never wistful, for the unicorn was always too indignant.
Azra traveled with her pet coyote. Azra was never wistful, for the coyote was always too impassioned.
Yuuma traveled with her pet owl. Yuuma was never wistful, for the owl was always too courteous.
Azra traveled with her pet zebra. Azra was never impassioned, for the zebra was always too astute.