QB64.org Forum

Active Forums => Programs => Topic started by: Qwerkey on August 23, 2019, 06:32:59 am

Title: Crossword Generator
Post by: Qwerkey on August 23, 2019, 06:32:59 am
This program creates a crossword grid and fills it with words.  The filling routine is quite simple and a number of tries are required before a completed grid is produced.

The program creates a standard 15x15 grid with the following rules:


The routine for checking contiguousness is fairly simple, but I believe that it will trap faulty grids: if you discover a noncontiguous grid, please let me know.  The routine for placing the blanks is also fairly simple and some grids do not have the standard crossword look (although all are acceptable).

The method for filling the grid with words is a simple blundering process: a random word of the correct length is tried: if all its squares are blank then this word is added: if some of its squares are already filled and the word does not fit, another word is tried.  If (as is likely) the grid cannot be successfully filled, then another grid is generated and the process begins again.

This blundering process takes some time to achieve a completely filled grid, and some efforts have been made to improve the chance of success.  The dictionary used was created from two readily available on the web: quite a large number of words are thus contained in the dictionary.  You may find (as I do) that a completed grid uses some seemingly improbable words, but somebody has judged them acceptable.  The dictionary also includes some phrases.

When selecting words from the dictionary, the program makes some judgement of how likely the word is to cross successfully.  A word which would produce a cross word ending with unlikely letters like Q or Z is avoided.  And a word which would be less likely to cross with another in the middle (letters like J and X) are also avoided.

So you will notice that a completed grid has words which favour the common letters like E in the crossing positions.  The Qs, J's, K's et cetera will only appear at the start of words or in non-crossing positions.

The longest words are placed first, as fitting the shorter words to existing ones has a better chance.

The program is multilingual, and you can choose which language to use.  The alternatives are:


Running the program

Extract the folder "Crossword Generator" from the .zip file and place the folder in your QB64 folder (be careful not to create an extra folder layer).  Open the "Multilingual Crossword Generator.bas" in the IDE (with "Output EXE to Source Folder" checked).  [The source folder contains another .bas file which is an older version (English only) of the program].

You will be presented with a Menu List to choose your language.  Although I have constructed this Options Menu to look like an InForm program (Windows native look), there is no mouse function available.  Press the Spacebar to change the language and Return to select your language.


The program will generate a grid and slowly fill with words.  When a word can no longer be found to fit, asterisks are filled in that place - it is unlikely that the grid will be successfully filled - and the program waits for keyboard input.  If you press the Spacebar, another grid will be generated and again words will be added.  If you press "f" when the filling stops, the program will quickly generate new grids and try to fill and the process will continue until a filled grid is obtained. Then the program will again wait for keyboard input.  Spacebar will create another grid, "f" will revert to the step-by-step method.  Esc will quit.

