Concatenate word hintnames if we need more

This commit is contained in:
Oliver Blanthorn 2026-07-27 19:54:33 +02:00
parent d50ddc38f5
commit c8103dc0f6
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -753,10 +753,13 @@ function shuffleArray<T>(arr: T[]): T[] {
/** Random hintnames from a built-in word list.
* @hidden */
function* hintnames_words(n: number): IterableIterator<string> {
const shuffled = shuffleArray(RANDOM_HINT_WORDS)
for (let i = 0; i < n; i++) {
yield shuffled[i % shuffled.length]
}
const shuffled = shuffleArray(HINT_WORDS)
const wordCount = Math.max(1, Math.ceil(log(n, shuffled.length)))
yield* map(
islice(permutationsWithReplacement(shuffled, wordCount), n),
// Keep neighbouring hints from sharing the same first word.
words => words.reverse().join(""),
)
}
/** @hidden */