jonadsimon / wonder-words-generator

Generates WonderWords puzzles
Apache License 2.0
2 stars 0 forks source link

Condition overlappability measure on two words being placed at random #40

Closed jonadsimon closed 2 years ago

jonadsimon commented 2 years ago

Previous overlappability assumed two words were already intersecting and computed based on this + some scaling factor.

Better to assume the following model: 1) Board is empty 2) Word 1 is placed at random 3) Word 2 is placed at random

What is the probability (ignoring edge-effects) that the placements of word1 and word2 are compatible?

Winds up being a function of not just letter overlaps, but also word lengths, since two short words are less likely collide even if they share no letters.

Simplified formula:

p(no_overlap) + p(overlap) x p(letter_match | overlap)
~ (1 - w1_area x w2_area / board_area) + (w1_area x w2_area / board_area) x num_same_letter_pairs / (w1_len x w2_len)
~ (1 - w1_len x w2_len / n^2) + (w1_len x w2_len / n^2) x get_num_overlaps() / (w1_len x w2_len)
= 1 + (get_num_overlaps() - w1_len x w2_len) / n^2

Combine this with https://github.com/jonadsimon/wonder-words-generator/issues/39 for more effective word set optimization. In practice, likely equates to choosing from only among the shortest words because the 1st term dominates.

jonadsimon commented 2 years ago

Done in https://github.com/jonadsimon/wonder-words-generator/commit/6f3e8076679a68bc6e42e3cf87405d0d63749e14