Hallo, Jared Kling hat gesagt: // Jared Kling wrote:
Thanks for responding. I've been playing with state-machine.pd and think I'm getting a grasp of it. At every line, the choice made will send the state machine to that line's choice. For example, consider the following example file, with line numbers in parentheses for easier reading... 3 4; (line 0) 2 3; (line 1) 0 1; (line 2) 0 0; (line 3) 3 1; (line 4)
So the initial choices would be 3 and 4. choosing 4 would send the state machine to line 4, where the choices would be 3 and 1, etc.
Yes, exactly.
So I'll need to go through and set every 'node' of the story to a line in the text file, with it's options sending it to the possible voting choices. Since every node has, at most, 2 choices that shouldn't be a problem.
My question would then be how can I go about labeling each line? I'm assuming the ; at the end of each line is a line delimiter, so I could put notes to myself after that line. It also seems like I could make each line set up as follows: (linenumber1) (choicename1) (linenumber2) (choicename2) so it would look like 12 Go_Upstairs 7 Stay_Downstairs ;
Then I could display them simply by replacing the [unpack 0 0] with [unpack 0 0 0 0] and the outlets would match the numbers and titles.
Basically yes. However you would need to use [unpack 0 s 0 s] because every second element is a symbol, not a number, and also the [pd nth] patch would need to be adapted: You need to select the first and third element of the choice-list, that is, send a 0 and a 2 to the right inlet.
However I guess it would be easier to keep it as it is, and use another textfile only for translating numbers to labels. This textfile would load a textfile only with labels, like:
Go_Upstairs Stay_Downstairs Fall_from_a_Tree ...
and you would use a simular construct as in [pd get-line...] to fetch the correct label from that textfile by line-number.
Btw: It occured to me, that the version I had posted was actually showing the past selection, not the one that a user can choose ATM. I attached a slight modification, so that the "possible state transitions" now show the possible *next* states to select.
I guess I have two final questions, both slightly tangential. First, how do you get a textfile to be read in by state-machine? You're using random numbers to generate a list of numbered pairs and I can't seem to figure out how to actually get it to read in from text, either from looking through the PD list archive and the reference material. I feel like this is probably one of those simple questions that I just haven't been able to find the answer to.
You use a "read filename.txt" message. Check out the help-patch for textfile. There is also the "read filename.txt cr" message possible which would treat a normal linebreak as a line ending, so you can omit the ";" that normally terminates lines in [textfile].
Second, is there a way to have the titles in each line contain spaces? That is, have the lines look like something like... 12 "Go Upstairs" 7 "Stay Downstairs"
Conversely, is there an easy way to strip out underscores?
There is no easy way, especially not if you store "mixed" lines like: "12 Go_Upstairs 7 Stay_Downstairs": Because then a space would mess up the numbe of items like this:
Index: 0 1 2 3 Line: 12 Go_Upstairs 7 Stay_Downstairs
Index: 0 1 2 3 4 5 Line: 12 Go Upstairs 7 Stay Downstairs
However if you use a second textfile for labels as I recommend above, you could use the abstraction [list-l2s] from the [list]-abs collection to convert the lists stored in the label-textfile (like "Go Downstairs") to symbols containing spaces easily.
I put an example for the conversion into attached file as well.
Frank Barknecht _ ______footils.org_ __goto10.org__