Author Topic: Word Search Puzzle Builder  (Read 6479 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Word Search Puzzle Builder
« Reply #15 on: December 01, 2020, 04:00:00 pm »
Why did I end up 91st?

Cobalt is 91st because the list was sorted and then ordered by size, Cobalt being only 6 letters is less that most other element names in list, be glad you aren't TIN. ;)

Wait... are you here?

You know I considered a list of members for Word Search, that would be one way to get us all together before Christmas. ;)


Update: Wait... how did COBALT get to 91 here and something else in the other listing (in Off Topic Board)? Oh there is a shuffle in there too!

So from alpha ordered list there is shuffle(s) then an ordering of the list from most letters to least. Because it's easier to fit smaller words amongst the larger already placed words.
« Last Edit: December 01, 2020, 04:23:45 pm by bplus »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Word Search Puzzle Builder
« Reply #16 on: December 01, 2020, 11:48:34 pm »
Boobs: The primary reason to learn trigonometry.  Useful for other curves too.
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Word Search Puzzle Builder
« Reply #17 on: December 02, 2020, 01:29:00 am »
Hi @Richard Frost

(bplus is debriefing himself here with assumed audience of R Frost who might actually know what I am talking about for others this is probably boring as hell so feel free to skip. This little exercise just helps me clarify and make productive a sort of unproductive day.)

