Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

order of the input impacts the generated layout - why ? #9

Open
yonatanm opened this issue Jan 18, 2022 · 2 comments
Open

order of the input impacts the generated layout - why ? #9

yonatanm opened this issue Jan 18, 2022 · 2 comments

Comments

@yonatanm
Copy link

when I change the order of the objects {answer: 'xxx', clue: 'yyy} within the input array to the main generateLayout() function I get a different layout.

considering the fitness function - could be that a different order of the input will yield a better layout ?

@MichaelWehar
Copy link
Owner

MichaelWehar commented Jan 18, 2022

Thanks so much for your message!

I just tested it out. Yes, order does appear to matter!

Here are a few ideas I quickly came up with that might be a little bit helpful:

  • We could randomize the order of the words first if you want different outcomes each time
  • We could sort the words alphabetically first if you want the same outcome each time
  • Or, we could make a new fitness function that doesn't care about order

I think that having many different fitness functions that one could choose from would be really neat! Maybe this is something to be done in the future.

@yonatanm
Copy link
Author

yonatanm commented Jan 18, 2022

Thanks for your suggestion, here is my POV

Random ? I can do that on the app level
Sort? Yes, but I won't get the best possible crossword (as determined by your fitness function)
The third option is best. I can do it at the app level, and run all the permutations of order (n!). That way I can either use my owner fitness function or (preferred) have generateLayout() return its rank.

BTW, I'm using it in a side project. I run generateLayout() for all permutations I can imagine (explained below) and then I use my own fitness function to pick the best.

If I permute each SAPCE in an answer, I can decide where to delete it (and make it a long word without spaces) or to split it to a "sub" clue-answer pair. which gives me 2^[number-of-spaces] permutations (which is not ideal)

for example:
[{answer: "hello world", clue: "whatever"}] --->
p1:
[{answer: "helloworld", clue: "whatever", originalAnswer: "hello world"}]
p2:

 [{answer: "hello", clue: "whatever", originalAnswer: "hello world"}, 
  {answer: "world", clue: "whatever", originalAnswer: "hello world"}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants