keiranking / Phil

A crossword maker.
http://www.keiranking.com/phil
Apache License 2.0
282 stars 85 forks source link

create random pattern generator #22

Open pwjablonski opened 5 years ago

pwjablonski commented 5 years ago

Hi Keiran!

I came across your project when trying to make my own crossword builder. I love puzzles and seems like a really fun project to contribute to rather than starting from square one. I wanted to take a shot at this feature to get my feet wet. Not too confident my approach is the cleanest or most efficient, and I am very open to your suggestions.

Current State Currently, when the user clicks on the generate pattern button the program selects a pattern from a predefined array of patterns.

Goal of this PR: Create a random pattern generator that programmatically creates a unique board each time the user clicks the generate pattern button.

Approach Given the conventional crossword rules, each word must be 3 letters long and the board should retain rotational symmetry. To do this, I Iooped through each square's location on the grid. I check the surrounding squares of each square looped through. If we are able to add the square based on the given rules, we randomly decide whether or not to add the square to the pattern.

Limitations

Excited to hear your thoughts and looking forward to contributing more in the future!