I went in complete circle today assuming my directions were overbalanced heading Up Down Left Right with hardly any diagonals. So I added direction counting and retooled the DX DY array and code to try and place words in at a diagonal first, try all 4 directions before the 4 standards NSEW. I ran into math difficulties so I made it random diagonals all the way and then NSEW random after. (Actually it turned out to be another A+ Blunder from changing the DX, DY arrays a line disappeared on me while copy/pasting and didn't find the sucker until reverting back to old DX, DY meanwhile that line was in there screwing up my East with another dang North. That sucker cost me allot of time and frustration from misdiagnosing the problem.) Result worse than just a standard sweep around clockwise and counter clockwise. (Wait, maybe I didn't get a proper test because... nope not going through that again, it should be a random direction from a random spot for word placement no cheating by stacking deck with diagonals first!

Also "cheating" IMHO is systematically running through word placements from cell 0 to cell last. What happens there is first word is placed diagonally from (0, 0) next at (0, 1) is same diagonal (when you have a system that favors diagonals) to that (0, 2) same diagonal to that... until end of row, THEN under (0, 0) at (1, 0) another set of same diagonals going across such that the end result is a very predictable puzzle at least in top left corner! :(  (so I am not just jealous of your Lucky Charms of completing the Elements puzzle in 700 tries (Very impressive even if it is a sort of cheat though hee, hee.), Mr Frost, it's not a great puzzle that gets built that way.)

Yucko results (from a faulty test I admit) I put everything back and counted diagonals from the way I had it, and not too bad maybe 40% diagonals to 60% NSEW. What's weird is a couple of directions will dominate and a couple will be really low, but they are different each time, so much depends on the placement and direction of the first few words!

To all,
Summary I have direction counts reported in the code now.

If you are just checking this out for first time you probably wont want to run a million trys on Elements, recommend 100-1000 trys in main loop with test 1 uncommented and Elements commented out near top of code. I will put all the test Word List Files in the OP (Original Post = first in this thread).
Code: QB64: [Select]
  1. _TITLE "Puzzle Builder for Word Lists" 'by B+ restarted 2020-11-28 from Rosetta Code Challenge
  2. ' Make a Word Search game & txt file from a list of words usu with some theme.
  3.  
  4. ' 2020-11-30 Puzzle Builder #2 w Finder 2020-11 Now complete the app with a word finder.
  5. ' Max word letters = 15
  6. ' Max cells/letters per side = 30
  7. ' Max words can find on word list is 120 (that can be shown on screen).
  8.  
  9. ' 2020-12-2 post update: Puzzle Builder #2.1 w Finder 2020-11.bas
  10. ' Added Direction counters.
  11.  
  12. DEFLNG A-Z
  13. CONST AscA = 97
  14. CONST ScreenWidth = 1000, ScreenHeight = 640
  15. DIM SHARED WordListFileBase$, GridSide, GridSideM1, GridSideP2M1
  16.  
  17.  
  18. '======================================= File Base name and Grid Size ================================================
  19.  
  20. '   Make your word list file with: Some base name for theme + " Word List.txt"
  21.  
  22. ' test file 2
  23. WordListFileBase$ = "Elements" ' add suffix to your file " Word List.txt"    <<<<<<<<<<<<<<<<<<<<<<<<<    Input
  24. GridSide = 30 ' <<<<<<<<<<<<<<<<<<<<<<<<<    Input later    30 the maximum grid size
  25.  
  26. ' test file 1
  27. 'WordListFileBase$ = "Christmas" 'add suffix to your file " Word List.txt"   <<<<<<<<<<<<<<<<<<<<<<<<<    Input
  28. 'GridSide = 15 ' <<<<<<<<<<<<<<<<<<<<<<<<<    Input later    30 the maximum grid size
  29.  
  30. '' test file 3
  31. 'WordListFileBase$ = "The_Four"
  32. 'GridSide = 5
  33.  
  34. '=====================================================================================================================
  35.  
  36. ' Calc once and for all!
  37. GridSideM1 = GridSide - 1
  38. GridSideP2M1 = GridSide * GridSide - 1
  39.  
  40. DIM SHARED LetterLimit
  41. IF GridSide > 15 THEN LetterLimit = 15 ELSE LetterLimit = GridSide
  42.  
  43. DIM SHARED GridLabel$ ' for labeling WS grid
  44. GridLabel$ = MID$("   0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z", 1, GridSide * 2 + 2)
  45.  
  46. 'LoadWords opens file of words and sets
  47. DIM SHARED NWords 'set in LoadWords, number of words
  48.  
  49. ' word file words (shuffled) to be fit into puzzle and index position, 24945 comes from a dictionary file
  50. DIM SHARED Words$(1 TO 24945), WordsIndex AS INTEGER 'the file has 24945 words but many are unsuitable
  51.  
  52. 'words placed in Letters grid, word itself (WordList$) x, y head (WordX, WordY) and direction (WordDirection), WordIndex is the index to all these
  53. DIM SHARED WordList$(1 TO 250), WordX(1 TO 250), WordY(1 TO 250), WordDirection(1 TO 250), WordIndex
  54. DIM SHARED BestWordList$(1 TO 250), BestWordX(1 TO 250), BestWordY(1 TO 250), BestWordDirection(1 TO 250)
  55.  
  56. ' letters grid and for saving best grid
  57. DIM SHARED Letters$(0 TO GridSideP2M1, 0 TO GridSideP2M1), Best$(0 TO GridSideP2M1, 0 TO GridSideP2M1), BestWordIndex
  58.  
  59. ' direction arrays
  60. DIM SHARED DX(0 TO 7), DY(0 TO 7), DString$(0 TO 7)
  61. DIM SHARED DirectionTotals(0 TO 7) 'used to randomly check directions to place words also used to store direction counts
  62.  
  63. 'new order to favor diagonals placements first if possible
  64. DX(0) = 1: DY(0) = 0: DString$(0) = "East"
  65. DX(1) = 1: DY(1) = 1: DString$(1) = "South East"
  66. DX(2) = 0: DY(2) = 1: DString$(2) = "South"
  67. DX(3) = -1: DY(3) = 1: DString$(3) = "South West"
  68. DX(4) = -1: DY(4) = 0: DString$(4) = "West"
  69. DX(5) = -1: DY(5) = -1: DString$(5) = "North West"
  70. DX(6) = 0: DY(6) = -1: DString$(6) = "North"
  71. DX(7) = 1: DY(7) = -1: DString$(7) = "North East"
  72.  
  73. ' signal successful fill of puzzle = either no spaces left or all words$() used
  74. DIM SHARED Filled ' signal we are full and done!
  75.  
  76. SCREEN _NEWIMAGE(ScreenWidth, ScreenHeight, 32)
  77. _DELAY .25
  78.  
  79. DIM try, c, r, y$, puzzleFiled
  80. try = 0
  81. LoadWords 'this sets NWORDS count to work with
  82. WHILE try < 1000000 'for long runs uncomment BEEP
  83.     Initialize
  84.     'ShowPuzzle
  85.     FOR WordsIndex = 1 TO NWords
  86.         PlaceWord
  87.         'ShowPuzzle
  88.         IF Filled THEN EXIT FOR
  89.     NEXT
  90.     IF WordIndex > BestWordIndex THEN 'copy Letters$ into Best$
  91.         FOR r = 0 TO GridSideM1
  92.             FOR c = 0 TO GridSideM1
  93.                 Best$(c, r) = Letters$(c, r)
  94.             NEXT
  95.         NEXT
  96.         BestWordIndex = WordIndex
  97.         ERASE BestWordList$, BestWordX, BestWordY, BestWordDirection
  98.         FOR r = 1 TO WordIndex
  99.             BestWordList$(r) = WordList$(r): BestWordX(r) = WordX(r): BestWordY(r) = WordY(r): BestWordDirection(r) = WordDirection(r)
  100.         NEXT
  101.         IF BestWordIndex = NWords THEN 'automatic file if all words positioned in puzzle
  102.             ShowBestPuzzle
  103.             LOCATE 33, 1: PRINT " Total Norths: "; TS$(DirectionTotals(4)); ", Total Souths: "; TS$(DirectionTotals(6));
  104.             LOCATE 34, 1: PRINT " Total Easts: "; TS$(DirectionTotals(7)); ", Total Wests: "; TS$(DirectionTotals(5));
  105.             LOCATE 35, 1: PRINT " Total NEs: "; TS$(DirectionTotals(3)); ", Total SEs: "; TS$(DirectionTotals(0));
  106.             LOCATE 36, 1: PRINT " Total NWs: "; TS$(DirectionTotals(2)); ", Total SWs: "; TS$(DirectionTotals(1));
  107.  
  108.             LOCATE 37, 1: PRINT " After "; TS$(try); " tries, this complete puzzle was made."
  109.             FilePuzzle
  110.             LOCATE 38, 1: PRINT " Puzzle Filed, next up is word search.";
  111.             LOCATE 40, 1: PRINT "      press any to continue.";
  112.             puzzleFiled = -1
  113.             BEEP
  114.             SLEEP
  115.             EXIT WHILE
  116.         END IF
  117.     END IF
  118.     try = try + 1
  119.     LOCATE 1, 1: PRINT "Try:"; try
  120. IF puzzleFiled = 0 THEN
  121.     ShowBestPuzzle
  122.     BEEP
  123.     LOCATE 33, 1: PRINT " Total Norths: "; TS$(DirectionTotals(4)); ", Total Souths: "; TS$(DirectionTotals(6));
  124.     LOCATE 34, 1: PRINT " Total Easts: "; TS$(DirectionTotals(7)); ", Total Wests: "; TS$(DirectionTotals(5));
  125.     LOCATE 35, 1: PRINT " Total NEs: "; TS$(DirectionTotals(3)); ", Total SEs: "; TS$(DirectionTotals(0));
  126.     LOCATE 36, 1: PRINT " Total NWs: "; TS$(DirectionTotals(2)); ", Total SWs: "; TS$(DirectionTotals(1));
  127.     LOCATE 37, 1: PRINT " After "; TS$(try); " tries, this was best puzzle."
  128.     LOCATE 38, 1: INPUT " Enter y for yes, to save the best to file."; y$
  129.     IF y$ = "y" THEN
  130.         FilePuzzle
  131.         LOCATE 39, 1: PRINT " Puzzle Filed.";
  132.     END IF
  133.     LOCATE 40, 1: PRINT " Next up is word search, press any to continue.";
  134.     LOCATE 1, 1
  135.     SLEEP
  136.  
  137. ' Now to find words in our best puzzle
  138. DIM bestPuz, mx, my, mb, wIndex, hx, hy, wd, i, sx, sy, navX$, navY$, navD$
  139.  
  140. ShowBestPuzzle 'get a snapshot
  141. bestPuz = _NEWIMAGE(ScreenWidth, ScreenHeight, 32)
  142. _PUTIMAGE , 0, bestPuz
  143. WHILE _KEYDOWN(27) = 0
  144.     _PUTIMAGE , bestPuz, 0
  145.     LOCATE 34, 1: PRINT "Move mouse over a word to find."
  146.     mb = _MOUSEBUTTON(1) 'wait for a word to be clicked
  147.     mx = INT(_MOUSEX / 8) + 1: my = INT(_MOUSEY / 16) + 1
  148.     IF mx >= 65 AND mx <= 84 THEN
  149.         wIndex = my
  150.     ELSEIF mx >= 85 AND mx <= 104 THEN
  151.         wIndex = my + 40
  152.     ELSEIF mx >= 105 AND mx <= 125 THEN
  153.         wIndex = my + 80
  154.     ELSE
  155.         wIndex = 0
  156.     END IF
  157.     IF wIndex > BestWordIndex THEN wIndex = 0
  158.     IF wIndex THEN
  159.         IF Found(BestWordList$(wIndex), hx, hy, wd) THEN 'high lite it black, yellow
  160.             ConvertCR2Screen hx, hy, sx, sy '    tranlate array location to screen location and navigate column, row
  161.             ConvertCR2Nav hx, hy, wd, navX$, navY$, navD$
  162.             LOCATE 36, 1: PRINT BestWordList$(wIndex); " found at ("; navX$; ", "; navY$; ") going "; navD$
  163.             COLOR &HFF0000BB, &HFFFFFF00
  164.             LOCATE sy, sx: PRINT Best$(hx, hy);
  165.             FOR i = 2 TO LEN(BestWordList$(wIndex))
  166.                 hx = hx + DX(wd): hy = hy + DY(wd)
  167.                 ConvertCR2Screen hx, hy, sx, sy
  168.                 LOCATE sy, sx: PRINT Best$(hx, hy);
  169.             NEXT
  170.             COLOR &HFFFFFFFF, &HFF000000
  171.         ELSE
  172.             LOCATE 34, 1: PRINT "Sorry, something is screwed up!"
  173.             LOCATE 36, 1: PRINT "       press any to continue..."
  174.         END IF
  175.     END IF
  176.     _LIMIT 60
  177.  
  178. SUB LoadWords
  179.     DIM wd$
  180.     OPEN WordListFileBase$ + " Word List.txt" FOR INPUT AS #1
  181.     WHILE EOF(1) = 0
  182.         INPUT #1, wd$
  183.         IF LEN(wd$) <= LetterLimit THEN
  184.             NWords = NWords + 1: Words$(NWords) = UCASE$(wd$) ' traditional ucase, works better with proper names
  185.         END IF
  186.     WEND
  187.     CLOSE #1
  188.  
  189. SUB Shuffle 'then order biggest first smallest last
  190.     DIM i, j
  191.     FOR i = NWords TO 2 STEP -1
  192.         SWAP Words$(i), Words$(INT(RND * i) + 1)
  193.     NEXT
  194.     i = 0
  195.     WHILE i < NWords - 1 'order the hard way but less than 100 words
  196.         i = i + 1
  197.         FOR j = i + 1 TO NWords
  198.             IF LEN(Words$(j)) > LEN(Words$(i)) THEN SWAP Words$(i), Words$(j)
  199.         NEXT
  200.     WEND
  201.  
  202. SUB Initialize ' zero out everything
  203.     DIM r, c
  204.  
  205.     FOR r = 0 TO GridSideM1
  206.         FOR c = 0 TO GridSideM1
  207.             Letters$(c, r) = " "
  208.         NEXT
  209.     NEXT
  210.     ERASE WordList$, WordX, WordY, WordDirection
  211.     WordIndex = 0
  212.     Shuffle 'reset word order
  213.  
  214. FUNCTION TS$ (n) ' this shorthand for TrimString and I want it shorthand!
  215.     TS$ = _TRIM$(STR$(n))
  216.  
  217. FUNCTION CountSpaces () 'used in PlaceWord
  218.     DIM x AS _BYTE, y AS _BYTE, count AS INTEGER
  219.     FOR y = 0 TO GridSide - 1
  220.         FOR x = 0 TO GridSide - 1
  221.             IF Letters$(x, y) = " " THEN count = count + 1
  222.         NEXT
  223.     NEXT
  224.     CountSpaces = count
  225.  
  226. FUNCTION Match (word AS STRING, template AS STRING) 'used in PlaceWord
  227.     DIM i AS INTEGER
  228.     Match = 0
  229.     IF LEN(word) <> LEN(template) THEN EXIT FUNCTION
  230.     FOR i = 1 TO LEN(template)
  231.         IF ASC(template, i) <> 32 AND (ASC(word, i) <> ASC(template, i)) THEN EXIT FUNCTION
  232.     NEXT
  233.     Match = -1
  234.  
  235. SUB PlaceWord
  236.     ' place the words randomly in the grid
  237.     ' start at random spot and work forward or all the squares
  238.     ' for each open square try the 8 directions for placing the word
  239.     '
  240.     ' Filled will now signal that all the words have been positioned
  241.     ' if place a word update Letters$, WordIndex, WordList$(WordIndex), WordX(WordIndex), WordY(WordIndex), WordDirection(WordIndex)
  242.  
  243.     DIM wd$, wLen, spot, testNum, rdir ' rdir go forward or back form spot
  244.     DIM x, y, d, dNum, rdd ' dNum counts number of directions we tried,  rdd sets direction to rotate
  245.     DIM template$, b1, b2 'for match against letters already in Letters$ grid
  246.     DIM i, j
  247.  
  248.     wd$ = Words$(WordsIndex) 'the right side is all shared
  249.     wLen = LEN(wd$) - 1 '     from the spot there are this many letters to check
  250.     testNum = 1 '             when this hits GridSide*GridSide we've tested all possible spots on grid
  251.     IF RND < .5 THEN rdir = -1 ELSE rdir = 1 ' go forward or back from spot for next test
  252.     spot = INT(RND * GridSide * GridSide)
  253.     WHILE testNum < GridSide * GridSide
  254.         y = INT(spot / GridSide)
  255.         x = spot MOD GridSide
  256.         IF Letters$(x, y) = MID$(wd$, 1, 1) OR Letters$(x, y) = " " THEN
  257.             d = INT(8 * RND)
  258.             IF RND < .5 THEN rdd = -1 ELSE rdd = 1
  259.             dNum = 1
  260.             WHILE dNum < 9
  261.                 'will wd$ fit? from  at x, y
  262.                 template$ = ""
  263.                 b1 = wLen * DX(d) + x >= 0 AND wLen * DX(d) + x <= GridSideM1 'wLen = len(wd$) - 1
  264.                 b2 = wLen * DY(d) + y >= 0 AND wLen * DY(d) + y <= GridSideM1
  265.                 IF b1 AND b2 THEN ' build the template of letters and spaces from Letter grid
  266.                     FOR i = 0 TO wLen
  267.                         template$ = template$ + Letters$(x + i * DX(d), y + i * DY(d))
  268.                     NEXT
  269.                     IF Match(wd$, template$) THEN 'the word will fit but does it fill anything?
  270.                         FOR j = 1 TO LEN(template$)
  271.                             IF ASC(template$, j) = 32 THEN 'yes a space to fill
  272.                                 FOR i = 0 TO wLen 'adding word to letter grid
  273.                                     Letters$(x + i * DX(d), y + i * DY(d)) = MID$(wd$, i + 1, 1)
  274.                                 NEXT
  275.                                 WordIndex = WordIndex + 1 'add word to loacting arrays
  276.                                 WordList$(WordIndex) = wd$: WordX(WordIndex) = x: WordY(WordIndex) = y: WordDirection(WordIndex) = d
  277.                                 IF CountSpaces = 0 OR WordIndex > NWords THEN Filled = -1
  278.                                 EXIT SUB 'get out now that word is loaded
  279.                             END IF
  280.                         NEXT
  281.                         'if still here keep looking
  282.                     END IF
  283.                 END IF
  284.                 d = (d + 8 + rdd) MOD 8 'set next direction to try
  285.                 dNum = dNum + 1 'count number of resets done when have 9 resets
  286.             WEND
  287.         END IF
  288.         spot = spot + rdir ' ok try next spot
  289.         IF spot >= GridSide * GridSide THEN spot = 0
  290.         IF spot < 0 THEN spot = GridSideP2M1
  291.         testNum = testNum + 1 'until tried every spot on grid
  292.     WEND
  293.  
  294. 'SUB ShowPuzzle 'this was needed to make sure finding the best puzzle was working correctly
  295. '    DIM i, x, y
  296.  
  297. '    CLS
  298. '    LOCATE 1, 1: PRINT GridLabel$
  299. '    FOR i = 3 TO 2 + GridSide
  300. '        LOCATE i, 1: PRINT MID$(GridLabel$, i * 2 - 2, 1);
  301. '    NEXT
  302. '    FOR y = 0 TO GridSide - 1
  303. '        FOR x = 0 TO GridSide - 1
  304. '            LOCATE y + 3, 2 * x + 4: PRINT Letters$(x, y)
  305. '        NEXT
  306. '    NEXT
  307. '    FOR i = 1 TO WordIndex
  308. '        IF i <= 40 THEN
  309. '            LOCATE i, 65: PRINT TS$(i); " "; WordList$(i);
  310. '        ELSEIF i <= 80 THEN
  311. '            LOCATE i - 40, 85: PRINT TS$(i); " "; WordList$(i);
  312. '        ELSEIF i <= 120 THEN
  313. '            LOCATE i - 80, 105: PRINT TS$(i); " "; WordList$(i);
  314. '        END IF
  315. '    NEXT
  316. '    LOCATE 35, 1: PRINT "Spaces left:"; CountSpaces
  317. '    LOCATE 36, 1: PRINT "Words placed:"; WordIndex
  318. '    LOCATE 37, 1: PRINT SPACE$(16)
  319. '    IF WordsIndex THEN LOCATE 37, 1: PRINT TS$(WordsIndex); " "; Words$(WordsIndex)
  320. 'END SUB
  321.  
  322. SUB FilePuzzle
  323.     DIM i, r, c, b$, x$, y$, d$
  324.  
  325.     OPEN WordListFileBase$ + " Word Search Puzzle.txt" FOR OUTPUT AS #1
  326.     PRINT #1, GridLabel$
  327.     PRINT #1, ""
  328.     FOR r = 0 TO GridSideM1
  329.         b$ = MID$(GridLabel$, r * 2 + 4, 1) + "  "
  330.         FOR c = 0 TO GridSideM1
  331.             b$ = b$ + Best$(c, r) + " "
  332.         NEXT
  333.         PRINT #1, b$
  334.     NEXT
  335.     PRINT #1, ""
  336.     PRINT #1, " Search Word Solutions:"
  337.     PRINT #1, ""
  338.     PRINT #1, " Words from: " + WordListFileBase$ + " Word List.txt found here:"
  339.     PRINT #1, ""
  340.     FOR i = 1 TO BestWordIndex
  341.         ConvertCR2Nav BestWordX(i), BestWordY(i), BestWordDirection(i), x$, y$, d$
  342.         PRINT #1, RIGHT$(SPACE$(3) + TS$(i), 3); ") "; RIGHT$(SPACE$(LetterLimit) + BestWordList$(i), LetterLimit);
  343.         PRINT #1, "("; x$; ", "; y$; ") >>>---> "; d$
  344.     NEXT
  345.     PRINT #1, " "
  346.     PRINT #1, "Total Norths: "; TS$(DirectionTotals(4)); ", Total Souths: "; TS$(DirectionTotals(6))
  347.     PRINT #1, "Total Easts: "; TS$(DirectionTotals(7)); ", Total Wests: "; TS$(DirectionTotals(5))
  348.     PRINT #1, "Total NEs: "; TS$(DirectionTotals(3)); ", Total SEs: "; TS$(DirectionTotals(0))
  349.     PRINT #1, "Total NWs: "; TS$(DirectionTotals(2)); ", Total SWs: "; TS$(DirectionTotals(1))
  350.     CLOSE #1
  351.  
  352. SUB FillBlanksInBest
  353.     DIM y, x, m
  354.     FOR y = 0 TO GridSide - 1
  355.         FOR x = 0 TO GridSide - 1
  356.             IF Best$(x, y) = " " THEN
  357.                 m = (m + 1) MOD 5
  358.                 Best$(x, y) = MID$("BPLUS", m + 1, 1)
  359.             END IF
  360.         NEXT
  361.     NEXT
  362.  
  363. SUB ShowBestPuzzle
  364.     DIM i, x, y
  365.  
  366.     FillBlanksInBest
  367.     CLS
  368.     LOCATE 1, 1: PRINT GridLabel$
  369.     FOR i = 3 TO 2 + GridSide
  370.         LOCATE i, 1: PRINT MID$(GridLabel$, i * 2 - 2, 1);
  371.     NEXT
  372.     FOR y = 0 TO GridSide - 1
  373.         FOR x = 0 TO GridSide - 1
  374.             LOCATE y + 3, 2 * x + 4: PRINT Best$(x, y)
  375.         NEXT
  376.     NEXT
  377.     ERASE DirectionTotals
  378.     FOR i = 1 TO BestWordIndex
  379.         IF i <= 40 THEN
  380.             LOCATE i, 65: PRINT TS$(i); " "; BestWordList$(i);
  381.         ELSEIF i <= 80 THEN
  382.             LOCATE i - 40, 85: PRINT TS$(i); " "; BestWordList$(i);
  383.         ELSEIF i <= 120 THEN
  384.             LOCATE i - 80, 105: PRINT TS$(i); " "; BestWordList$(i);
  385.         END IF
  386.         DirectionTotals(BestWordDirection(i)) = DirectionTotals(BestWordDirection(i)) + 1
  387.     NEXT
  388.  
  389. FUNCTION Found (word$, headX, headY, direction)
  390.     'First find a letter that matches the first letter in word$,
  391.     'then at that x, y try each of 8 directions to see if find a match.
  392.     'See if enough room to fit the find word before heading out to match letters.
  393.  
  394.     DIM first$, lenFind, x, y, d, b1, b2, xx, yy, b$, i
  395.  
  396.     first$ = MID$(word$, 1, 1): lenFind = LEN(word$) - 1
  397.     FOR y = 0 TO GridSideM1
  398.         FOR x = 0 TO GridSideM1
  399.             IF Best$(x, y) = first$ THEN
  400.                 FOR d = 0 TO 7 'will word fit in this direction? 2 booleans True condition
  401.                     b1 = lenFind * DX(d) + x >= 0 AND lenFind * DX(d) + x <= GridSideM1
  402.                     b2 = lenFind * DY(d) + y >= 0 AND lenFind * DY(d) + y <= GridSideM1
  403.                     IF b1 AND b2 THEN 'word fits,
  404.                         ' build word from Letters block to see if matches word to find
  405.                         b$ = first$: xx = x + DX(d): yy = y + DY(d)
  406.                         FOR i = 2 TO LEN(word$)
  407.                             b$ = b$ + Best$(xx, yy)
  408.                             xx = xx + DX(d): yy = yy + DY(d)
  409.                         NEXT
  410.                         xx = x: yy = y 'copy x, y for rebuilding word on screen
  411.                         IF b$ = word$ THEN 'found one show our result
  412.                             headX = x: headY = y: direction = d: Found = -1
  413.                             EXIT SUB
  414.                         END IF
  415.                     END IF
  416.                 NEXT
  417.             END IF
  418.         NEXT
  419.     NEXT
  420.  
  421. SUB ConvertCR2Screen (c, r, screenC, screenR)
  422.     screenC = 2 * c + 4: screenR = r + 3
  423.  
  424. SUB ConvertCR2Nav (c, r, d, navX$, navY$, navD$)
  425.     IF c > 9 THEN navX$ = CHR$(c - 9 + AscA - 1) ELSE navX$ = TS$(c)
  426.     IF r > 9 THEN navY$ = CHR$(r - 9 + AscA - 1) ELSE navY$ = TS$(r)
  427.     navD$ = DString$(d)
  428.  

 
Latest successful run with Elements.PNG


Here is: Elements Word Search Puzzle.txt,  file that is output that you can print out with solution below puzzle.
 

Along with cleaner presentation of solution, there is a Total Directions Report at bottom which is of interest to us taking this as a programming challenge more than a fancy puzzle end product (yet).

For screen shot above and Elements Word Search Puzzle.txt, Direction Totals:
Code: QB64: [Select]
  1. Total Norths: 38, Total Souths: 20
  2. Total Easts: 7, Total Wests: 2
  3. Total NEs: 6, Total SEs: 30
  4. Total NWs: 15, Total SWs: 0
  5.  
« Last Edit: December 02, 2020, 01:19:10 pm by bplus »

Marked as best answer by bplus on December 03, 2020, 07:51:18 pm

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Word Search Puzzle Builder
« Reply #18 on: December 04, 2020, 12:50:58 am »
Here is one kick butt Puzzle Builder! I've picked up on Richard Frost methods, Evaluate, what I call Scoring system. Tinkered with the scoring system and the order of directions and getting mighty fine results for the harder Elements Puzzle, puzzle usually built with all 118 Elements positioned mostly diagonally around the puzzle, in 10 tries or less, under a minute! Builder #2.1 was taking 100,000's of tries taking hours.

Code: QB64: [Select]
  1. _TITLE "Puzzle Builder for Word Lists" 'by B+ restarted 2020-11-28 from Rosetta Code Challenge
  2. ' Make a Word Search game & txt file from a list of words usu with some thene.
  3.  
  4. ' 2020-11-30 Puzzle Builder #2 w Finder 2020-11 Now complete the app with a word finder.
  5. ' Max word letters = 15
  6. ' Max cells/letters per side = 30
  7. ' Max words can find on word list is 120 (that can be shown on screen).
  8.  
  9. ' 2020-12-2 post update: Puzzle Builder #2.1 w Finder 2020-11.bas
  10. ' Added Direction counters.
  11.  
  12. ' 2020-12-2 Puzzle Builder #3 try Eval 2020-12.bas try Richard Frost approach find a best or better placement of words.
  13. ' This will take 30 * 30 * 8 steps for seaching every position and direction on grid.
  14. ' This needs overhaul with UDT's
  15.  
  16. DEFLNG A-Z
  17. CONST AscA = 97, WordLengthLimit = 15
  18. CONST ScreenWidth = 1000, ScreenHeight = 640
  19.  
  20. TYPE WordSearch 'having trouble tracking all Global shared variables for puzzle so here is that container
  21.     FileTheme AS STRING ' the theme name for + " Word List.txt" file we are doing
  22.     GridSide AS LONG ' number of letters per side of square grid
  23.     GridSideM1 AS LONG ' grid size - 1
  24.     GridSideP2M1 AS LONG ' grid size ^ 2 - 1
  25.     GridLabel AS STRING ' top and side labeling of letters grid
  26.     NWords AS LONG ' number of words
  27.     PlaceWordIndex AS LONG ' current index of word we are working
  28.     NPlacedWords AS LONG ' current number of placed words
  29.     NUnplaced AS LONG 'count the disasters
  30.     UnfilledCellF AS LONG 'there are still unfilled cells
  31.     BestNPlacedWords AS LONG ' best number of placed words here is goal  = nWords
  32.  
  33. TYPE WordType
  34.     S AS STRING ' the word
  35.     Len AS LONG ' it's length
  36.     Placed AS LONG
  37.     X AS LONG 'placements
  38.     Y AS LONG
  39.     D AS LONG 'direction 0 to 7
  40.  
  41. REDIM SHARED WS AS WordSearch
  42. REDIM SHARED Words(1 TO 250) AS WordType, ascWord(1 TO 250, WordLengthLimit), BestWords(1 TO 250) AS WordType
  43. REDIM SHARED AscLetters(0 TO WS.GridSideM1, 0 TO WS.GridSideM1), AscBestLetters(0 TO WS.GridSideM1, 0 TO WS.GridSideM1)
  44. REDIM SHARED DX(0 TO 7), DY(0 TO 7), DString$(0 TO 7)
  45. REDIM SHARED DirectionTotals(0 TO 7) 'used to randomly check directions to place words also used to store direction counts
  46.  
  47.  
  48. '======================================= Word Search File Base Name and Grid Size ================================================
  49.  
  50. '   Make your word list file with: Some base name for theme + " Word List.txt"
  51.  
  52. ' test file 2
  53. WS.FileTheme = "Elements" ' add suffix to your file " Word List.txt"    <<<<<<<<<<<<<<<<<<<<<<<<<    Input
  54. WS.GridSide = 30 ' <<<<<<<<<<<<<<<<<<<<<<<<<    Input later    30 the maximum grid size
  55.  
  56. ' test file 1
  57. 'WS.FileTheme = "Christmas" 'add suffix to your file " Word List.txt"   <<<<<<<<<<<<<<<<<<<<<<<<<    Input
  58. 'ws.GridSide = 15 ' <<<<<<<<<<<<<<<<<<<<<<<<<    Input later    30 the maximum grid size
  59.  
  60. '' test file 3
  61. 'WS.FileTheme = "The_Four"
  62. 'ws.GridSide = 5
  63.  
  64.  
  65. SCREEN _NEWIMAGE(ScreenWidth, ScreenHeight, 32)
  66. _DELAY .25
  67.  
  68. DIM try, c, r, cnt, y$, puzzleFiled
  69.  
  70. InitializeOnce
  71. WHILE try < 8 'for long runs uncomment BEEP
  72.     try = try + 1
  73.     RestartPuzzleFill
  74.     IF WS.PlaceWordIndex > 0 THEN ShowPuzzle
  75.     WHILE WS.PlaceWordIndex < WS.NWords
  76.         WS.PlaceWordIndex = WS.PlaceWordIndex + 1
  77.         WS.UnfilledCellF = 0 ' set F that all are filled
  78.         PlaceWord
  79.         IF try MOD 25 = 0 THEN ShowPuzzle
  80.         IF WS.UnfilledCellF = 0 OR (WS.NPlacedWords = WS.NWords) THEN EXIT WHILE
  81.     WEND
  82.     'BEEP
  83.     IF WS.NPlacedWords > WS.BestNPlacedWords THEN 'copy Letters$ into Best$
  84.         REDIM AscBestLetters(0 TO WS.GridSideM1, 0 TO WS.GridSideM1) '??????????????????
  85.         FOR r = 0 TO WS.GridSideM1
  86.             FOR c = 0 TO WS.GridSideM1
  87.                 AscBestLetters(c, r) = AscLetters(c, r)
  88.             NEXT
  89.         NEXT
  90.         WS.BestNPlacedWords = WS.NPlacedWords
  91.         cnt = 0
  92.         FOR r = 1 TO WS.NWords 'copy everything because we shuffle each time
  93.             IF Words(r).Placed THEN
  94.                 cnt = cnt + 1
  95.                 BestWords(cnt).S = Words(r).S: BestWords(cnt).Len = Words(r).Len
  96.                 BestWords(cnt).X = Words(r).X: BestWords(cnt).Y = Words(r).Y: BestWords(cnt).D = Words(r).D
  97.             END IF
  98.         NEXT
  99.         IF WS.BestNPlacedWords = WS.NWords THEN 'automatic file if all words positioned in puzzle
  100.             ShowBestPuzzle
  101.             PrintDirectionTotals 0
  102.             LOCATE 37, 1: PRINT " After "; TS$(try); " tries, this complete puzzle was made."
  103.             FilePuzzle
  104.             LOCATE 38, 1: PRINT " Puzzle Filed, next up is word search.";
  105.             LOCATE 40, 1: PRINT "      press any to continue.";
  106.             puzzleFiled = -1
  107.             'BEEP
  108.             SLEEP
  109.             EXIT WHILE
  110.         END IF
  111.     END IF
  112.     LOCATE 2, 1: PRINT "Try:"; try
  113.  
  114. IF puzzleFiled = 0 THEN
  115.     ShowBestPuzzle
  116.     'beep
  117.     PrintDirectionTotals 0
  118.     LOCATE 37, 1: PRINT " After "; TS$(try); " tries, this was best puzzle."
  119.     LOCATE 38, 1: INPUT " Enter y for yes, to save the best to file."; y$
  120.     IF y$ = "y" THEN
  121.         FilePuzzle
  122.         LOCATE 39, 1: PRINT " Puzzle Filed.";
  123.     END IF
  124.     LOCATE 40, 1: PRINT " Next up is word search, press any to continue.";
  125.     LOCATE 1, 1
  126.     SLEEP
  127.  
  128. ' Now to find words in our best puzzle
  129. DIM bestPuz, mx, my, mb, wIndex, hx, hy, wd, sx, sy, navX$, navY$, navD$, i
  130.  
  131. ShowBestPuzzle 'get a snapshot
  132. bestPuz = _NEWIMAGE(ScreenWidth, ScreenHeight, 32)
  133. _PUTIMAGE , 0, bestPuz
  134. WHILE _KEYDOWN(27) = 0
  135.     _PUTIMAGE , bestPuz, 0
  136.     LOCATE 34, 1: PRINT "Move mouse over a word to find."
  137.     mb = _MOUSEBUTTON(1) 'wait for a word to be clicked
  138.     mx = INT(_MOUSEX / 8) + 1: my = INT(_MOUSEY / 16) + 1
  139.     IF mx >= 65 AND mx <= 84 THEN
  140.         wIndex = my
  141.     ELSEIF mx >= 85 AND mx <= 104 THEN
  142.         wIndex = my + 40
  143.     ELSEIF mx >= 105 AND mx <= 125 THEN
  144.         wIndex = my + 80
  145.     ELSE
  146.         wIndex = 0
  147.     END IF
  148.     IF wIndex > WS.BestNPlacedWords THEN wIndex = 0
  149.     IF wIndex THEN
  150.         IF Found(BestWords(wIndex).S, hx, hy, wd) THEN 'high lite it black, yellow
  151.             ConvertCR2Screen hx, hy, sx, sy '    tranlate array location to screen location and navigate column, row
  152.             ConvertCR2Nav hx, hy, wd, navX$, navY$, navD$
  153.             LOCATE 36, 1: PRINT BestWords(wIndex).S; " found at ("; navX$; ", "; navY$; ") going "; navD$
  154.             COLOR &HFF0000BB, &HFFFFFF00
  155.             LOCATE sy, sx: PRINT CHR$(AscBestLetters(hx, hy));
  156.             FOR i = 2 TO BestWords(wIndex).Len
  157.                 hx = hx + DX(wd): hy = hy + DY(wd)
  158.                 ConvertCR2Screen hx, hy, sx, sy
  159.                 LOCATE sy, sx: PRINT CHR$(AscBestLetters(hx, hy));
  160.             NEXT
  161.             COLOR &HFFFFFFFF, &HFF000000
  162.         ELSE
  163.             LOCATE 34, 1: PRINT "Sorry, something is screwed up!"
  164.             LOCATE 36, 1: PRINT "       press any to continue..."
  165.         END IF
  166.     END IF
  167.     _LIMIT 60
  168.  
  169. SUB InitializeOnce ' everything that needs to be done once to get going
  170.     REDIM wd$, i
  171.  
  172.     'new order to favor diagonals placements first if possible
  173.     DX(0) = 1: DY(0) = 0: DString$(0) = "East"
  174.     DX(1) = 0: DY(1) = 1: DString$(1) = "South"
  175.     DX(2) = -1: DY(2) = 0: DString$(2) = "West"
  176.     DX(3) = 0: DY(3) = -1: DString$(3) = "North"
  177.     DX(4) = -1: DY(4) = 1: DString$(4) = "South West"
  178.     DX(5) = -1: DY(5) = -1: DString$(5) = "North West"
  179.     DX(6) = 1: DY(6) = -1: DString$(6) = "North East"
  180.     DX(7) = 1: DY(7) = 1: DString$(7) = "South East"
  181.  
  182.     WS.GridSideM1 = WS.GridSide - 1
  183.     WS.GridSideP2M1 = WS.GridSide * WS.GridSide - 1
  184.     WS.GridLabel = MID$("   0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z", 1, WS.GridSide * 2 + 2)
  185.     WS.NWords = 0
  186.     OPEN WS.FileTheme + " Word List.txt" FOR INPUT AS #1
  187.     WHILE EOF(1) = 0
  188.         INPUT #1, wd$
  189.         IF LEN(wd$) <= WordLengthLimit AND _TRIM$(wd$) <> "" THEN  '<<< EDIT OR to AND
  190.             WS.NWords = WS.NWords + 1
  191.             Words(WS.NWords).S = UCASE$(wd$)
  192.             Words(WS.NWords).Len = LEN(wd$)
  193.             FOR i = 1 TO LEN(wd$)
  194.                 ascWord(WS.NWords, i) = ASC(wd$, i)
  195.             NEXT
  196.         END IF
  197.     WEND
  198.     CLOSE #1
  199.     REDIM AscLetters(0 TO WS.GridSideM1, 0 TO WS.GridSideM1) 'now that we have the right size
  200.  
  201. SUB RestartPuzzleFill
  202.     DIM i, j, k, r, c
  203.  
  204.     WS.PlaceWordIndex = 0
  205.     WS.NUnplaced = 0 'count the disasters
  206.     WS.NPlacedWords = 0
  207.     FOR i = 1 TO WS.NWords 'clear positions of words
  208.         Words(i).Placed = 0: Words(i).X = -1: Words(i).Y = -1: Words(i).D = -1
  209.     NEXT
  210.     FOR r = 0 TO WS.GridSideM1 ' clear the letter numbers
  211.         FOR c = 0 TO WS.GridSideM1
  212.             AscLetters(c, r) = 32
  213.         NEXT
  214.     NEXT
  215.     FOR i = WS.NWords TO 2 STEP -1 'shuffle the list of Words to load
  216.         r = INT(RND * (i + 1)) + 1
  217.         SWAP Words(i), Words(r)
  218.         FOR j = 0 TO WordLengthLimit
  219.             SWAP ascWord(i, j), ascWord(r, j)
  220.         NEXT
  221.     NEXT
  222.     i = 0
  223.     WHILE i < WS.NWords - 1 'order word length
  224.         i = i + 1
  225.         FOR j = i + 1 TO WS.NWords
  226.             IF Words(j).Len > Words(i).Len THEN
  227.                 SWAP Words(i), Words(j)
  228.                 FOR k = 0 TO WordLengthLimit
  229.                     SWAP ascWord(i, k), ascWord(j, k)
  230.                 NEXT
  231.             END IF
  232.         NEXT
  233.     WEND
  234.  
  235. SUB ShowPuzzle 'this was needed to make sure finding the best puzzle was working correctly
  236.     DIM i, x, y, cnt, notPlaced$, cntUnplaced
  237.     notPlaced$ = ""
  238.     CLS
  239.     LOCATE 1, 1: PRINT WS.GridLabel$
  240.     FOR i = 3 TO 2 + WS.GridSide
  241.         LOCATE i, 1: PRINT MID$(WS.GridLabel$, i * 2 - 2, 1);
  242.     NEXT
  243.     FOR y = 0 TO WS.GridSide - 1
  244.         FOR x = 0 TO WS.GridSide - 1
  245.             LOCATE y + 3, 2 * x + 4: PRINT CHR$(AscLetters(x, y))
  246.         NEXT
  247.     NEXT
  248.     FOR i = 1 TO WS.PlaceWordIndex
  249.         IF Words(i).Placed THEN
  250.             cnt = cnt + 1
  251.             IF cnt <= 40 THEN
  252.                 LOCATE cnt, 65: PRINT TS$(cnt); " "; Words(i).S;
  253.             ELSEIF cnt <= 80 THEN
  254.                 LOCATE cnt - 40, 85: PRINT TS$(cnt); " "; Words(i).S;
  255.             ELSEIF i <= 120 THEN
  256.                 LOCATE cnt - 80, 105: PRINT TS$(cnt); " "; Words(i).S;
  257.             END IF
  258.         ELSE
  259.             cntUnplaced = cntUnplaced + 1
  260.             notPlaced$ = notPlaced$ + Words(i).S + " "
  261.         END IF
  262.     NEXT
  263.     LOCATE 36, 1: PRINT "Words placed:"; WS.NPlacedWords
  264.     LOCATE 37, 1: PRINT "Unplaced: "; WS.NUnplaced
  265.     LOCATE 38, 1: PRINT "Not placed words: "; notPlaced$; cntUnplaced
  266.     LOCATE 39, 1: PRINT "Last word: "; TS$(WS.PlaceWordIndex); " "; Words(WS.PlaceWordIndex).S;
  267.     'SLEEP
  268.  
  269. SUB PlaceWord
  270.     DIM bestScore, score, y, x, d, b1, b2, i
  271.  
  272.     bestScore = -1 ' going through entire array of AscLetters try every direction looking for best score = placement
  273.     FOR y = 0 TO WS.GridSideM1
  274.         FOR x = 0 TO WS.GridSideM1
  275.             IF ascWord(WS.PlaceWordIndex, 1) = AscLetters(x, y) OR AscLetters(x, y) = 32 THEN
  276.                 IF ascWord(WS.PlaceWordIndex, 1) = AscLetters(x, y) THEN score = 20
  277.                 IF AscLetters(x, y) = 32 THEN score = 0: WS.UnfilledCellF = -1 'no points for blanks but may proceed
  278.                 FOR d = 0 TO 7
  279.                     b1 = x + DX(d) * (Words(WS.PlaceWordIndex).Len - 1) >= 0 AND x + DX(d) * (Words(WS.PlaceWordIndex).Len - 1) <= WS.GridSideM1
  280.                     b2 = y + DY(d) * (Words(WS.PlaceWordIndex).Len - 1) >= 0 AND y + DY(d) * (Words(WS.PlaceWordIndex).Len - 1) <= WS.GridSideM1
  281.                     IF b1 AND b2 THEN 'we're in
  282.                         FOR i = 2 TO Words(WS.PlaceWordIndex).Len
  283.                             IF ascWord(WS.PlaceWordIndex, i) = AscLetters(x + DX(d) * (i - 1), y + DY(d) * (i - 1)) THEN
  284.                                 score = score + 10 + (d <= 3) * -5 + (d > 3) * -6
  285.                             ELSEIF AscLetters(x + DX(d) * (i - 1), y + DY(d) * (i - 1)) = 32 THEN
  286.                                 WS.UnfilledCellF = -1
  287.                                 score = score + (7 - d)
  288.                             ELSE
  289.                                 GOTO skip
  290.                             END IF
  291.                         NEXT
  292.                         IF score > bestScore THEN
  293.                             Words(WS.PlaceWordIndex).X = x: Words(WS.PlaceWordIndex).Y = y: Words(WS.PlaceWordIndex).D = d
  294.                             bestScore = score 'local
  295.                         END IF
  296.                     END IF
  297.                     skip:
  298.                 NEXT
  299.             END IF
  300.         NEXT
  301.     NEXT
  302.     'BEEP
  303.     IF bestScore > -1 THEN 'we have a good place for this word put it there and update stuff
  304.         FOR i = 1 TO Words(WS.PlaceWordIndex).Len
  305.             AscLetters(DX(Words(WS.PlaceWordIndex).D) * (i - 1) + Words(WS.PlaceWordIndex).X,_
  306.              DY(Words(WS.PlaceWordIndex).D) * (i - 1) + Words(WS.PlaceWordIndex).Y) = ascWord(WS.PlaceWordIndex, i)
  307.         NEXT
  308.         Words(WS.PlaceWordIndex).Placed = -1
  309.         WS.NPlacedWords = WS.NPlacedWords + 1
  310.     ELSE
  311.         Words(WS.PlaceWordIndex).Placed = 0
  312.         WS.NUnplaced = WS.NUnplaced + 1
  313.     END IF
  314.  
  315. FUNCTION TS$ (n) ' this shorthand for TrimString and I want it shorthand!
  316.     TS$ = _TRIM$(STR$(n))
  317.  
  318. SUB FilePuzzle
  319.     DIM i, r, c, b$, x$, y$, d$
  320.  
  321.     OPEN WS.FileTheme + " Word Search Puzzle.txt" FOR OUTPUT AS #1
  322.     PRINT #1, WS.GridLabel$
  323.     PRINT #1, ""
  324.     FOR r = 0 TO WS.GridSideM1
  325.         b$ = MID$(WS.GridLabel$, r * 2 + 4, 1) + "  "
  326.         FOR c = 0 TO WS.GridSideM1
  327.             b$ = b$ + CHR$(AscBestLetters(c, r)) + " "
  328.         NEXT
  329.         PRINT #1, b$
  330.     NEXT
  331.     PRINT #1, ""
  332.     PRINT #1, " Search Word Solutions:"
  333.     PRINT #1, ""
  334.     PRINT #1, " Words from: " + WS.FileTheme + " Word List.txt found here:"
  335.     PRINT #1, ""
  336.     FOR i = 1 TO WS.BestNPlacedWords
  337.         ConvertCR2Nav BestWords(i).X, BestWords(i).Y, BestWords(i).D, x$, y$, d$
  338.         PRINT #1, RIGHT$(SPACE$(3) + TS$(i), 3); ") "; RIGHT$(SPACE$(WordLengthLimit) + BestWords(i).S, WordLengthLimit);
  339.         PRINT #1, "("; x$; ", "; y$; ") >>>---> "; d$
  340.     NEXT
  341.     PRINT #1, " "
  342.     PrintDirectionTotals -1
  343.     CLOSE #1
  344.  
  345. SUB FillBlanksInBest
  346.     DIM y, x, m
  347.     FOR y = 0 TO WS.GridSide - 1
  348.         FOR x = 0 TO WS.GridSide - 1
  349.             IF AscBestLetters(x, y) = 32 THEN
  350.                 m = (m + 1) MOD 5
  351.                 AscBestLetters(x, y) = ASC("BPLUS", m + 1)
  352.             END IF
  353.         NEXT
  354.     NEXT
  355.  
  356. SUB PrintDirectionTotals (toFileTF)
  357.     DIM s$(1 TO 4), i
  358.     s$(1) = " Total Norths: " + TS$(DirectionTotals(3)) + ", Total Souths: " + TS$(DirectionTotals(1))
  359.     s$(2) = " Total Easts: " + TS$(DirectionTotals(0)) + ", Total Wests: " + TS$(DirectionTotals(2))
  360.     s$(3) = " Total NEs: " + TS$(DirectionTotals(6)) + ", Total SEs: " + TS$(DirectionTotals(7))
  361.     s$(4) = " Total NWs: " + TS$(DirectionTotals(5)) + ", Total SWs: " + TS$(DirectionTotals(4))
  362.     FOR i = 1 TO 4
  363.         IF toFileTF THEN PRINT #1, s$(i) ELSE LOCATE 32 + i, 1: PRINT s$(i);
  364.     NEXT
  365.  
  366. SUB ShowBestPuzzle
  367.     DIM i, x, y
  368.  
  369.     FillBlanksInBest
  370.     CLS
  371.     LOCATE 1, 1: PRINT WS.GridLabel$
  372.     FOR i = 3 TO 2 + WS.GridSide
  373.         LOCATE i, 1: PRINT MID$(WS.GridLabel$, i * 2 - 2, 1);
  374.     NEXT
  375.     FOR y = 0 TO WS.GridSide - 1
  376.         FOR x = 0 TO WS.GridSide - 1
  377.             LOCATE y + 3, 2 * x + 4: PRINT CHR$(AscBestLetters(x, y))
  378.         NEXT
  379.     NEXT
  380.     REDIM DirectionTotals(0 TO 7)
  381.     FOR i = 1 TO WS.BestNPlacedWords
  382.         IF i <= 40 THEN
  383.             LOCATE i, 65: PRINT TS$(i); " "; BestWords(i).S;
  384.         ELSEIF i <= 80 THEN
  385.             LOCATE i - 40, 85: PRINT TS$(i); " "; BestWords(i).S;
  386.         ELSEIF i <= 120 THEN
  387.             LOCATE i - 80, 105: PRINT TS$(i); " "; BestWords(i).S
  388.         END IF
  389.         DirectionTotals(BestWords(i).D) = DirectionTotals(BestWords(i).D) + 1
  390.     NEXT
  391.  
  392. FUNCTION Found (word$, headX, headY, direction)
  393.     'First find a letter that matches the first letter in word$,
  394.     'then at that x, y try each of 8 directions to see if find a match.
  395.     'See if enough room to fit the find word before heading out to match letters.
  396.  
  397.     DIM first$, lenFind, x, y, d, b1, b2, xx, yy, b$, i
  398.  
  399.     first$ = MID$(word$, 1, 1): lenFind = LEN(word$) - 1
  400.     FOR y = 0 TO WS.GridSideM1
  401.         FOR x = 0 TO WS.GridSideM1
  402.             IF AscBestLetters(x, y) = ASC(first$) THEN
  403.                 FOR d = 0 TO 7 'will word fit in this direction? 2 booleans True condition
  404.                     b1 = lenFind * DX(d) + x >= 0 AND lenFind * DX(d) + x <= WS.GridSideM1
  405.                     b2 = lenFind * DY(d) + y >= 0 AND lenFind * DY(d) + y <= WS.GridSideM1
  406.                     IF b1 AND b2 THEN 'word fits,
  407.                         ' build word from Letters block to see if matches word to find
  408.                         b$ = first$: xx = x + DX(d): yy = y + DY(d)
  409.                         FOR i = 2 TO LEN(word$)
  410.                             b$ = b$ + CHR$(AscBestLetters(xx, yy))
  411.                             xx = xx + DX(d): yy = yy + DY(d)
  412.                         NEXT
  413.                         xx = x: yy = y 'copy x, y for rebuilding word on screen
  414.                         IF b$ = word$ THEN 'found one show our result
  415.                             headX = x: headY = y: direction = d: Found = -1
  416.                             EXIT SUB
  417.                         END IF
  418.                     END IF
  419.                 NEXT
  420.             END IF
  421.         NEXT
  422.     NEXT
  423.  
  424. SUB ConvertCR2Screen (c, r, screenC, screenR)
  425.     screenC = 2 * c + 4: screenR = r + 3
  426.  
  427. SUB ConvertCR2Nav (c, r, d, navX$, navY$, navD$)
  428.     IF c > 9 THEN navX$ = CHR$(c - 9 + AscA - 1) ELSE navX$ = TS$(c)
  429.     IF r > 9 THEN navY$ = CHR$(r - 9 + AscA - 1) ELSE navY$ = TS$(r)
  430.     navD$ = DString$(d)
  431.  

 
Builder #3.PNG


Code: QB64: [Select]
  1.   0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t
  2.  
  3. 0  E P M U I C N A R F L L R A D I U M U S M H O L M I U M B M
  4. 1  P N L U U M G U L U E I S B P Y U R A N I U M U I R E C U G
  5. 2  N L I R I A U U Y I F M V U B I S M U T H S I M N O R I E B
  6. 3  B O I S L L O I N R U L T E N P L P M A U D U S S B T R R O
  7. 4  M U S L S R L S S I U I U U R P L U R U R I S B S E M O P H
  8. 5  M U I S I E T Y D E T C T S M M I G M O N L M U T A M S K R
  9. 6  D U I N E E N N R A C P R U N D O U F I S U B U N I T R P I
  10. 7  M L E R I N I N N E E L I E A N I R T N I I L I N U Y O S U
  11. 8  D U O N U B A I E N B N G N M S E C I T M M U E P P M M P M
  12. 9  L U I G U L U G S T E Y A U E H A O D U U M G M T U U B P L
  13. a  M U B V U M L S R L X V N N T T B A I I M O B O I I Y N C G
  14. b  M U I N E H R E E O P I G U O I T N N M R U N C M T E O A E
  15. c  U U I M I L L S T U T A R R U S E F U T E I I Y T G P D S S
  16. d  I M I N U U E B M A M P P M M G A I I L C N D R O P O U M E
  17. e  G U U H O I M D L U A B S R T H C N F K R O I R E L B U P N
  18. f  R L T I T L D P N L I M A N A N E E E E E U D R I N I U I A
  19. g  O A S H D E O I B E U D E R E S R L P N M Y E N O V T T P G
  20. h  B T D L U A M P R I M O N R I M E O I S H V I B O L U I E N
  21. i  A N L O S L L O L I R B W A I U C O O U L U R C C H H N E A
  22. j  E A P I N D I L R L C A U U C C M D D I M A S N A S I C B M
  23. k  S T A P T T A U A P L A M L U S I S S Y C O I S S D B P O M
  24. l  F B E S C H H E M P C A L C I U M U E L M Z S T O N M L U N
  25. m  L E M C T H I O L Y L U N I M S R U M U I I R I O U Y I E M
  26. n  E R U R H A R U R U N I B T F O R T I R U O U B I B N T U N
  27. o  R K I H P N T O M I H O L U H O L B C M N S E M D E S I O M
  28. p  O E D O B O E I M O U B M P P A R O P T L L S E H G R N U S
  29. q  V L I D N O N T N I B M S I B E N N I P I O N T N A E O L U
  30. r  I I B I S U R I I E U O U O T I B U I U P U U U M X L E U S
  31. s  U U U U M B U O P U H M C T U N M L M U M R T A R S E N I C
  32. t  M M R M U M S B N P M P Y M L U A S B P M L S I L I C O N U
  33.  
  34.  Search Word Solutions:
  35.  
  36.  Words from: Elements Word List.txt found here:
  37.  
  38.   1)   RUTHERFORDIUM(c, c) >>>---> North East
  39.  2)    PROTACTINIUM(c, d) >>>---> North East
  40.  3)    PRASEODYMIUM(c, d) >>>---> South East
  41.  4)    DARMSTADTIUM(b, g) >>>---> North East
  42.  5)     MENDELEVIUM(a, h) >>>---> North West
  43.  6)     COPERNICIUM(g, i) >>>---> North East
  44.  7)     LIVERMORIUM(a, 0) >>>---> South East
  45.  8)     ROENTGENIUM(a, i) >>>---> North East
  46.  9)     CALIFORNIUM(a, j) >>>---> South East
  47. 10)     EINSTEINIUM(a, 1) >>>---> South West
  48. 11)      TENNESSINE(9, 9) >>>---> North West
  49. 12)      MEITNERIUM(t, j) >>>---> North West
  50. 13)      LAWRENCIUM(a, k) >>>---> North East
  51. 14)      PHOSPHORUS(9, t) >>>---> North East
  52. 15)      PROMETHIUM(9, k) >>>---> North West
  53. 16)      GADOLINIUM(t, a) >>>---> South West
  54. 17)      ORGANESSON(9, b) >>>---> North West
  55. 18)      SEABORGIUM(0, k) >>>---> North
  56. 19)      TECHNETIUM(1, k) >>>---> South East
  57. 20)      MOLYBDENUM(t, j) >>>---> South West
  58. 21)      DYSPROSIUM(e, 0) >>>---> South East
  59. 22)       NEPTUNIUM(9, 8) >>>---> North East
  60. 23)       PALLADIUM(9, l) >>>---> North West
  61. 24)       LANTHANUM(a, k) >>>---> South East
  62. 25)       RUTHENIUM(l, s) >>>---> North East
  63. 26)       PLUTONIUM(9, l) >>>---> South West
  64. 27)       YTTERBIUM(c, t) >>>---> North East
  65. 28)       POTASSIUM(s, 8) >>>---> North West
  66. 29)       BERYLLIUM(a, 8) >>>---> North West
  67. 30)       MOSCOVIUM(k, l) >>>---> North East
  68. 31)       TELLURIUM(8, c) >>>---> North West
  69. 32)       MAGNESIUM(a, d) >>>---> North East
  70. 33)       FLEROVIUM(0, l) >>>---> South
  71. 34)       AMERICIUM(a, e) >>>---> South East
  72. 35)       MANGANESE(t, j) >>>---> North
  73. 36)       NEODYMIUM(j, g) >>>---> North East
  74. 37)       ZIRCONIUM(l, l) >>>---> South West
  75. 38)       BERKELIUM(1, l) >>>---> South
  76. 39)       GERMANIUM(t, 1) >>>---> South West
  77. 40)       STRONTIUM(o, k) >>>---> South West
  78. 41)        SELENIUM(7, c) >>>---> North East
  79. 42)        THALLIUM(4, m) >>>---> North East
  80. 43)        VANADIUM(b, a) >>>---> North East
  81. 44)        ALUMINUM(b, l) >>>---> South West
  82. 45)        ASTATINE(2, k) >>>---> South East
  83. 46)        FLUORINE(9, 0) >>>---> South West
  84. 47)        ACTINIUM(g, 9) >>>---> North East
  85. 48)        LUTETIUM(m, 7) >>>---> North East
  86. 49)        TUNGSTEN(m, s) >>>---> North East
  87. 50)        PLATINUM(7, f) >>>---> North East
  88. 51)        POLONIUM(7, h) >>>---> North West
  89. 52)        NOBELIUM(p, l) >>>---> South West
  90. 53)        SAMARIUM(m, t) >>>---> North East
  91. 54)        NITROGEN(h, e) >>>---> North East
  92. 55)        CHROMIUM(4, l) >>>---> South East
  93. 56)        TANTALUM(1, k) >>>---> North
  94. 57)        CHLORINE(r, j) >>>---> North West
  95. 58)        EUROPIUM(i, l) >>>---> South West
  96. 59)        FRANCIUM(9, 0) >>>---> West
  97. 60)        HYDROGEN(k, h) >>>---> North East
  98. 61)        ANTIMONY(g, t) >>>---> North West
  99. 62)        SCANDIUM(f, k) >>>---> North West
  100. 63)        TITANIUM(c, 3) >>>---> South West
  101. 64)        RUBIDIUM(2, t) >>>---> North
  102. 65)        NIHONIUM(c, m) >>>---> South West
  103. 66)         GALLIUM(6, 1) >>>---> South West
  104. 67)         LITHIUM(2, i) >>>---> South East
  105. 68)         SILICON(m, t) >>>---> East
  106. 69)         KRYPTON(s, 5) >>>---> South West
  107. 70)         NIOBIUM(j, 7) >>>---> South West
  108. 71)         CADMIUM(n, i) >>>---> South East
  109. 72)         BISMUTH(e, 2) >>>---> East
  110. 73)         MERCURY(e, 8) >>>---> North West
  111. 74)         IRIDIUM(9, i) >>>---> North West
  112. 75)         HASSIUM(p, i) >>>---> South West
  113. 76)         BROMINE(t, 2) >>>---> South West
  114. 77)         ARSENIC(n, s) >>>---> East
  115. 78)         RHODIUM(3, n) >>>---> South
  116. 79)         HAFNIUM(f, e) >>>---> North East
  117. 80)         HOLMIUM(l, 0) >>>---> East
  118. 81)         THORIUM(5, k) >>>---> South East
  119. 82)         DUBNIUM(0, 8) >>>---> South East
  120. 83)         URANIUM(g, 1) >>>---> East
  121. 84)         RHENIUM(6, b) >>>---> West
  122. 85)         CALCIUM(a, l) >>>---> East
  123. 86)         YTTRIUM(q, a) >>>---> South West
  124. 87)         TERBIUM(e, r) >>>---> North East
  125. 88)         BOHRIUM(t, 2) >>>---> South
  126. 89)         THULIUM(2, f) >>>---> South East
  127. 90)         FERMIUM(i, e) >>>---> South West
  128. 91)          SODIUM(j, h) >>>---> South West
  129. 92)          IODINE(n, m) >>>---> North East
  130. 93)          COPPER(s, a) >>>---> South West
  131. 94)          OSMIUM(l, q) >>>---> North East
  132. 95)          CERIUM(r, 1) >>>---> West
  133. 96)          NICKEL(m, b) >>>---> South West
  134. 97)          ERBIUM(f, q) >>>---> North East
  135. 98)          CURIUM(5, 0) >>>---> South West
  136. 99)          INDIUM(6, 7) >>>---> North East
  137. 100)          BARIUM(b, e) >>>---> South East
  138. 101)          RADIUM(c, 0) >>>---> East
  139. 102)          SILVER(i, k) >>>---> North East
  140. 103)          CESIUM(a, 6) >>>---> North West
  141. 104)          OXYGEN(9, b) >>>---> North East
  142. 105)          SULFUR(d, 5) >>>---> North West
  143. 106)          HELIUM(f, e) >>>---> South East
  144. 107)          COBALT(c, s) >>>---> North East
  145. 108)          CARBON(k, k) >>>---> North East
  146. 109)           XENON(p, r) >>>---> North East
  147. 110)           BORON(4, p) >>>---> South East
  148. 111)           ARGON(j, 3) >>>---> South West
  149. 112)           RADON(0, f) >>>---> South East
  150. 113)            NEON(r, s) >>>---> North
  151. 114)            IRON(r, 2) >>>---> West
  152. 115)            LEAD(8, m) >>>---> North West
  153. 116)            GOLD(3, 9) >>>---> North West
  154. 117)            ZINC(l, l) >>>---> North East
  155. 118)             TIN(r, g) >>>---> North East
  156.  
  157.  Total Norths: 5, Total Souths: 4
  158.  Total Easts: 7, Total Wests: 4
  159.  Total NEs: 36, Total SEs: 18
  160.  Total NWs: 19, Total SWs: 25
  161.  
  162.  
