When you *really* don't want repeated rules
Tracery currently doesn't have a way to avoid repeating rules. If you can, look at it as an opportunity for unexpected poetics ("Driving through the countryside, I see a silo, a silo, a silo" -@losttesla). But if you need different rules chose, make two non-overlapping lists. You lose some expressive range, but can prevent duplicates for sure.
"adj1": ["soft", "blue", "gregarious"],
"adj2": ["round", "spiky", "sorrowful"],
"story": ["Meet our hero, who is #adj1# and #adj2#"]
When you want to choose from matched sets of things (i.e. set pronouns for a character)
When you want a *really* rare rule
Tracery currently doesn't have a way to put numerical probabilities on rules. You can adjust rule weights by adding extra copies of a rule. But if you want one rule to show up one in a hundred times, or less, you can nest the rare rule in multiple levels of rarity. This example has a 1/5 times 1/5 times 1/4, or 1/100 chance of producing a rare result, but used 14 rather than 100 list items to set the probability.
"common": ["penny", "shilling", "pound"],
"rare": ["blank cheque", "pile of diamonds"],
"story": ["One day our hero found #money.a# and rejoiced"]
When you want to put a comma in a variable
If you use a comma in Tracery's variable push syntax, it will be interpreted as separating elements of a list, and when you evaluate the symbol you'll get a randomly chosen one of those elements. If you meant the symbol to be a single string that contains a comma, you'll have to use a different character. A suitable character is SINGLE LOW-9 QUOTATION MARK in Unicode. You can write it in Tracery as
\u201A, or use the character directly:
In most modern interfaces it will look like a comma, although in some older interfaces (such as the Windows command line) it may appear as an apostrophe.
In some versions of Tracery you can include a real comma in a variable push indirectly, by putting the comma inside an existing symbol and evaluating that symbol. This is a useful test case by hugovk:
"origin": "#defthing#The #WOTSIT#s #thing#", "defthing": [ "[WOTSIT:colour][thing:#colour#]", "[WOTSIT:animal][thing:#animal#]" ], "colour": "orange, blue and white", "animal": "unicorn, raven and sparrow"
When you want a rule to have two different "modes"
Tracery allows you to change the value of a symbol by pushing or popping values on its stack. This allows a lot of flexibility in what text a symbol can contain, but it doesn't let you change the actions it performs, like evaluating another symbol or pushing another value. You can do something similar to changing a symbol's action by making separate symbols for each possible action, and switching them on or off by pushing/popping an empty string on top of them:
"list": "an apple",
"add_apple": "[list:an apple and #list#]",
"add_orange": "[list:#list# and an orange]",
If you call
"#initialise#", you can then call
"#add_fruit#" to extend the list of fruit, and
"#orange_mode#" to change which kind of fruit will be added. Note that trying to enter apple or orange mode while already in it will break the system! You can make this more robust by having the mode change symbols switch themselves off and the other when called.