gorzek / loomwords

a dynamic text generation platform
MIT License
1 stars 1 forks source link

Add cooldowns to limit random choice repetition #24

Open gorzek opened 2 years ago

gorzek commented 2 years ago

When using a particular vocabulary, there's currently no mechanism to prevent the same values from appearing over and over through random chance. While this makes sense technically, it produces clumsy output.

So, a new feature will be added, --cooldown [integer], in which a value of '0' indicates no cooldown, and any positive integer represents the number of times any given vocab must be used before it is allowed to repeat a value already randomly chosen.

For example, suppose a vocab named any_letter is in use, e.g. <any_letter>.

Suppose it consists of:

a
b
c
d
e
f

Without a cooldown, if <any_letter> were used several times in a row, output could be:

a b a a b a

Suppose a cooldown of 5 is used instead. Then the output could be:

b d e f c a b

Notice that b does not repeat until 5 other choices have been made.

If a cooldown value exceeds the number of available choices, Loomwords will make a best effort to respect it but will always produce a value, even if it must repeat early.