« Last Edit: December 04, 2020, 01:03:19 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Word Search Puzzle Builder
« Reply #19 on: December 04, 2020, 12:29:51 pm »
Update: I tried the Christmas List and there is still more things to do.

Making all Letters from list CAP's is easy enough but I want to at least get the word list up next to puzzle without the clues to use as a printout from your favorite Word Processor.

I am hoping to give this to great nieces and nephews to use with their vocabulary and spelling lists. Wait... they still do that don't they? ;-))

Yeah and the Elements list is for the budding scientists for 3-4 year old Sheldon like folks. :)

Maybe instead of BLUS as filler, we could use their own name!

Oh better put words in alpha order, Sheldon would like demand that.
« Last Edit: December 04, 2020, 12:53:02 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Word Search Puzzle Builder
« Reply #20 on: December 07, 2020, 10:40:13 pm »
Puzzle Builder #5 coming soon, meanwhile here is a 28x28 letter grid with all 118 Elements placed:
 
28x28 in 22564 tries.PNG


Here is where they're at:
Code: QB64: [Select]
  1.  
  2.  Search Word Solutions:
  3.             Words from: Elements Word List.txt
  4.  
  5.  First Letter Location and Direction:
  6.  
  7.    1)        ACTINIUM (7, g) >>>---> North West
  8.   2)        ALUMINUM (k, k) >>>---> South East
  9.   3)       AMERICIUM (h, 1) >>>---> West
  10.   4)        ANTIMONY (k, 7) >>>---> North East
  11.   5)           ARGON (a, f) >>>---> South West
  12.   6)         ARSENIC (7, k) >>>---> South West
  13.   7)        ASTATINE (o, 5) >>>---> South West
  14.   8)          BARIUM (0, r) >>>---> North
  15.   9)       BERKELIUM (4, k) >>>---> North East
  16.  10)       BERYLLIUM (n, r) >>>---> North West
  17.  11)         BISMUTH (0, l) >>>---> North
  18.  12)         BOHRIUM (f, l) >>>---> South East
  19.  13)           BORON (l, 2) >>>---> South West
  20.  14)         BROMINE (f, o) >>>---> North West
  21.  15)         CADMIUM (g, 2) >>>---> West
  22.  16)         CALCIUM (c, 0) >>>---> West
  23.  17)     CALIFORNIUM (n, 9) >>>---> South
  24.  18)          CARBON (b, a) >>>---> South East
  25.  19)          CERIUM (5, g) >>>---> North West
  26.  20)          CESIUM (5, r) >>>---> East
  27.  21)        CHLORINE (b, 8) >>>---> South East
  28.  22)        CHROMIUM (7, f) >>>---> North West
  29.  23)          COBALT (5, b) >>>---> South West
  30.  24)     COPERNICIUM (g, 2) >>>---> South East
  31.  25)          COPPER (d, 8) >>>---> South East
  32.  26)          CURIUM (5, r) >>>---> North West
  33.  27)    DARMSTADTIUM (g, 0) >>>---> South East
  34.  28)         DUBNIUM (b, h) >>>---> South West
  35.  29)      DYSPROSIUM (9, 9) >>>---> South West
  36.  30)     EINSTEINIUM (k, g) >>>---> North West
  37.  31)          ERBIUM (5, i) >>>---> West
  38.  32)        EUROPIUM (c, j) >>>---> North
  39.  33)         FERMIUM (e, l) >>>---> South East
  40.  34)       FLEROVIUM (8, 2) >>>---> South West
  41.  35)        FLUORINE (j, h) >>>---> South East
  42.  36)        FRANCIUM (3, j) >>>---> North East
  43.  37)      GADOLINIUM (b, f) >>>---> South
  44.  38)         GALLIUM (r, h) >>>---> North
  45.  39)       GERMANIUM (8, f) >>>---> North West
  46.  40)            GOLD (8, h) >>>---> East
  47.  41)         HAFNIUM (8, o) >>>---> North East
  48.  42)         HASSIUM (q, i) >>>---> North
  49.  43)          HELIUM (5, 2) >>>---> South West
  50.  44)         HOLMIUM (j, l) >>>---> South East
  51.  45)        HYDROGEN (3, q) >>>---> North East
  52.  46)          INDIUM (6, q) >>>---> North West
  53.  47)          IODINE (q, 5) >>>---> South West
  54.  48)         IRIDIUM (o, g) >>>---> North West
  55.  49)            IRON (g, 3) >>>---> South East
  56.  50)         KRYPTON (k, 1) >>>---> East
  57.  51)       LANTHANUM (b, j) >>>---> South West
  58.  52)      LAWRENCIUM (l, l) >>>---> North West
  59.  53)            LEAD (j, o) >>>---> South East
  60.  54)         LITHIUM (q, r) >>>---> North West
  61.  55)     LIVERMORIUM (k, e) >>>---> South West
  62.  56)        LUTETIUM (q, r) >>>---> North
  63.  57)       MAGNESIUM (g, 1) >>>---> South West
  64.  58)       MANGANESE (b, o) >>>---> North West
  65.  59)      MEITNERIUM (p, a) >>>---> North West
  66.  60)     MENDELEVIUM (f, 9) >>>---> South East
  67.  61)         MERCURY (9, 1) >>>---> West
  68.  62)      MOLYBDENUM (p, j) >>>---> North
  69.  63)       MOSCOVIUM (8, 9) >>>---> West
  70.  64)       NEODYMIUM (g, f) >>>---> South East
  71.  65)            NEON (a, 5) >>>---> West
  72.  66)       NEPTUNIUM (d, 4) >>>---> South East
  73.  67)          NICKEL (i, r) >>>---> West
  74.  68)        NIHONIUM (7, 6) >>>---> South West
  75.  69)         NIOBIUM (6, g) >>>---> North West
  76.  70)        NITROGEN (c, 4) >>>---> West
  77.  71)        NOBELIUM (6, h) >>>---> South East
  78.  72)      ORGANESSON (a, d) >>>---> South West
  79.  73)          OSMIUM (q, 6) >>>---> South
  80.  74)          OXYGEN (d, i) >>>---> South East
  81.  75)       PALLADIUM (0, 1) >>>---> South East
  82.  76)      PHOSPHORUS (g, j) >>>---> North West
  83.  77)        PLATINUM (j, 1) >>>---> South East
  84.  78)       PLUTONIUM (i, 4) >>>---> South West
  85.  79)        POLONIUM (7, c) >>>---> North West
  86.  80)       POTASSIUM (g, j) >>>---> South East
  87.  81)    PRASEODYMIUM (n, 1) >>>---> South West
  88.  82)      PROMETHIUM (g, j) >>>---> North East
  89.  83)    PROTACTINIUM (j, 1) >>>---> South West
  90.  84)          RADIUM (i, 0) >>>---> West
  91.  85)           RADON (m, 2) >>>---> East
  92.  86)         RHENIUM (d, l) >>>---> South East
  93.  87)         RHODIUM (0, 0) >>>---> East
  94.  88)     ROENTGENIUM (4, 2) >>>---> South East
  95.  89)        RUBIDIUM (o, j) >>>---> North
  96.  90)       RUTHENIUM (8, 8) >>>---> West
  97.  91)   RUTHERFORDIUM (0, 0) >>>---> South East
  98.  92)        SAMARIUM (7, p) >>>---> North West
  99.  93)        SCANDIUM (r, 3) >>>---> South West
  100.  94)      SEABORGIUM (5, l) >>>---> North East
  101.  95)        SELENIUM (7, a) >>>---> West
  102.  96)         SILICON (r, 3) >>>---> South
  103.  97)          SILVER (n, 0) >>>---> West
  104.  98)          SODIUM (h, q) >>>---> West
  105.  99)       STRONTIUM (4, j) >>>---> South East
  106. 100)          SULFUR (d, 3) >>>---> West
  107. 101)        TANTALUM (q, n) >>>---> North West
  108. 102)      TECHNETIUM (9, a) >>>---> North East
  109. 103)       TELLURIUM (j, e) >>>---> South East
  110. 104)      TENNESSINE (l, e) >>>---> North West
  111. 105)         TERBIUM (j, k) >>>---> North West
  112. 106)        THALLIUM (j, k) >>>---> South
  113. 107)         THORIUM (6, 8) >>>---> North West
  114. 108)         THULIUM (2, q) >>>---> East
  115. 109)             TIN (l, e) >>>---> South East
  116. 110)        TITANIUM (f, p) >>>---> West
  117. 111)        TUNGSTEN (f, 4) >>>---> South East
  118. 112)         URANIUM (7, 8) >>>---> North East
  119. 113)        VANADIUM (7, 2) >>>---> South West
  120. 114)           XENON (3, 2) >>>---> South East
  121. 115)       YTTERBIUM (k, j) >>>---> South West
  122. 116)         YTTRIUM (n, 3) >>>---> South West
  123. 117)            ZINC (o, 4) >>>---> North East
  124. 118)       ZIRCONIUM (i, k) >>>---> North West
  125.  
  126.  Total Norths: 8, Total Souths: 5
  127.  Total Easts: 6, Total Wests: 16
  128.  Total NWs: 23, Total SWs: 22
  129.  Total NEs: 28, Total SEs: 10
  130.  
  131.  Message in unused letters: bplus
  132.  
  133.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Word Search Puzzle Builder
