Giter Site home page Giter Site logo

Comments (3)

dranorter avatar dranorter commented on August 28, 2024

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.

galaxykate avatar galaxykate commented on August 28, 2024

from tracery.

dranorter avatar dranorter commented on August 28, 2024

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)

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.