Comments (3)
I've run into something this issue actually prevents me from doing. I'm trying to have a generated narrative remember what the hero is trying to accomplish, but the hero's goal is a list of alternatives like "money, riches, treasure" or "medicine, a cure". Since the nested narratives have different goals, I need to rename "quest" to "quest2" to keep it from being forgotten. But if I use something like "#[quest2:#quest#]tellStory#", of course that just picks one element from the list. So really what I'm wanting at the moment is a way to wrap "quest", keeping it from being evaluated; or something like #quest.rulesList# which would evaluate to the list "money, riches, treasure" for example.
The thing is, I can't seem to find a viable workaround. Here are several attempts to get around the problem:
{
"origin": ["#[#setVars#]thepattern#","#[#setVars#]thePatternWrapper#","#[settings:#setVars#]smarterWrapper#",
"#[settings:#setVars#]evenSmarterWrapper#"],
"thepattern": ["#one#, #one#, #one#, #one# ..(thepattern).. #two#, #two#, #two#, #two#"],
"thepattern2": ["#one2#, #one2#, #one2#, #one2# ...(thepattern2)... #two2#, #two2#, #two2#, #two2#"],
"thepattern3": ["#one3#, #one3#, #one3#, #one3# ....(thepattern3).... #two3#, #two3#, #two3#, #two3#"],
"thepattern4": ["#one4#, #one4#, #one4#, #one4# .....(thepattern4)..... #two4#, #two4#, #two4#, #two4#"],
"thePatternWrapper": ["#[one2:#one#][two2:#two#]thepattern2#"],
"smarterWrapper": ["#[#settings#]smarterWrapperHelper#"],
"smarterWrapperHelper":["#[one3:#one#][two3:#two#]thepattern3#"],
"evenSmarterWrapper": ["#[#settings.replace(one, one4).replace(two, two4)#]thepattern4#"],
"setVars": ["#setOne##setTwo#","[one:plane, car, road, boat, vacation][two:kiss, wedding, date, longing gaze, heart, cuddle]"],
"setOne": ["[one:yes, no, maybe, try again, reply hazy]","[one:cat, dog, horse, bird, puppet, seahorse, fish, espionage]","[one:1, 2, 3, 4, 5]","[one:many, some, multitudes, a number]"],
"setTwo": ["[two:ufo, pyramid, greek fire, bigfoot, Barney]","[two:life, taxes, free will, morality, missing socks, calculus]","[two:into, under, out of, between, within, acquitted of]"]
}
"thePattern" does what I'm trying to do, but isn't protecting the variables, so it would lose them if I recursively called "thePattern". The rest of them prematurely collapse "one" and "two" down to one possibility.
The results look like this:
no, no, no, no ...(thepattern2)... between, between, between, between
some, some, many, many ..(thepattern).. out of, acquitted of, out of, between
((one4)), ((one4)), ((one4)), ((one4)) .....(thepattern4)..... ((two4)), ((two4)), ((two4)), ((two4))
vacation, vacation, vacation, vacation ...(thepattern2)... cuddle, cuddle, cuddle, cuddle
((one4)), ((one4)), ((one4)), ((one4)) .....(thepattern4)..... ((two4)), ((two4)), ((two4)), ((two4))
car, boat, plane, plane ..(thepattern).. date, cuddle, kiss, longing gaze
((one4)), ((one4)), ((one4)), ((one4)) .....(thepattern4)..... ((two4)), ((two4)), ((two4)), ((two4))
road, road, road, road ...(thepattern2)... kiss, kiss, kiss, kiss
multitudes, multitudes, multitudes, multitudes ....(thepattern3).... calculus, calculus, calculus, calculus
((one4)), ((one4)), ((one4)), ((one4)) .....(thepattern4)..... ((two4)), ((two4)), ((two4)), ((two4))
a number, a number, a number, a number ...(thepattern2)... calculus, calculus, calculus, calculus
road, road, road, road ...(thepattern2)... kiss, kiss, kiss, kiss
((one4)), ((one4)), ((one4)), ((one4)) .....(thepattern4)..... ((two4)), ((two4)), ((two4)), ((two4))
plane, plane, plane, plane ....(thepattern3).... date, date, date, date
((one4)), ((one4)), ((one4)), ((one4)) .....(thepattern4)..... ((two4)), ((two4)), ((two4)), ((two4))
plane, road, plane, boat ..(thepattern).. longing gaze, kiss, date, wedding
seahorse, dog, bird, puppet ..(thepattern).. under, out of, out of, within
((one4)), ((one4)), ((one4)), ((one4)) .....(thepattern4)..... ((two4)), ((two4)), ((two4)), ((two4))
((one4)), ((one4)), ((one4)), ((one4)) .....(thepattern4)..... ((two4)), ((two4)), ((two4)), ((two4))
2, 2, 2, 2 ....(thepattern3).... into, into, into, into
5, 5, 5, 5 ...(thepattern2)... life, life, life, life
I really can't figure out why the "evenSmarterWrapper" approach (pattern4) didn't work! Shouldn't the "replace()" change the names before the text is even evaluated? Come to think of it, though, that method wouldn't offer any protection if I was doing recursion.
A second feature that would help me out here would be double evaluation. I could have symbols like "treasure" and "cure" hold their possible paraphrasings, and keep a symbol "quest" which simply evaluates to the text "treasure" or the text "cure"; and then I could write ##quest## and get what I want.
from tracery.
from tracery.
Ah, it's good to hear that you're not sure about that! :) I'll be sure to play with the new features when they come.
I suppose with what I'm doing right now, I really could just put in words like TREASURE that get replaced with something more descriptive later. Or even things like VILLAGEOFCEEDODRIN where "ceedodrin" is a word Tracery makes up for me.
Either way, it's not a big deal. I decided to do NaNoGenMo just two days ago. Well-- I decided to do it back in December of 2015, but then I'd forgotten it existed until two days ago. My project is just an elaboration on the "nested story" idea from the Tracery tutorial.
from tracery.
Related Issues (20)
- Tracery2 has breaking changes with setting variables HOT 1
- capitalizeAll doesn't support Unicode properly
- Variable expansion breaks on commas in variable text. HOT 3
- Substitutions behave strangely inside bindings
- please add a license? HOT 3
- Feature request(?): change probabilities HOT 3
- Add uppercase and lowercase modifiers HOT 2
- how to build? HOT 1
- Modifiers not working / NPM Package probem HOT 2
- "a" modifier doesn't account for cases like "useful" HOT 4
- Links on your website died
- Capitalize the first alphabet character
- Java port HOT 1
- Actions overriding existing rules HOT 3
- firstS modifier adds space on single word entries
- .ing does not work
- Plural for specific cases? HOT 1
- Some idea on how to implement the parameters for modifiers
- Not sure where to put this, but Tracery's former 'home' to tutorials, CrysyalCodePalace.com is getting domain squatted
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tracery.