Thanks for noticing the error!
This is why I need to do a much better job of describing the meme language.
The things like "@0.5,
" are probabilities, as you noticed, and they are evaluated left-to-right. Each one makes a random choice whose outcome is determined by the number, and as soon as one of them turns out to be "true", the rest of the list is ignored.
In the multiple-choice:
[RED@0.25, YELLOW@0.33, GREEN@0.5, BLUE]
What happens is:
- There is a 25% chance of choosing "RED",
- if it doesn't choose "RED", then there is a 33% chance of choosing "YELLOW",
- if it doesn't choose "RED" or "YELLOW", then there is a 50% chance of choosing "GREEN",
- if it doesn't choose any of those, then it chooses "BLUE".
This seems even more confusing if you consider this:
[template1, template2, template3]
which is almost exactly equivalent to:
[email@example.com, firstname.lastname@example.org, template3]
which is also almost exactly equivalent to:
[email@example.com, template2, template3]
(the difference being that 0.33 is not exactly 1/3). What these examples show is that if you don't use the numbers, it will choose between the un-numbered choices with equal probability.
But you cannot
do that with "literal text", i.e. text that is to be taken verbatim, not the name of a class or template. I wanted to allow multiple-choice between phrases that contain a comma:
[RED, YELLOW, AND BLUE@0.5, ORANGE, GREEN, AND PURPLE]
to choose either "RED, YELLOW, AND BLUE
" or "ORANGE, GREEN, AND PURPLE
" with equal probability — and this indeed works (though until just today there was a bug that made the commas turn to spaces, but I've just fixed that.)
If that's not bad enough, consider this:
[class1, class2, class3]
, and class3
are word lists. Here, the relative chance of picking each class is proportional to the number of words in that class. There's a reason for that! I wanted to be able to define lists of words of different but related types (like the different kinds of nouns), and have an easy way to choose a word from two or more such lists with equal probability per wordw
But if you want to choose from word-classes with explicit probabilities, you can also do that:
[firstname.lastname@example.org, email@example.com, class3]
and the odds of picking each type of word will be equal, regardless of how many words are in each class.
I know this doesn't make much sense, but it was the easiest way to make sure that there was no requirement that the numbers add up to 1.0 (or 100%). Then, once I translated all of @Link
's memes, I was stuck with it.
Notice that there's no reason to use a number that is 1.0 or greater (it would cause all subsequent items in the list to be ignored). That means I can, sometime in the future, decide to add another option for more logical probabilities. I can make a rule that states that if you use any numbers that are 1 or higher, then it will do some more logical or easy-to-understand calculation, like adding all the numbers together and using probabilities relative to the total.— mrob27 w
(But, there's another way to do that, which is to define a class that has other classes as members. But that's good, because I like there to be multiple ways of doing common tasks. Always err on the side of "Easier for the user, harder for the programmer"