It takes a number of attempts to produce a completely filled grid, and on my Core i5 PC this takes some seconds (dependent upon the language, and if you've a slower machine you may have to wait for longer).

The process to fill the grid clearly has no intelligence to find words that will allow crossing words to be found in a small number of attempts.  An actual human compiler will be careful to think in advance.  Also, there may be some cases where the program, as is, is rejecting acceptable words.  So if you're sufficiently interested, you may like to create a rather cleverer program.

You may well suggest that a naive bystanding youngster would say of this program "But it doesn't do anything!".  This innocent would be correct: the emperor is entirely unclothed.

Multilingual Program now included (Updated 13/09/19)
Title: Re: Crossword Generator
Post by: Qwerkey on August 23, 2019, 08:12:40 am
Memo after a couple of hours of posting the above (for those who may have tried the program):  I just didn't give the program enough chances to find suitable words and the program was very sluggish.  Optimised program now included above.  Apologies for anyone who tried the program before this optimisation.
Title: Re: Crossword Generator
Post by: petoro on August 23, 2019, 10:43:25 am
I have checked it 20 or 25 times. Alas, it hasn't completed any crossword up to now.

Eagerly awaiting for the new version.
Title: Re: Crossword Generator
Post by: Petr on August 23, 2019, 10:58:37 am
That's the perfect idea! Nice graphic design. Thanks for sharing.
Title: Re: Crossword Generator
Post by: Qwerkey on August 23, 2019, 11:23:24 am
I have checked it 20 or 25 times. Alas, it hasn't completed any crossword up to now.

Eagerly awaiting for the new version.

Apologies again, Petoro.  Please try the new version and let me know if working satisfactorily (remember to press "f" when waiting for key input and let it cycle: it's still unlikely to fill the grid in step-by-step mode).
Title: Re: Crossword Generator
Post by: petoro on August 23, 2019, 11:42:26 am
Wow, the old version worked very well and fast by pressing "f" key while paused. It was already very fast at finding a good and complete example.

The new version is even better, faster and cleverer. Amazing. Thank u very much.
Title: Re: Crossword Generator
Post by: Qwerkey on August 23, 2019, 12:58:29 pm
Petoro, thank you for your kind words.  I would offer to make a version using the Spanish language, but the program may use only A-Z without accents (ASC values between 64 and 90).  If you could obtain a Spanish dictionary with accented letters converted to nearest unaccented equivalent eg 'a' instead of 'á', i instead of 'í', n instead of 'ñ', I would be able to do such a version.

Please forgive my ignorance, but are there Spanish language crosswords, and if so do they use accented characters?  In English, any accented letters are changed to the closest non-accented version.  Personally, I think that such words should not be allowed in English crosswords (the words should keep their accents and therefore would not cross properly).
Title: Re: Crossword Generator
Post by: petoro on August 23, 2019, 01:15:54 pm
Petoro, thank you for your kind words.  I would offer to make a version using the Spanish language, but the program may use only A-Z without accents (ASC values between 64 and 90).  If you could obtain a Spanish dictionary with accented letters converted to nearest unaccented equivalent eg 'a' instead of 'á', i instead of 'í', n instead of 'ñ', I would be able to do such a version.

Please forgive my ignorance, but are there Spanish language crosswords, and if so do they use accented characters?  In English, any accented letters are changed to the closest non-accented version.  Personally, I think that such words should not be allowed in English crosswords (the words should keep their accents and therefore would not cross properly).

Spanish crosswords don't use accented characters. Not sure if some use the "ñ". I will see later if I can find Spanish dictionaries in some text format.

Thank you
Title: Re: Crossword Generator
Post by: petoro on August 23, 2019, 03:28:40 pm
I have found a Spanish .txt dictionary sorted by letter here (dict_rae_txt):

https://www.giusseppe.net/blog/archivo/2015/10/29/diccionario-de-la-rae-en-modo-texto-plano/

Alas, it lacks conjugations (which are frequent in Spanish crosswords) and needs conversion in order to avoid accents and discard "ñ" words.

Also it needs to be ordered by number of characters in order to suit your needs...


Petoro
Title: Re: Crossword Generator
Post by: Qwerkey on August 23, 2019, 05:14:04 pm
Petoro thanks.  All I need is a dictionary in text format (which you have kindly given me a reference for).  I have routines to convert into the files needed for the program.  I may also be able to handle the accented character conversions (I may need the help of QB64's Expert in All Things, Steve McNeill).  Leave it with me, I'll see what can be done (I shall love doing it - you may have noticed that I love all things words-related).

Richard
Title: Re: Crossword Generator
Post by: petoro on August 23, 2019, 05:46:26 pm
Petoro thanks.  All I need is a dictionary in text format (which you have kindly given me a reference for).  I have routines to convert into the files needed for the program.  I may also be able to handle the accented character conversions (I may need the help of QB64's Expert in All Things, Steve McNeill).  Leave it with me, I'll see what can be done (I shall love doing it - you may have noticed that I love all things words-related).

Richard
It is very kind from your part to dedicate your attention to this. Please take your time.

Have a good weekend.
Title: Re: Crossword Generator
Post by: bplus on August 23, 2019, 07:31:48 pm
Nice work Qwerkey!

Are you working up a list of clues to match with words? I am eager to see what half these words mean! ;-))
Title: Re: Crossword Generator
Post by: Qwerkey on August 24, 2019, 04:52:26 am
Petoro, there will be hours of fun working with the spanish dictionary.

I shall convert the accented letters as:

á -> a
é -> e
í -> i
ó -> o
ú -> u
ü -> u
ñ -> n

Do you want me to do the ñ conversion, or remove all ñ words?
Title: Re: Crossword Generator
Post by: petoro on August 24, 2019, 05:34:58 am
I am sorry for not being of much help on this task of dictionary conversion. I am somewhat stuck at programming.

Perhaps one should avoid ñ's and ü's in order to not make a very complex/slow algorithm. Anyway, those letters are very rare. Also, it would not be very correct to change them. It would be really good to discard Ñ's and Ü's. Thank you very much,

Title: Re: Crossword Generator
Post by: SMcNeill on August 24, 2019, 05:51:48 am
Petoro, there will be hours of fun working with the spanish dictionary.

I shall convert the accented letters as:

á -> a
é -> e
í -> i
ó -> o
ú -> u
ü -> u
ñ -> n

Do you want me to do the ñ conversion, or remove all ñ words?

If you got your list of words from the website linked above, you can do the conversion quickly, like so:

Code: QB64: [Select]
  1. OPEN "a.txt" FOR BINARY AS #1
  2. OPEN "a-converted.txt" FOR OUTPUT AS #2
  3.     LINE INPUT #1, text$
  4.     ReplaceAll text$, CHR$(195) + CHR$(161), "a"
  5.     ReplaceAll text$, CHR$(195) + CHR$(173), "i"
  6.     ReplaceAll text$, CHR$(195) + CHR$(177), "n"
  7.     ReplaceAll text$, CHR$(195) + CHR$(179), "o"
  8.     ReplaceAll text$, CHR$(195) + CHR$(169), "e"
  9.     PRINT #2, text$
  10. PRINT "Converted!"
  11.  
  12.  
  13.  
  14. SUB ReplaceAll (text$, find$, replace$)
  15.     DO
  16.         l = INSTR(text$, find$)
  17.         IF l THEN
  18.             text$ = LEFT$(text$, l - 1) + replace$ + MID$(text$, l + LEN(find$) + 1)
  19.         END IF
  20.     LOOP UNTIL l = 0

Since the page is saved in unicode, most of the accented characters  are stored as 2-byte values, with the first byte being CHR$(195) basically representing the command for "draw from the extended set".  If I missed any, just determine which line the offending character falls out, print the ASCII values out to the screen, and then plug the 2-number combo into the replace routine above and let it do all the work for you.  No need for "hours of fun", when you can let the computer do it in moments.  ;)
Title: Re: Crossword Generator
Post by: Qwerkey on August 24, 2019, 06:00:06 am
¿ñ's y ü's son muy raras en español, señor?  The only two words in Spanish that any Brit knows have the ñ!!
Title: Re: Crossword Generator
Post by: Qwerkey on August 24, 2019, 06:12:55 am
Steve, thanks very much.  I knew that it would be something to do with Unicode and extended ASCII and maybe opening a file in BINARY instead of INPUT and I was just dabbling trying to get something going, but now I can work with what you've done.  If I get stuck (probable), I'll let you know.
Title: Re: Crossword Generator
Post by: Qwerkey on August 24, 2019, 07:33:19 am
Steve, I've had a go with your code which seems to be nearly working (or probably working correctly, but I misunderstand).  By the way I've changed from a,i,n,o,e to a,e,i,o,u as those are the only ones which Petoro wants.  I find the following in a converted file:

For orignal word abaceriá (grocery), the code gives abaceri and loses the a.

I cannot see why the code would give this error, or maybe I'm misunderstanding the original file.

Petoro, would you confirm that abaceriá is the correct Spanish and not abaceri?  Thank you.
Title: Re: Crossword Generator
Post by: petoro on August 24, 2019, 07:35:14 am
I think I have found a better Spanish dictionary here:

http://www.gwicks.net/dictionaries.htm

There is only one file. And YES, it contains conjugate verbs this time!

I think it is a little better formatted and tidy. Still it contains accented letters and ñ's, so it needs conversion. It is around 174 000 words long.

Thanks Steve, I'm giving a look at your program, not sure if it works the same way in Ubuntu and Windows...
Title: Re: Crossword Generator
Post by: petoro on August 24, 2019, 07:44:58 am
Steve, I've had a go with your code which seems to be nearly working (or probably working correctly, but I misunderstand).  By the way I've changed from a,i,n,o,e to a,e,i,o,u as those are the only ones which Petoro wants.  I find the following in a converted file:

For orignal word abaceriá (grocery), the code gives abaceri and loses the a.

I cannot see why the code would give this error, or maybe I'm misunderstanding the original file.

Petoro, would you confirm that abaceriá is the correct Spanish and not abaceri?  Thank you.

Yes, I am having certain errors in Ubuntu. For example it translates abacería to abaceraa insted of abaceria, the later is correct. Or abrogacian instead of abrogacion.


Title: Re: Crossword Generator
Post by: SMcNeill on August 24, 2019, 07:55:24 am
Yes, I am having certain errors in Ubuntu. For example it translates abacería to abaceraa insted of abaceria, the later is correct. Or abrogacian instead of abrogacion.

Did i get my letters backwards?  I was being lazy and just copy/pasted to enter the letters.  I may have entered them backwards...  I’ll doublecheck things in a bit; it’s almost breakfast time with the family here.
Title: Re: Crossword Generator
Post by: petoro on August 24, 2019, 08:17:01 am
¿ñ's y ü's son muy raras en español, señor?  The only two words in Spanish that any Brit knows have the ñ!!

Well ñ's are not so "raras", ü's are however.
Title: Re: Crossword Generator
Post by: petoro on August 24, 2019, 08:29:38 am
Did i get my letters backwards?  I was being lazy and just copy/pasted to enter the letters.  I may have entered them backwards...  I’ll doublecheck things in a bit; it’s almost breakfast time with the family here.
Tryng to convert the new dictionary espanol.txt to espanol-converted.txt with your program.

Thank you for the code!
Title: Re: Crossword Generator
Post by: Qwerkey on August 24, 2019, 09:15:48 am
I shall stop trying to deprive Petoro of some of the fun, as it looks as though Steve and Petoro can create the required text file.  So all I need is a text file with only a-z :- in alphabetical order with no duplicates would be preferable.
Title: Re: Crossword Generator
Post by: SMcNeill on August 24, 2019, 01:36:56 pm
I shall stop trying to deprive Petoro of some of the fun, as it looks as though Steve and Petoro can create the required text file.  So all I need is a text file with only a-z :- in alphabetical order with no duplicates would be preferable.

See if this little program won't do what you're wanting, with customization:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. DIM ExemptionCode(1000) AS STRING * 2, Exempt AS INTEGER
  3. DIM ReplaceWhat(1000) AS STRING, ReplaceWith(1000) AS STRING, Replacements AS INTEGER
  4. _TITLE "Replace UniCode Project"
  5. file$ = "a.txt"
  6. out$ = "a-modified.txt"
  7.  
  8. OPEN file$ FOR BINARY AS #1 'Read in the old file
  9. OPEN out$ FOR BINARY AS #2 'And, the out file
  10.  
  11. IF LOF(1) = 0 THEN
  12.     FOR i = 1 TO 100
  13.         CLS
  14.         PRINT "No file, dummy!  I'm going to go format your computer now!"
  15.         PRINT
  16.         PRINT "Formatting in process."
  17.         X = _EXIT 'just to be mean! CAUSE!!
  18.         FOR j = 1 TO i
  19.             PRINT ".";
  20.         NEXT
  21.         _DELAY .1
  22.     NEXT
  23.     PRINT
  24.     PRINT
  25.     PRINT "I've now erased all your stuff, because you made me angry!"
  26.     FOR j = 1 TO 10
  27.         PRINT "Ha! ";
  28.         _DELAY 1
  29.     NEXT
  30.     SYSTEM
  31.  
  32.     LINE INPUT #1, text$
  33.     count = count + 1
  34.     CLS
  35.     redo:
  36.     'make all replacements that we've already established
  37.  
  38.     PRINT "AUTOMATIC REPLACEMENTS:"
  39.     FOR i = 1 TO Replacements
  40.         PRINT i; ")", ReplaceWhat(i), "with", ReplaceWith(i)
  41.         ReplaceAll text$, ReplaceWhat(i), ReplaceWith(i)
  42.     NEXT
  43.     PRINT
  44.     PRINT "CURRENTLY PROCESSING:"
  45.  
  46.     PRINT count; ")"; TAB(10); text$
  47.     bad = 0
  48.     FOR i = 1 TO LEN(text$)
  49.         a = ASC(text$, i)
  50.         IF a < 32 OR a > 128 THEN 'it's an extended character
  51.             test$ = MID$(text$, i, 2) 'look for our list of exemptions
  52.             FOR j = 1 TO Exempt
  53.                 IF test$ = ExemptionCode(j) THEN
  54.                     i = i + 1 'move past the second character as well
  55.                     _CONTINUE 'and check from this point on
  56.                 END IF
  57.             NEXT
  58.             bad = a 'Otherwise, see what to do with it
  59.             EXIT FOR
  60.         END IF
  61.     NEXT
  62.     IF bad THEN
  63.         PRINT "Non-Standard characters found. ("; test$; ")"
  64.         PRINT "Do you want to replace all these characters with something different? ";
  65.         DO
  66.             _LIMIT 10
  67.             a$ = UCASE$(INPUT$(1))
  68.         LOOP UNTIL a$ = "Y" OR a$ = "N"
  69.         PRINT a$
  70.         PRINT
  71.         IF a$ = "N" THEN
  72.             Exempt = Exempt + 1
  73.             ExemptionCode(Exempt) = MID$(text$, bad, 2)
  74.             GOTO redo 'check the word for more issues
  75.         ELSE
  76.             DO
  77.                 PRINT "Replaceing " + test$ + " with ";
  78.                 r$ = INPUT$(1)
  79.                 PRINT r$
  80.                 PRINT
  81.                 PRINT "Is this correct? (Y/N)"
  82.                 DO
  83.                     _LIMIT 10
  84.                     a$ = UCASE$(INPUT$(1))
  85.                 LOOP UNTIL a$ = "Y" OR a$ = "N"
  86.                 PRINT a$
  87.             LOOP UNTIL a$ = "Y"
  88.             Replacements = Replacements + 1
  89.             ReplaceWhat(Replacements) = test$
  90.             ReplaceWith(Replacements) = r$
  91.             GOTO redo 'replace and check the word for more issues.
  92.         END IF
  93.         PRINT
  94.     END IF
  95.     text$ = text$ + CHR$(10) 'unix line ending.  No need to use the CHR$(13) + chr$(10) since even notepad is dropping them.
  96.     PUT #2, , text$
  97.  
  98.  
  99. SUB ReplaceAll (text$, find$, replace$)
  100.     DO
  101.         l = INSTR(text$, find$)
  102.         IF l THEN
  103.             text$ = LEFT$(text$, l - 1) + replace$ + MID$(text$, l + LEN(find$) + 1)
  104.         END IF
  105.     LOOP UNTIL l = 0

If it works as I'm hoping it should for you, I'll share it in the programs forum, and folks can find it and make use of it for future conversion needs.  ;)
Title: Re: Crossword Generator
Post by: Qwerkey on August 25, 2019, 05:30:07 am
Petoro, here is a Spanish version of the prgram.

