Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"super advanced" Actions behave differently from static ones. #31

Open
dranorter opened this issue Nov 26, 2016 · 3 comments
Open

"super advanced" Actions behave differently from static ones. #31

dranorter opened this issue Nov 26, 2016 · 3 comments

Comments

@dranorter
Copy link

dranorter commented Nov 26, 2016

When I pass a 'correlated' bundle of information (such as "bracetypes" below) to a symbol, and then make recursive calls to that symbol, then the information gets overwritten unless I protect it with a second symbol ("brace2" below) which renames the relevant symbol. The more basic actions (like symbol:#letter# below) don't care.

{
     "letter": ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"],
     "bracetypes": ["[open:(][close:)]","[open:{][close:}]","[open:<][close:>]","[open:«][close:»]","[open:𛰫][close:𛰬]","[open:⌜][close:⌝]","[open:ᙅ][close:ᙂ]","[open:ᙦ][close:ᙣ]","[open:⁅][close:⁆]","[open:⌈][close:⌉]","[open:⌊][close:⌋]","[open:⟦][close:⟧]","[open:⦃][close:⦄]","[open:⦗][close:⦘]","[open:⫷][close:⫸]"],
     "brace": ["#open2##symbol# #[symbol:#letter#][#bracetypes#]brace2##symbol##close2# #[symbol:#letter#][#bracetypes#]brace2#", "","#open2##symbol# #[symbol:#letter#][#bracetypes#]brace2##symbol##close2# "],
     "brace2": ["#[open2:#open#][close2:#close#]brace#"],
     "origin": ["#[symbol:#letter#][#bracetypes#]brace2#"]
}

This gives output with matched braces and matched brace labels, such as the following:

«G ⫷B ⌊N ⁅M ⌈C C⌉ ⫷K ᙦA ᙅE ⌜B ᙦB Bᙣ B⌝ ᙦJ 𛰫K 𛰫H H𛰬 ⦃P ᙅD ⌈M ⌈B B⌉ M⌉ Dᙂ ⁅H H⁆ P⦄ K𛰬 Jᙣ Eᙂ ᙅL (J J) ⫷E E⫸ Lᙂ Aᙣ ⁅M ⌈M (K K) M⌉ M⁆ K⫸ M⁆ N⌋ B⫸ «H ᙅJ Jᙂ H» G»

Technically I don't need the symbol/action "open2" since I only use the open braces before recursive calls. But if I rename all occurrances of "close2" to "close", I get this sort of output:

<A «O O> «L <O ᙅH H> O{{close}} L{{close}} <P «K K> P{{close}} A{{close}}

It's as if nested calls "borrow" the value of their parent, and then the variable is no longer defined after the call! Yet, note that the capital letters match up perfectly; they have no such issue.

Of course, how I initially wrote the code was with no protective symbol "brace2", like this:

{
     "letter": ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"],
     "bracetypes": ["[open:(][close:)]","[open:{][close:}]","[open:<][close:>]","[open:«][close:»]","[open:𛰫][close:𛰬]","[open:⌜][close:⌝]","[open:ᙅ][close:ᙂ]","[open:ᙦ][close:ᙣ]","[open:⁅][close:⁆]","[open:⌈][close:⌉]","[open:⌊][close:⌋]","[open:⟦][close:⟧]","[open:⦃][close:⦄]","[open:⦗][close:⦘]","[open:⫷][close:⫸]"],
     "brace": ["#open##symbol# #[symbol:#letter#][#bracetypes#]brace##symbol##close# #[symbol:#letter#][#bracetypes#]brace#", "","#open##symbol# #[symbol:#letter#][#bracetypes#]brace##symbol##close# "],
     "origin": ["#[symbol:#letter#][#bracetypes#]brace#"]
}

which gives output like this:

{L ⟦F ᙦL ⁅C ⌈O ⁅N N⌉ (H H⌉ ⦃D D⌉ O{{close}} C{{close}} ⫷P P{{close}} L{{close}} 𛰫F ᙅF ⦗I Iᙂ F{{close}} F{{close}} F{{close}} L{{close}}

Again, the letters match up fine, yet the different braces and brackets don't.

Another interesting example is this piece of code:

{
     "origin": ["#[#xvals#]lambda#Hello!#x#","#[[x:seven, eight]]lambda#Hello!#x#", "#[x:one, two]lambda#Hello!#x#","#[x:#test#]lambda#Hello!#x#"],
     "test":["three","four"],
     "lambda":["#x#"],
     "x":["null"],
     "xvals":["[x:five, six]"]
}

The first and second rule for symbol "origin" clobbers the value of "x" so that after it's called, the variable no longer even exists. So, using the Tracery tutorial, I can get run histories like the following:

twoHello!null
threeHello!null
fourHello!null
threeHello!null
oneHello!null
oneHello!null
sixHello!{{x}}

Or like the following:

threeHello!null
threeHello!null
fiveHello!{{x}}
fiveHello!{{x}}
fourHello!{{x}}
twoHello!{{x}}
fourHello!{{x}}

Or:

twoHello!null
fourHello!null
eightHello!{{x}}
sixHello!{{x}}
threeHello!{{x}}
sixHello!{{x}}
oneHello!{{x}}

So "x" actually disappeared from the grammar! Now, I wouldn't mind being able to use actions to change the value of "x" over time. But having it just disappear isn't very useful, and I don't understand why the first two rules are different from the other two (using bare lambda or using lambda with "test").

@dranorter
Copy link
Author

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.

@galaxykate
Copy link
Owner

galaxykate commented Nov 27, 2016 via email

@dranorter
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants