A couple years ago I made a codepen to generate arbitrarily long Genji-mon from a ruleset, and managed to write a rule that reduces the number of required special cases to one. However, these rules are very fragile, and "break" with lengths > 5 (edit: or maybe they don't! this deserves further exploration). Glad to see someone else discovering the structure behind this interesting system!
I tried setting `width` to 5 and found that your algorithm handles Yugiri correctly out-of-the-box. I tried commenting out various special case rules, such as lines 162-170, but it's the recursive algorithm itself that causes this. As you note on lines 204-214, your algorithm is not guaranteed to find the shortest solution; but the fact that it correctly handles Yugiri while mine does not suggests that it's closer to the intuitive, aesthetic judgement originally used to decide on the traditional layout.
That really surprised me (in a good way), because I had viewed Yugiri as an exception to an otherwise regular rule, while you showed it actually a natural consequence of a different rule! Of course, your algorithm also has special cases that need to be handled, so ultimately it may just be an aesthetic choice after all, but it proves that Yugiri may not be as irregular as I thought.
This codepen's presentation strongly presents the "phantom squares crossroads" optical illusion.