Place all the files in .zip into the existing Crossword Generator folder (it will need the font file which is already there) and run the Crucigrama Generador bas.

It takes longer for the program to find a solution.  This is because there are so few letters which commonly end Spanish words.  It much be more challenging for Spaniards to create crosswords than for Britons.  But it still works.

Title: Re: Crossword Generator
Post by: petoro on August 25, 2019, 07:50:45 am
Thank you, it "invents" a new Spanish crucigrama from scratch in a very reasonable amount of time.

Besides, the words are not rather strange at all.
Title: Re: Crossword Generator
Post by: Qwerkey on August 25, 2019, 09:42:05 am
Version 2

14/9/19: Version 2 has been superseded by a general update to the program - see first part of post.
Title: Re: Crossword Generator
Post by: ExilePrisoner on August 26, 2019, 11:48:51 pm
I have tried both version of this program in a newly downloaded and  clean version 1.3 of QB64 and receive the following error in BOTH versions of the crossword program. I have disabled my virus checker to run the program uninterrupted (Avast).
Title: Re: Crossword Generator
Post by: Qwerkey on August 27, 2019, 04:33:14 am
I have tried both version of this program in a newly downloaded and  clean version 1.3 of QB64 and receive the following error in BOTH versions of the crossword program. I have disabled my virus checker to run the program uninterrupted (Avast).

