From 68dcf78da846a002670de9dcc3d59298cc10b565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20S=2E=20Martins?= Date: Tue, 8 Dec 2020 12:55:18 +0000 Subject: [PATCH] Update readme --- readme.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index 2542fa6..ac3036b 100644 --- a/readme.md +++ b/readme.md @@ -3,29 +3,30 @@ Crossword Generator This very simple Python script generates a *clueless* crossword puzzle. It harnesses the capabilities of Python and LaTeX to output the puzzle in a printable PDF. -Algorithm +Usage --- -I purposefully designed and implemented this little project without performing research on crossword generation techniques; I wanted to see if I could do it by myself. The very simple algorithm that is implemented here is as follows: - -1. The technique receives a list of words, in a .txt file (I tested using [these](http://www.gwicks.net/dictionaries.htm) lists). -2. A number (1000, by default) of words are chosen randomly from the list that is given, and these are the words that will be used hereafter. -3. The technique expands the list of words into a list of possibilities, where each possibility encodes a possible starting location for a word, as well as its direction. This essentially constitutes all possible words that can be placed into the grid. -4. Words that connect to words that are already on the grid are isolated into a connected_possibilities list. -5. A new word is taken from the list of possibilities/connected_possibilities and placed on the grid. This makes it so a number of possibilities are now invalid, and these are removed from the list. Steps 3 through 5 are repeated until the grid is as full as we want it to be, or the script times out. +All you have to do is run the script on a folder where a "words.txt" file with one word per line exists. I recommend using the aforementioned lists! Run `./crossword_generator -h` to see all available options. Output --- The script depends on LaTeX for producing the PDF output. However, the grid can be (and is, by default) printed to the screen. The PDF is print-ready, and includes both the puzzle (with the needed words) and the solution, making the output of each run completely self-contained. - Performance Considerations --- On my consumer-grade machine (i7-6700HQ) the algorithm can generate a 20x20 grid with 50% completion in some ~~45~~ ~~10~~ ~~4~~ seconds (with the new algorithm). I am currently looking into ways of improving this mark, and already have a ton of ideas, so stay tuned! -Usage +Algorithms --- -All you have to do is run the script on a folder where a "words.txt" file with one word per line exists. I recommend using the aforementioned lists! Run `./crossword_generator -h` to see all available options. +I purposefully designed and implemented this little project without performing research on crossword generation techniques; I wanted to see if I could do it by myself. I am essentially using this project as a testbench of sorts for coming up with search algorithms. + +The basic algorithm currently in use essentially + +1. Fills up the grid with random words in random positions, as long as they fit and do not collide; +2. Removes any isolated words, i.e. words that do not touch any others; +3. Repeats step 1. + +This can be done ad infinitum. However, the time it takes to find valid possibilities scales exponentially with how full the grid already is, so getting past 60% occupancy takes quite a while.