What's the terminology or whatever for creating a string from a tree of decisions?
-
Having a total shit-for-brains day. I want to create an arbitrary string. I start on a node that's the start of the sentence. I then make a decision from that node (based on other data) that can lead to different nodes with different decisions, until I hit a termination point.
Something like:
The
{animal_type... is Fox}
Fox{fox actions: run}
ran up{# hills in Fox Environment Instance}
five hills.But different nodes values could lead to different things
The
{animal_type if Whale}
fat fucking ocean-fish got{action: tasty level of Whale > 20}
eaten by the{antagonist of Whale Instance: stereotype}
Japanese dude.And you can in theory render that out to a whole tree of nodes and possibilities-- the path through which depends on the data fed into the start?
-
Sounds a lot like a Markov chain.
-
@masonwheeler said in What's the terminology or whatever for creating a string from a tree of decisions?:
Sounds a lot like a Markov chain.
I was thinking that, but that seems like it's more random than I was thinking. Going through a decision node would be based on a set piece of data, rather than a random number?
(I could be misunderstanding Markov chains, though)
-
If I'm remembering Godel, Escher, Bach correctly, you want a recursive transition network, although the recursive part might not apply in your examples.
Syntax diagram, maybe?
-
@Lorne-Kates said:
What's the terminology or whatever for creating a string from a tree of decisions?
You mean like a Decision Tree?
More seriously, if you want to make a tree that represents every possible string in your domain, I think you mean a Trie.
-
I could see this working somewhat easily in Python, where functions are variables, so you could just have a BST (or however many branches it might have) plus another variable in each node that's the function being checked, and then the function's result selects one of the branches. That, or each height level of the tree would use the same function based on the input and then some variable in the node (i.e. your first level gets animal type, your second level gets action, your third gets some subject relating to the action). As for terminology, I guess it is something like a trie?
-
I tried to create something like that, but it had to honor grammar, and tense had to be random.
I got as far as something that produced: "He has his sword"
It could also do, "She swung a sword." "She swung her sword." "He swung your sword."
But it was tons of code just to produce that.
The basic decision making was a tree, where one of the possible end nodes told the program to select an object.
That was the easy part. Then I had to attach adjectives and adverbs to the various objects in the nodes in the tree.... Then it had to remember the subject as it traversed the tree, because that impacted future words (like "her" in the above example).
The idea was that I'd have a program that could produce a random story. It would have these trees represent
chataction bots, and that they'd interact, at random.I got to the point where it was producing "He swung her."
-
@Zecc said in What's the terminology or whatever for creating a string from a tree of decisions?:
Trie
@Fox said in What's the terminology or whatever for creating a string from a tree of decisions?:
trie
Seems close, though I'm thinking of something where two alternate paths could meet on the other side of the decision to continue the construct.
Let's say it was game cards, and I was trying to turn a scoring mechanism into plain language.
One card says "+1 for each Hearts", while another says "+7 for each 8-10", and another "-3 if you have a 2 of Hearts", "-7 if you have a 2,3,4 straight"
So the logic would go something like.
Node: variable, value of score (+1, +7, -3)
Decision: "foreach" or "if" type of scoring will go to a node "if" or a node "For Each", which then converges
Decision: rank or suit?
...suit leads to a node that says "{suit name}"
...rank leads a a Decision, is this a single number, or a range
......single number leads to a node that says "{rank value}"
......range leads to a Decision, min/max range, or straight?
.........straight leads to a looping node that outputs "X...Y" (2,3,4)
.........min/max leads to a node that says "X to Y"
...all ranks leads back to a Decision, "Is the rank also combined with a suit?"
...yes leads to a Node that says "of", then goes to the Suit node above.I suppose this almost looks like a flowchart, but data-driven rather than code-driven?
-
@Lorne-Kates Monad.
-
@Lorne-Kates said in What's the terminology or whatever for creating a string from a tree of decisions?:
I suppose this almost looks like a flowchart, but data-driven rather than code-driven?
Are you describing a "railroad diagram", for example the ones seen at json.org?
-
@Captain said in What's the terminology or whatever for creating a string from a tree of decisions?:
@Lorne-Kates Monad.
I think that's it.
-
@Lorne-Kates Depending on how you want to "create" the string, you can use either a writer monad to sequence your decisions and build a string, or a reader monad to sequence your decisions and effect look-ups in a data structure. Or you can use a state monad if you need the power of a state machine.
-
If monads are the answer, you're probably asking the wrong question.
-
@Captain said in What's the terminology or whatever for creating a string from a tree of decisions?:
@Lorne-Kates Monad.
-
@Groaner I don't know what's worse, the art or the joke.
-
@RaceProUK said in What's the terminology or whatever for creating a string from a tree of decisions?:
@Groaner I don't know what's worse, the art or the joke.
With Quantum it can be both! (at least until you look closely which we definitely don't want to)
-
You might be looking for "rewrite rules", i.e. a normal grammar, possibly with attributes.