Exile, I believe that your error occurs because the program cannot find the dictionary files.  Are you sure that you have the Run Option 'Output EXE to Source Folder' checked?
Title: Re: Crossword Generator
Post by: euklides on August 29, 2019, 06:04:18 am
Very, very nice program !

- here I join for you the #word.rnd files in french language (with 193445 words) in uppercase letters without accent... (if somebody interested)

- Question: how export then finished grid (for instance in a text file ?)
Title: Re: Crossword Generator
Post by: Qwerkey on August 29, 2019, 07:21:38 am
Very, very nice program !

- Question: how export then finished grid (for instance in a text file ?)

Euklides, thank you.  I attach a French version of the program, with your .rnd file renamed.  The program version is optimised for speed using the position statistics from these dictionary files.  Again, the files need to go in the original folder.

So, now we have English, Spanish and French versions.

In the French version, if you press "w" when a completed grid is dispayed, the grid will be output to a text file ("xword.txt").
Title: Re: Crossword Generator
Post by: Qwerkey on September 01, 2019, 04:53:42 am
Call for other language dictionaries


Just to finish off this topic, I thought that I'd make a multilingual version by selecting the language from a list.  So, we've already got English (which I'll change into and British English and US English), French and Spanish.

If you could provide a dictionary and rules for substituting any accented letters (or others) into a-z, I'll add them.  Italian?  Portuguese?  Dutch? German?  Any others?
Title: Re: Crossword Generator
Post by: euklides on September 02, 2019, 01:09:28 pm
I have a german dic, and could generate the german files.
Currently I have no time, because I go on vacation on the Mediterranean Sea.
We'll see later.

In german, you must change this (according to the rules of the crossword in Germany) :

ä -> ae
ö -> oe
ü -> ue
ß -> ss


Title: Re: Crossword Generator
Post by: Qwerkey on September 03, 2019, 09:08:40 am
I have now created a multilingual version of the program, which can be found in the first part of this thread - it replaces the original version.

The languages available are:

British English and US English.  I used dictionaries (found by Petoro) in Reply #18.  The separate dictionaries have fewer words than in the original version.  This has two effects: far less strange words are used; it takes somewhat longer to complete a grid.

German.  I used a dictionary in Reply #18.  Fortunately I used the conversion of letters with diacritical marks and the ß as given by euklides.

Spanish.  This is the dictionary from Reply #18, used in the Spanish version.

French.  This is a diction supplied by euklides as used in the French version.

Italian.  This is a dictionary from Reply #18, with all words containing letters outside a-z removed.

Dutch.  This is a dictionary from Reply #18, with all words containing letters outside a-z removed.

The time taken to complete a grid depends upon which language is used.  The average time taken (on my computer) is:

British English   5s (approx 50 attempts)
US English        5s (approx 50 attempts)
German          12s (approx 135 attempts)
Spanish            4s (approx 47 attempts)
French              2s (approx 37 attempts)
Italian             11s (approx 100 attempts)
Dutch               3s (approx 27 attempts)

The variations occur because of the different number of words in the various dictionaries and also because some languages have fewer letters which are common in word endings (and also to some extent in the word middle).

The searching activity is very intensive: over 200000 dictionary searches per second are made when the program is running.
Title: Re: Crossword Generator
Post by: SMcNeill on September 03, 2019, 09:29:44 am
Question:  Have you considered using this for numbers as well? 

Kakuro has a very crossword like feel to it, and is a very popular math puzzler which many folks enjoy.   It also might plug nicely into your crossword generator.  ;)

 https://en.m.wikipedia.org/wiki/Kakuro
