Results 1 to 25 of 25

Thread: [RESOLVED] Different Boggle Question

  1. #1

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Resolved [RESOLVED] Different Boggle Question

    So, I have 16 characters(letters) (randomly chosen from 16 cubes (dice, or die, if you prefer)) in a text array (1 through 16). The way the game BOGGLE works is that people have to make words from those 16 letters. The problem is, once the first letter (one of those 16 textboxes) is chosen (I'm using a textbox to check each letter as it is entered based upon what a player says is a word that can be made), the second letter must come from one of the ADJOINING textboxes (in that array), and then the third letter must come from one of the adjoining/surrounding textboxes from THAT textbox, and so forth.

    Puzzled on how to attack this. Note, that some of the letters in the 16 textboxes may be duplicated.

    So, as a player tells me the 'word', I type it into a textbox, checking each letter as I type (in KeyUp) to see if it is one of the available 'surrounding/adjacent' letters. At first glance, it appears like SEVERAL upon SEVERAL Case or IF statements.

    Any suggestions?

    here's an example of a random round....

    Name:  boggle.jpg
Views: 516
Size:  31.1 KB

    EDIT...words have to be at least 3 letters in length...

    So, in this example I can see
    EAR (INDEX 2, 3 AND 4)
    EARN (INDEX 2, 3, 4 AND 7)
    RUN (5, 6, 7)
    WINE (11, 12, 8, 2)
    WIN (11, 12 8)
    MAT (10,14, 15)
    MATE (10, 15, 15, 16)
    ETC, ETC
    Last edited by SamOscarBrown; Oct 19th, 2020 at 12:05 PM.
    Sam I am (as well as Confused at times).

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Different Boggle Question

    Ok, just brainstorming/thinking about this thing ... if it were me, I'd probably start with a 4x4 two-dimensional array of booleans. That array would represent letters selected/not-selected.

    And then, when a new one is clicked (possibly selected), I'd check to see if it was adjoining via an algorithm I wrote.

    You'll probably also need a "Clear" button to start the selection process over.

    But, here's another problem I see. Can you make words out of a T selection:

    Name:  T.png
Views: 406
Size:  96.7 KB

    If not, your "adjoining" algorithm will wind up getting somewhat complex, but not at all impossible.

    I'm tempted to throw something together, but I'll leave it at that for right now.

    EDIT: I think I answered my own questions from your examples in your edit. You can use T for selection.
    Last edited by Elroy; Oct 19th, 2020 at 12:22 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Different Boggle Question

    THX ELROY

    1-I hadn't thought of clicking on each textbox, but that seems like it is going to be easier than using a separate textbox and type in letter by letter whatever word the player says.

    2-A "T" COULD be possible, but not like you show there (MATS). If the letters were "S" (where the 'M' is), and "W" where that 'S' is, then "SWAT" would be possible as the W is adjacent to the S, and the S adjacent to the A, and the A adjacent to the T (or vice-versa).

    I would like to 'already' know all possibilities before the round started, but don't HAVE to...I guess, on-the-fly is just as fine.

    Gonna play around with it a bit, using your suggestion to click on the textboxes....

    Later....
    Sam I am (as well as Confused at times).

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Different Boggle Question

    Ok, here's an idea I threw together. I didn't test it though as I didn't put together all your textboxes.

    I assumed your textbox array was from 1 to 16 though. If it's 0 to 15, things will need to be adjusted.

    Code:
    
    Option Explicit
    
    Dim bbSel(1 To 4, 1 To 4) As Boolean
    
    Private Function Adjoining(Index As Integer) As Boolean
        ' Index is from 1 to 16.
        ' This also marks the bbSel array if TRUE is returned.
    
        Dim iRow As Integer
        Dim iCol As Integer
        Dim bbMarked As Boolean
    
        iRow = ((Index - 1) Mod 4) + 1
        iCol = (Index - 1) \ 4 + 1
    
        bbMarked = False
        On Error Resume Next
            bbMarked = bbMarked Or bbSel(iRow - 1, iCol)
            bbMarked = bbMarked Or bbSel(iRow, iCol - 1)
            bbMarked = bbMarked Or bbSel(iRow + 1, iCol)
            bbMarked = bbMarked Or bbSel(iRow, iCol + 1)
        On Error GoTo 0
    
        If bbMarked Then
            bbSel(iRow, iCol) = True
            Adjoining = True
        End If
    
    End Function
    
    
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Different Boggle Question

    since you are using texboxes, u could actually skip the matrix and instead do a "close by" approach.
    so, if u click on M. u do a loop 1-16 and check if any of the 16 is within range of "M"

    example: (lets say each box are around 100 pixel from each other)

    lets assume we start with "M", gets the center position: Mx= Left+Width/2 , My= Top+Height/2
    do a loop 1-16, for each box u get the center position, we call it Lx and Ly (for each)

    If Abs(Mx-Lx) < 150 and Abs(My-Ly) < 150 then
    this tells what boxes are allowed to be used.
    u can use a backcolor approach, like if we start with M, M gets a new background color, this color could also function as a "block", so:

    If Abs(Mx-Lx) < 150 and Abs(My-Ly) < 150 and TextBox(i).BackColor = vbWhite then

    if "unused" boxes have white background color, it means, its ok, otherwise it will not allow it.

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Different Boggle Question

    hmm... I think if it were me I would use buttons rather than text boxes and let the user click them in the order they wish to spell the word. You could remember the last button pushed to check if the next button is valid. I would of course use the button click event to trigger the test and also consider using a dictionary to determine if the word is valid if possible.

    If memory serves I don't think you can use the same die twice in any given word so you may need to keep a list of buttons pressed until the word is complete then clear it for the next word.

  7. #7
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Different Boggle Question

    I don't know the rules to this thing, but if you can make the same word twice, but using a different square combination, I'd probably make a Collection of either the bbSel(1 To 4, 1 To 4) arrays, or actually probably some kind of string that represented that array. If it were a string, you could use it as the Collection key for quick searching to see if that combination was already used.

    If duplicate words (with different square combinations) isn't allowed, a simple Collection using the words as keys (and probably values, just duplicated) would serve perfectly.

    ---------

    EDIT: If duplicate selections of the same word are allowed, here's a function that will turn your selection array into a String that could be used for a Collection key. That would allow a quick Collection search to make sure a selection combination hadn't been used before.

    Code:
    
    Private Function StringFromArray(TheArray() As Boolean) As String
        Dim iRow As Integer
        Dim iCol As Integer
        Dim Index As Integer
        '
        StringFromArray = "0000000000000000"
        For Index = 1 To 16
            iRow = ((Index - 1) Mod 4) + 1
            iCol = (Index - 1) \ 4 + 1
            If TheArray(iRow, iCol) Then Mid$(StringFromArray, Index, 1) = "1"
        Next
    End Function
    
    
    Last edited by Elroy; Oct 19th, 2020 at 12:55 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  8. #8
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Different Boggle Question

    Been about 30 years since I played this game but if memory serves. The rules are the letters must be from neighboring dice in any direction, same die can not be used twice in any given word, a short time limit is imposed to make you have to think quickly and at the end of the time the players compare their words and score only for words that no one else got so getting the saem word twice could be valid but pointless.

  9. #9

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Different Boggle Question

    wow---all good comments...gonna have to study a bit more...

    @Elroy...yeah, I decided on 1 to 16 instead of 0 to 15...(makes it easier for me to visualize)
    @DataMiser...rules state that you can't use the same die twice in a word. BUT, if there are two DIFFERENT dice with the same letter, of course you can use both in a word.
    Also, "I" am (will be) the user...as initially I will be playing this over Zoom, each player/team will have to TELL me (either with CHAT, show the paper they used to solve, or just speak) what each word is.
    @baka...hmmm...I would think instead of 'close by' with distances, it would be just as easy to look at adjacent textbox indices (6 is 'surrounded by' 1, 2, 3, 4, 7, 9, 10 and 11)....that is why I initially said that it looked like a lot of Case or If statements.

    Well, I "CAN" run this game by clicking on each textbox based upon the letters the player 'announce' to me. I can trap then, the word, determine its length, and then score it appropriately (3 and 4 letter words are worth 1 pt, 5-letter words are 2, 6-letter words are 3, 7-letter words are 5, and 8 or more-letter words are worth 11). This is the way I MAY have to do this (a manual approach) by clicking on each textbox (already got THAT part coded), but will look again at suggestions above so I can maybe simply type in a word in a textbox, and, in code, determine if it is a possibility or not...THAT would be the ideal solution in my mind.

    I do NOT have a dictionary to check against (never coded anything like that)...suggestions on this??? (say, I have a 'word' given to me (and it is a possibility in the matrix), how would I check some 'dictionary'?)

    Edit:
    @ DM, you are correct on your memory. Diagonal, left, right, top, bottom...all are candidates. Time limit is 3 minutes.
    Sam I am (as well as Confused at times).

  10. #10

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Different Boggle Question

    @Elroy, yes, the same word twice (using different dice) is allowed. I was not going to allow it (as I put all words into a listbox and check if they exist), but....I guess that is just another If statement or two to determine which dice were used.

    Argh...this is becoming more difficult as I get into it.
    Sam I am (as well as Confused at times).

  11. #11

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Different Boggle Question

    Argh (again)---you are right DataMiser:
    Only words that no other player created are scored.
    Complicates things a bit in code....(i was scoring each word that each player would have told me)....errrrrrr
    Sam I am (as well as Confused at times).

  12. #12
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Different Boggle Question

    Yeah you would need one list per player and then compare those to see which words actually get a point value.

  13. #13
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Different Boggle Question

    It may also be easier if you were to use 4 arrays, one for each row rather than just one.

  14. #14
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Different Boggle Question

    Quote Originally Posted by SamOscarBrown View Post
    Diagonal, left, right, top, bottom...all are candidates.
    Diagonal is a candidate? I didn't realize that. Here's a modified function to consider diagonal as adjacent:

    Code:
    
    Option Explicit
    
    Dim bbSel(1 To 4, 1 To 4) As Boolean
    
    Private Function Adjoining(Index As Integer) As Boolean
        ' Index is from 1 to 16.
        ' This also marks the bbSel array if TRUE is returned.
    
        Dim iRow As Integer
        Dim iCol As Integer
        Dim bbMarked As Boolean
    
        iRow = ((Index - 1) Mod 4) + 1
        iCol = (Index - 1) \ 4 + 1
    
        bbMarked = False
        On Error Resume Next
            bbMarked = bbMarked Or bbSel(iRow - 1, iCol)
            bbMarked = bbMarked Or bbSel(iRow, iCol - 1)
            bbMarked = bbMarked Or bbSel(iRow + 1, iCol)
            bbMarked = bbMarked Or bbSel(iRow, iCol + 1)
            bbMarked = bbMarked Or bbSel(iRow - 1, iCol - 1)
            bbMarked = bbMarked Or bbSel(iRow + 1, iCol - 1)
            bbMarked = bbMarked Or bbSel(iRow - 1, iCol + 1)
            bbMarked = bbMarked Or bbSel(iRow + 1, iCol + 1)
        On Error GoTo 0
    
        If bbMarked Then
            bbSel(iRow, iCol) = True
            Adjoining = True
        End If
    
    End Function
    
    

    EDIT: I'm still thinking about this ... you'll have to make certain compensations for the first letter chosen. It ... of course ... will not have any adjacent letters selected.
    Last edited by Elroy; Oct 19th, 2020 at 02:04 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  15. #15
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Different Boggle Question

    Quote Originally Posted by SamOscarBrown View Post
    Argh (again)---you are right DataMiser:
    Only words that no other player created are scored.
    Complicates things a bit in code....(i was scoring each word that each player would have told me)....errrrrrr
    If it were me, I'd just have a "master" collection, and also a collection for each player. The "master" collection could be used for each searching when a new word is submitted, and the individual collections could be used for final scoring.

    EDIT: Also, if you wanted to do this, don't forget that the Collection is just an object. Therefore, you can have Collections of Collections.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  16. #16
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Different Boggle Question

    the reason I think "close by" is a good way is that u can change the amount of boxes to anything, 4x4, 5x6, 8x8, well anything that can fit the screen and it will work.

    I would do:
    - programmatically create the boxes (so u only have textbox(0), and the best way to change size, positions without the need to do it manually)
    - use the ".tag" property to tell the "order" of the word, so EAR, would be E=1, A=2, R=3 and if tag has a number its "occupied"
    - a dictionary function together with the adjoining check to show what "boxes" can be used (I would use different colors to tell what can be used)

    for dictionary, I remember I found on the internet *.txt files, that are easy to parse. this when I was working on a word-puzzle game, many years ago.
    dont have the link, but I remember it took a bit to find it. if no .txt can be found, u need to understand the syntax of the dictionary that u get, as long theres no encyptions it should be easy enough to parse.

  17. #17

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Different Boggle Question

    @DM....I already have 4 sets of arrays (top row, 2nd row, third row, and bottom row), but because I wanted to check 'between rows', I then simply went through each row and created an identical set of textboxes, but this time 1 though 16 (instead of text1(1 through 4), text2 (1 through 4), etc...)

    Took a break and shot a a few games of pool to free up the mind from all this darn 'thinkin''--- :-)

    Sammi
    Sam I am (as well as Confused at times).

  18. #18
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: Different Boggle Question

    Sam, your initial Problem reminds me of Conways "Game of Life":
    It checks the (max) 8 possible squares around the "selected" square for a "state" (dead/alive)
    Maybe you can find an algorithm there: https://rosettacode.org/wiki/Conway%..._of_Life#BASIC
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  19. #19
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,121

    Re: Different Boggle Question

    Quote Originally Posted by Zvoni View Post
    Sam, your initial Problem reminds me of Conways "Game of Life":
    It checks the (max) 8 possible squares around the "selected" square for a "state" (dead/alive)
    Maybe you can find an algorithm there: https://rosettacode.org/wiki/Conway%..._of_Life#BASIC
    Nothing like Building a computer in Conway's game of life. . . This is mind-boggling!

    cheers,
    </wqw>

  20. #20
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: Different Boggle Question

    You know, looking at the link wqweto provided.......

    .... i don't think there is enough alcohol on the planet for me to suddenly understand a single word of that one day.......
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  21. #21

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Different Boggle Question

    Ow! Ow! Ow!.....my head hurts!

    Just looked at that Conway's Game of Life link....

    think I will just experiment a bit with info already provided above... :-)
    Sam I am (as well as Confused at times).

  22. #22

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Different Boggle Question

    Welll...not progressing very fast (I'm a slow learner, at best times).

    I guess to sum up the issue, what I would like to do is type a word (up to 9 characters in length), and determine if that word can be found in an array of 16 letters (which are represented currently by an array of Textboxes (1-16 indices)). And the rule is that once the first letter is found, the next letter must be in an adjacent (top, left, right, bottom and all diagonals), and each subsequent letters must also be 'surrounding' the previous letter's textbox index.

    Anyway, still playing around with it...
    Sam I am (as well as Confused at times).

  23. #23
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Different Boggle Question

    Wait, you want to do it backwards? Type in a word, and then see if the code can find it?

    Ok, what if the word has duplicate letters, like maybe "boot" (two "o"s). Does the Boggle board also have to have two "o"s?

    If you'll answer that question, I'll take a shot at it. Also, I assume all the adjacent rules still apply.

    Personally, to do this, I'd just do it "through brute force", finding if the letters are there, seeing if they're adjacent, if so, say so ... if not, keep going until we've covered all possibilities. With only 16 squares, "brute force" is going to be quite fast.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  24. #24

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Different Boggle Question

    @Elroy
    A board could have multiple letters (like 2 (or more) "o"s
    But, of course those two o's would have to be 'touching'.

    Don't spend much time on this Elroy (your farm needs tending, right?). I can still 'play' the game as I have it set up right now, it just doesn't check if words 'exist' within the matrix according to the 'touching rules'.....ah, wait a minute...a bulb brightened:
    If I put all possible 'touching' indices' captions into listboxes (one for each of the number of letters in the word (I said up to 9)), then I can probably pretty easily then compare each letter of the word with the appropriate listbox...hmmmm...may try this in a bit (gotta shoot my hour of pool today).

    Sam
    EDIT: After rereading your post, to clarify, a single letter appears only once, can only be used once....like if there was one s, you could not have 'mess', but, if there were two s's, and the s's are touching each other, then you can use both s's. Does that make sense?

    But again, don't spend much time...I am satisfied with what I have in my program now...will mark this resolved a bit later....
    Last edited by SamOscarBrown; Oct 20th, 2020 at 05:33 PM.
    Sam I am (as well as Confused at times).

  25. #25

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Different Boggle Question

    So...with my 'completed' Boggle game (without auto-search), the controlling screen looks like this (the audience screen is very similar but without some of the controlling controls:

    It lets players (starting with #1) read their list after spending 3 minutes attempting to create as many words with a least three letters. I (as the controller), will click on the letters in each word as the player reads them to me---this shows on both controlling and audience screens (green BG means I clicked on a letter). As I click, the word is spelled out in a textbox (also shown on the audience form). I then click on ADD if no other player says they have that word on their list (this essentially adds that word to the player reading his/her list). If someone else says they have that word, I click on Don't Add, and the list is put into a common list for all to see. (both those buttons check to see if a word already exists in the common list as well as all the players' list. What I end up with is players' lists with only the words they found, and no one else did. I would then click on the Calculate Scores button and based upon how many letters in each word (1 for 3 and 4 letters, 2 for 5, 3 for 6, 5, for 7, and 11 for 8 or more) places the appropriate scores for each player. These scores are carried forward (while all lists are cleared) into the next round. The number of rounds will be determined by time limits for the game.
    Attached Images Attached Images  
    Sam I am (as well as Confused at times).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width