Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Help with creating a text frequency algorithm in twine

Hi, so I'm trying to build a version of an nth order frequency text scrambler in twine using Harlowe and its internal coding. I thought it would be possible without resorting to javascript, but am a bit stuck.

The idea is that you have a source text (contained in an array), from which the process finds every example of a string (for example "I am") it then selects at random one of the strings that follows one of the original strings (for example "a cat" or "a dog"). It then combines the two strings ("I am a cat") and continues with the process. ("I am a cat who likes" etc.)

The issue is that once I have created the array there doesn't seem to be a way to find the positions of a set of repeated strings in it. If I can find how to do this, I think this should be pretty doable.

Any ideas?

Comments

  • I believe you are going to have to result to using Javascript to do what you want because I am pretty sure that Harlowe's built-in array based macros don't have the functionality required and even if they did I think the solution would be very long winded because Harlowe does not natively support locating the index of an element and it's element removal / insertion methods are fiddly.
Sign In or Register to comment.