Title: Re: Crossword Generator
Post by: Qwerkey on September 05, 2019, 05:27:29 am
Steve, I haven't (yet) sought to apply the methods to a numbers situation.  As you say, Kakuro has some analogous features.  As yet, the crossword generator is only for amusement - demonstrating how a computer finds words which can successfully cross á la crossword* - there is no actual output for the user to use.  I may come back to Kakuro in the future.  But bplus has been working on a Sudoku generator: his methods may be more pertinent.

* Wordsmiths (we know Steve to be our best) probably find the "franglais" term "á la" very incorrect.  Google implies that "crossword" in French is always in the plural, so I suppose the term should actually be "aux".  Aux, dear!
Title: Re: Crossword Generator
Post by: SMcNeill on September 05, 2019, 11:05:56 am
Steve, I haven't (yet) sought to apply the methods to a numbers situation.  As you say, Kakuro has some analogous features.  As yet, the crossword generator is only for amusement - demonstrating how a computer finds words which can successfully cross á la crossword* - there is no actual output for the user to use.  I may come back to Kakuro in the future.  But bplus has been working on a Sudoku generator: his methods may be more pertinent.

* Wordsmiths (we know Steve to be our best) probably find the "franglais" term "á la" very incorrect.  Google implies that "crossword" in French is always in the plural, so I suppose the term should actually be "aux".  Aux, dear!