« Reply #21 on: December 08, 2020, 02:05:12 pm »
Wait was that a fluke?

Lightning strike twice in a row! all 118 Elements in a 28x28 this time it tool only 7476 tries:
 
Lightning strikes twice 7476.PNG


Solution set:
Code: QB64: [Select]
  1.  
  2.  Search Word Solutions:
  3.             Words from: Elements Word List.txt
  4.  
  5.  First Letter Location and Direction:
  6.  
  7.    1)        ACTINIUM (e, p) >>>---> North East
  8.   2)        ALUMINUM (e, p) >>>---> East
  9.   3)       AMERICIUM (8, g) >>>---> West
  10.   4)        ANTIMONY (d, j) >>>---> South East
  11.   5)           ARGON (o, 5) >>>---> North
  12.   6)         ARSENIC (0, 8) >>>---> North
  13.   7)        ASTATINE (8, c) >>>---> North West
  14.   8)          BARIUM (4, b) >>>---> South East
  15.   9)       BERKELIUM (4, b) >>>---> North East
  16.  10)       BERYLLIUM (i, i) >>>---> South East
  17.  11)         BISMUTH (q, 8) >>>---> North
  18.  12)         BOHRIUM (q, 8) >>>---> West
  19.  13)           BORON (i, 0) >>>---> South West
  20.  14)         BROMINE (9, 8) >>>---> South East
  21.  15)         CADMIUM (7, p) >>>---> West
  22.  16)         CALCIUM (l, e) >>>---> South East
  23.  17)     CALIFORNIUM (h, b) >>>---> South East
  24.  18)          CARBON (6, 8) >>>---> South West
  25.  19)          CERIUM (8, d) >>>---> South East
  26.  20)          CESIUM (b, 2) >>>---> West
  27.  21)        CHLORINE (o, 7) >>>---> North West
  28.  22)        CHROMIUM (a, i) >>>---> South East
  29.  23)          COBALT (l, r) >>>---> West
  30.  24)     COPERNICIUM (a, i) >>>---> North East
  31.  25)          COPPER (p, 7) >>>---> South
  32.  26)          CURIUM (l, r) >>>---> East
  33.  27)    DARMSTADTIUM (l, 1) >>>---> South West
  34.  28)         DUBNIUM (6, 1) >>>---> West
  35.  29)      DYSPROSIUM (9, 9) >>>---> South West
  36.  30)     EINSTEINIUM (d, f) >>>---> South East
  37.  31)          ERBIUM (6, 4) >>>---> South West
  38.  32)        EUROPIUM (k, n) >>>---> North East
  39.  33)         FERMIUM (e, 0) >>>---> West
  40.  34)       FLEROVIUM (2, d) >>>---> South East
  41.  35)        FLUORINE (e, 9) >>>---> South East
  42.  36)        FRANCIUM (a, e) >>>---> South
  43.  37)      GADOLINIUM (9, b) >>>---> South West
  44.  38)         GALLIUM (j, a) >>>---> South
  45.  39)       GERMANIUM (b, q) >>>---> North West
  46.  40)            GOLD (b, 8) >>>---> South East
  47.  41)         HAFNIUM (6, 3) >>>---> South West
  48.  42)         HASSIUM (p, 6) >>>---> North West
  49.  43)          HELIUM (1, 4) >>>---> South
  50.  44)         HOLMIUM (6, o) >>>---> West
  51.  45)        HYDROGEN (k, h) >>>---> South West
  52.  46)          INDIUM (r, n) >>>---> North West
  53.  47)          IODINE (p, 5) >>>---> North
  54.  48)         IRIDIUM (q, a) >>>---> South
  55.  49)            IRON (0, c) >>>---> East
  56.  50)         KRYPTON (o, 9) >>>---> North West
  57.  51)       LANTHANUM (r, d) >>>---> North
  58.  52)      LAWRENCIUM (5, h) >>>---> South East
  59.  53)            LEAD (e, f) >>>---> North West
  60.  54)         LITHIUM (f, p) >>>---> North West
  61.  55)     LIVERMORIUM (r, d) >>>---> South West
  62.  56)        LUTETIUM (r, j) >>>---> North West
  63.  57)       MAGNESIUM (8, m) >>>---> West
  64.  58)       MANGANESE (e, q) >>>---> West
  65.  59)      MEITNERIUM (a, 3) >>>---> South
  66.  60)     MENDELEVIUM (a, c) >>>---> South West
  67.  61)         MERCURY (q, q) >>>---> West
  68.  62)      MOLYBDENUM (i, e) >>>---> South
  69.  63)       MOSCOVIUM (b, 0) >>>---> South West
  70.  64)       NEODYMIUM (3, h) >>>---> South East
  71.  65)            NEON (e, d) >>>---> South East
  72.  66)       NEPTUNIUM (9, q) >>>---> North East
  73.  67)          NICKEL (5, n) >>>---> West
  74.  68)        NIHONIUM (9, q) >>>---> North West
  75.  69)         NIOBIUM (l, 9) >>>---> North East
  76.  70)        NITROGEN (d, 7) >>>---> North East
  77.  71)        NOBELIUM (d, 7) >>>---> North West
  78.  72)      ORGANESSON (9, a) >>>---> North East
  79.  73)          OSMIUM (a, n) >>>---> North East
  80.  74)          OXYGEN (9, p) >>>---> North West
  81.  75)       PALLADIUM (j, 8) >>>---> South East
  82.  76)      PHOSPHORUS (n, 1) >>>---> South
  83.  77)        PLATINUM (c, g) >>>---> South East
  84.  78)       PLUTONIUM (h, f) >>>---> South East
  85.  79)        POLONIUM (7, h) >>>---> West
  86.  80)       POTASSIUM (j, 8) >>>---> North West
  87.  81)    PRASEODYMIUM (n, 1) >>>---> South West
  88.  82)      PROMETHIUM (f, 1) >>>---> South East
  89.  83)    PROTACTINIUM (7, 3) >>>---> South East
  90.  84)          RADIUM (o, f) >>>---> North
  91.  85)           RADON (l, o) >>>---> West
  92.  86)         RHENIUM (l, q) >>>---> North East
  93.  87)         RHODIUM (0, 0) >>>---> East
  94.  88)     ROENTGENIUM (4, 2) >>>---> South East
  95.  89)        RUBIDIUM (1, c) >>>---> North East
  96.  90)       RUTHENIUM (k, k) >>>---> North
  97.  91)   RUTHERFORDIUM (0, 0) >>>---> South East
  98.  92)        SAMARIUM (5, e) >>>---> South East
  99.  93)        SCANDIUM (p, g) >>>---> South West
  100.  94)      SEABORGIUM (d, 4) >>>---> South East
  101.  95)        SELENIUM (7, q) >>>---> West
  102.  96)         SILICON (r, f) >>>---> North West
  103.  97)          SILVER (r, m) >>>---> South
  104.  98)          SODIUM (0, f) >>>---> North
  105.  99)       STRONTIUM (g, i) >>>---> North
  106. 100)          SULFUR (r, i) >>>---> South West
  107. 101)        TANTALUM (8, b) >>>---> South East
  108. 102)      TECHNETIUM (9, r) >>>---> North West
  109. 103)       TELLURIUM (g, d) >>>---> South West
  110. 104)      TENNESSINE (d, 9) >>>---> North
  111. 105)         TERBIUM (9, r) >>>---> East
  112. 106)        THALLIUM (7, a) >>>---> South West
  113. 107)         THORIUM (h, 6) >>>---> North East
  114. 108)         THULIUM (6, a) >>>---> South West
  115. 109)             TIN (2, 2) >>>---> South West
  116. 110)        TITANIUM (2, 2) >>>---> South
  117. 111)        TUNGSTEN (9, r) >>>---> West
  118. 112)         URANIUM (8, i) >>>---> North East
  119. 113)        VANADIUM (p, f) >>>---> North West
  120. 114)           XENON (f, f) >>>---> North
  121. 115)       YTTERBIUM (8, a) >>>---> West
  122. 116)         YTTRIUM (k, q) >>>---> West
  123. 117)            ZINC (b, 6) >>>---> North West
  124. 118)       ZIRCONIUM (i, b) >>>---> North West
  125.  
  126.  Total Norths: 11, Total Souths: 10
  127.  Total Easts: 5, Total Wests: 18
  128.  Total NWs: 18, Total SWs: 18
  129.  Total NEs: 25, Total SEs: 13
  130.  
  131.  Message in unused letters: bplus
  132.  
  133.  

Start time 1:34 PM file time 1:41 PM = 7 minutes
« Last Edit: December 08, 2020, 02:06:18 pm by bplus »