If you ever want to give it a try, I assembled you a "number dictionary", which you can use to plug into the program and use to get the unique Kakuro values.  I've zipped it up for you, but I warn you -- it's quite a bit larger than most language lists.  (In fact, I was rather surprised at how many possible numbers are valid without duplicate values appearing -- 5,611,761 value number combinations!) 

Of course, feel free to ignore this as well; I was just mainly curious for myself at how large a "dictionary" would be required to adhere to the Kahuro ruleset, so I sat down and tossed together a quick little program to generate, test, and print values to a file for me.  Since I already had the file, I thought I'd share it, just in case you (or somebody else) might be interested in seeing it, so here it is.  ;)
Title: Re: Crossword Generator
Post by: Qwerkey on September 11, 2019, 12:24:44 pm
Euklides, I was checking the .rnd files for the Multi-language version, and I discovered that the French files which you supplied have a number of duplicates.  This hasn't caused a problem, but I've rewritten the French .rnd files which are now 87% - 97% of the original size.  The new files are in the .zip file in the first part of this post.
Title: Re: Crossword Generator
Post by: Qwerkey on September 14, 2019, 03:44:54 am
When creating a crossword puzzle, a compiler will ensure that no word is ever used twice.  However, the idiot coder here forgot to include such a check for this in the original version.  I have now updated the program in the first part of this post.  There is also now a 100% check for contiguousness.
Title: Re: Crossword Generator
Post by: euklides on September 23, 2019, 10:55:27 am
Euklides, I was checking the .rnd files for the Multi-language version, and I discovered that the French files which you supplied have a number of duplicates.  This hasn't caused a problem, but I've rewritten the French .rnd files which are now 87% - 97% of the original size.  The new files are in the .zip file in the first part of this post.

Yes, it is true.
In French for instance the words "livre" (book) and  "livré" (delivered) have not the same signification.
And if you transform "é" to "e", you have 2 same words.
I did not think about this when I created the files. This is the explanation.
Sorry ...
Title: Re: Crossword Generator
Post by: Qwerkey on October 08, 2019, 05:50:28 am
_MEM (partial) version

In order for the program to successfully create a completed grid, the processor is working flat-out doing comparisons of words (fitting tried words to existing ones and other string techniques).  Whilst the grid in the program is an array of integers (as opposed to string characters), the previous versions did not avoid some string processing.  Significant times are required to find a completed grid - see Reply #34.

_MEM processing is significantly faster than that of standard variable processing (and numeric processing is faster than that of string processing).  So I have created a version which has replaced string processing wherever possible and used _MEM object processing in places.  The program version here has reduced the times required, but not by a large factor.  The average times required to complete a grid are:

British English   4s
US English        4s
German            8s
Spanish            3s
French              1s
Italian              8s
Dutch               2s

The program is given here for completion, and you would not find a significant difference if you have already used that given in the start of this thread.  You would need to copy this .bas file into the existing folder created from the first part of this thread.  This program uses $CHECKING:OFF, and whilst it has been fully evaluated without fail, the use of this condition comes with some caution.  This version does not display the program trying to fill the created grids, and as such is rather less interesting because of that.

The desire would be to have a program which takes virtually zero time to create each completed grid, and perhaps one which works with entirely _MEM objects would do this.  This may be a future project.
Title: Re: Crossword Generator
Post by: euklides on October 09, 2019, 04:07:03 am
Well.
Is it now possible to get the full program and the dictionnaries and the necessary files to use it ???

The version "Multilingual Crossword Generator MEM.bas" dont work because "xword.cfg" is missing. And the dictionnaries too...
Title: Re: Crossword Generator
Post by: Qwerkey on October 09, 2019, 04:54:54 am
Euklides, to save duplication I referred to all the existing files which can be obtained from the very first part of this thread.  I have assumed that anybody interested enough to be reading this far down would already have downloaded the folder and files from there.  Just go to the very top of this thread.  Fortunately the $CHECKING:OFF statement comes after the OPEN "xword.cfg" statement, so no harm will come from trying to run this latest program without its associated files.