Anagram Solver- How to Ideas??

Hi folks, SO I've been attempting to make an anagram solver and hitting a brick wall. I'm trying to create and a solver that can locate from 3 letter words to 9 letter words. Time isn't an issue as it has 2 minutes at least to locate all of them So if its slow its not too much of bother. I start with a string of 9 letters and I want to find words that can be made with that string. Any ideas? Demos? Words of wisdom?

Comments

  • ArmellineArmelline Member, PRO Posts: 5,364

    It sounds like what you're after isn't actually an anagram solver, rather a word list. I'd assume you could find lists of 9 letter words and all words that can be created from them. I'd be surprised if games are generating those lists dynamically.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    I think the tricky part is finding shorter words. It shouldn't be hard to create an anagram "solver" for exact length (9-letter words that use 9 letters) using wordlists, as @Armeline suggested. This game does just that: http://forums.gamesalad.com/discussion/93290/20-seconds-word-game-out-now/p1.

    But I'm not sure how you'd find 3 to 8 letter words that work.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • fmakawafmakawa Member Posts: 565

    @Armelline the problem of that is that it would need either word lists for every nine letter word and derivatives which is prohibitive. I was thinking that I take a word lets say CARTHORSE which has 7 unique letters. I make GS look for words that do not contain the remaining 19 letters. Think that might work?

  • fmakawafmakawa Member Posts: 565

    @tatiang what about above?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    I mean, sure, but I still am not sure HOW you would do that.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • fmakawafmakawa Member Posts: 565

    @tatiang Bear with me here, thinking as I am typing. I have a string with all 26 letters and 26 individual letter attributes which are blank at start. Puzzle is given and we have 7 unique letters. Those letters are then removed using text replace from the string of 26 letters. The remaining 19 are taken one by one from the string and placed into the individual letter attributes. The extra 7 slots of the individual 26 attributes are left blank (and we want to include blank spaces we make the attributes contain a number or something we find undesirable). Then setting a rule with conditions for all 26 attributes with the condition of "does not contain" should only leave responses that have the 7 unique characters from our word.- I think. A tad round about if it works.

  • zweg25zweg25 Member Posts: 738

    I may have suggested this earlier: you have to loop through every permutation of letter combinations. In a program like Xcode this can take less than a second, but when I created my anagram solver for 6 letter words and under for Gamesalad it took about 10 seconds. I don't know if Gamesalad's loops have improved, but I just don't think Gamesalad is meant for that.

    An alternative solution is build an anagram solver online and then use the networking behaviors to send the info to your server.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @fmakawa said:
    @tatiang Bear with me here, thinking as I am typing. I have a string with all 26 letters and 26 individual letter attributes which are blank at start. Puzzle is given and we have 7 unique letters. Those letters are then removed using text replace from the string of 26 letters. The remaining 19 are taken one by one from the string and placed into the individual letter attributes. The extra 7 slots of the individual 26 attributes are left blank (and we want to include blank spaces we make the attributes contain a number or something we find undesirable). Then setting a rule with conditions for all 26 attributes with the condition of "does not contain" should only leave responses that have the 7 unique characters from our word.- I think. A tad round about if it works.

    So I'm trying to follow this...

    26 letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ

    7-letter word: HEAVENS

    19 remaining letters: BCDFGIJKLMOPQRTUWXYZ

    Then setting a rule with conditions for all 26 attributes with the condition of "does not contain" should only leave responses that have the 7 unique characters from our word.

    I don't get this at all. Can you give an example?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • fmakawafmakawa Member Posts: 565

    19 remaining letters: BCDFGIJKLMOPQRTUWXYZ

    Then setting a rule with conditions for all 26 attributes with the condition of "does not contain" should only leave responses that have the 7 unique characters from our word.

    I don't get this at all. Can you give an example?

    26 text attributes- game.1, game.2, game.3 etc (whichever naming method you wish). Take the string BCDFGIJKLMOPQRTUWXYZ and place each letter in an attribute - game.1 =B, game.C=C, game.3 = D etc. The remain 7 will have a place holder like *. Then running a loop using all 26 attributes as do not contain as it searches a word list table. A word like 'even' could be found but 'reave' would not since it contains 'r'. Does that make sense?

  • fmakawafmakawa Member Posts: 565

    @zweg25 said:
    I may have suggested this earlier: you have to loop through every permutation of letter combinations. In a program like Xcode this can take less than a second, but when I created my anagram solver for 6 letter words and under for Gamesalad it took about 10 seconds. I don't know if Gamesalad's loops have improved, but I just don't think Gamesalad is meant for that.

    An alternative solution is build an anagram solver online and then use the networking behaviors to send the info to your server.

    Correct me if I am wrong but wouldn't that need all permutation lists which is prohibitive as they run into the millions. IF we use combinations which are much fewer, several hundred I'm struggling to see how it would match the combinations which are essentially placeholders to the actual letters and how that is then connected to the word list were the solutions are. Care to run me through what you did or are doing? As I mentioned above, time isn't an issue at present, as long as everything is done in 2 minutes.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Okay, so you'd check the 10,000 words or whatever you have in a table to see if they contain B and then C and then D, etc. using a loop? So that would tell you that EVEN doesn't contain B and EVEN doesn't contain C, etc. and it would tell you that EVEN contains E and V and E and N... so I guess I can sort of understand now.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • zweg25zweg25 Member Posts: 738

    @fmakawa said:

    @zweg25 said:
    I may have suggested this earlier: you have to loop through every permutation of letter combinations. In a program like Xcode this can take less than a second, but when I created my anagram solver for 6 letter words and under for Gamesalad it took about 10 seconds. I don't know if Gamesalad's loops have improved, but I just don't think Gamesalad is meant for that.

    An alternative solution is build an anagram solver online and then use the networking behaviors to send the info to your server.

    Correct me if I am wrong but wouldn't that need all permutation lists which is prohibitive as they run into the millions. IF we use combinations which are much fewer, several hundred I'm struggling to see how it would match the combinations which are essentially placeholders to the actual letters and how that is then connected to the word list were the solutions are. Care to run me through what you did or are doing? As I mentioned above, time isn't an issue at present, as long as everything is done in 2 minutes.

    For an anagram solver of 9 letters there are 362,880 permutations. Which is a lot, but not unheard of. Thinking about it deeper I like my second idea better working with a server. But if you are stuck with running through the combos in Gamesalad then you will have to set up a way (my suggestion is through tables) of looping through the permutations of the letters.

  • fmakawafmakawa Member Posts: 565

    For an anagram solver of 9 letters there are 362,880 permutations. Which is a lot, but not unheard of. Thinking about it deeper I like my second idea better working with a server. But if you are stuck with running through the combos in Gamesalad then you will have to set up a way (my suggestion is through tables) of looping through the permutations of the letters.

    I like the server idea but it means if someone is offline then they lose that functionality which is not ideal.
    As to a table with all 362 880 permutations, how are you making it follow them? For instance 15679 is a permutation of 5 selections. How does it then read that, translate it to letter configurations? The number of 362880 is faulty too since it assumes that I have 9 letters and choosing from those same 9 letters at all time since its 9 letters with choosing 9 with no repetition and order being significant. The puzzles however are random. "CARTHORSE" will give me 362880 different permutations if making 9 letter choices and "MAKESHIFT" will give me an entirely different set. IF the table we are making with the choices is simply one that follows a sequence and then translates that sequence to letter combinations relevant to the puzzle, how is it doing that? As in 15679 would be a sequence that builds C H O R E to give "Chore" and that is matched up to a search to see if its actually a word. How is your version working exactly? I haven't managed to clearly understand you.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    I guess I do not quite understand the question.

    Are you wanting to display all the words that make up a given 9 letter string? (There are are less than 50,000 nine-letter words in English. Searching such a table of 9 letter words would take just an instant for GameSalad.)

    Or do you want to choose some letters from a set of 9 random letters and see if they make a word?

    Or is it something else you want to do?

  • zweg25zweg25 Member Posts: 738

    @RThurman if you take a look at this website http://scrabblewordfinder.org, it might help explain what the idea is. If you insert any string it returns all the words that are the length of that string and all the words that are shorter than the given string, but still made up of the given letters. This is what he is trying to achieve in Gamesalad.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
  • zweg25zweg25 Member Posts: 738

    I believe so

  • fmakawafmakawa Member Posts: 565
    edited October 2016

    And @zweg25

    No, not quite. That was about a boggle solver. We realised that GS is incapable of such a thing at this time. This is about an anagram solver, maybe the name is a misnomer but it's markedly different to that thread. It's a different problem altogether.

  • ArmellineArmelline Member, PRO Posts: 5,364

    @fmakawa said:
    And @zweg25

    No, not quite. That was about a boggle solver. We realised the GS is incapable of such a thingaa at this time. This is about an anagram solver, maybe the name is a misnomer but it's markedly differvent to that thread. It's a different problem altogether.

    I thought I understood what you were wanting to do in this thread, but I clearly don't, as the other thread seems to be asking for the same thing. Could you perhaps explain the difference, as I think that would really help clarify things for people (me).

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @Armelline as I understand it, @fmakawa wants to be able to generate a 9-letter string such as EDUCATION and then check a word list to see if any of the words are valid full or partial anagrams of that list. So valid words would include (among others):

    CAUTIONED
    CAUTION
    TEND
    DEN

    I think the other thread was primarily about finding linked letters in a table (my guess since I haven't read through it all) where each letter must "touch" another as in the classic game Boggle. For this application, any order is valid.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ArmellineArmelline Member, PRO Posts: 5,364

    @tatiang said:
    I think the other thread was primarily about finding linked letters in a table (my guess since I haven't read through it all) where each letter must "touch" another as in the classic game Boggle. For this application, any order is valid.

    Ah, that would make sense. Thanks for the explanation!

  • fmakawafmakawa Member Posts: 565

    Exactly as @tatiang put it!

  • fmakawafmakawa Member Posts: 565

    @RThurman what I am trying to do is what @zweg25 and @tatiang have describes above. To take a string of nine letters, which happen to form a word (from that list of 50000 words) and the generate all the words by checking a word list that can be made by using the letters in that string

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @fmakawa -- I see.
    Since time is not critical for your application, I would probably just brute force it by going through all the words in the dictionary and seeing if each word can be found inside the 9-letter word. Attached is an example. (The table 'word list' only contains 11 words. You would have to replace it with your full dictionary.)

  • fmakawafmakawa Member Posts: 565

    @RThurman said:
    @fmakawa -- I see.
    Since time is not critical for your application, I would probably just brute force it by going through all the words in the dictionary and seeing if each word can be found inside the 9-letter word. Attached is an example. (The table 'word list' only contains 11 words. You would have to replace it with your full dictionary.)

    This is great and working like a charm when I tested it with a full dictionary.
    However I am confused a little regarding your logic. (Its working great but would like to know how it is operating)

    In the attached picture you set self.isword to true and then a rule that's been in nested in a condition regarding textlength.You compare a letter from the word in the table to see if it is contained in the puzzle. IF it is, it is then replaced in the puzzle string but nothing and it then searches for the next letter and the next until the word is complete. if it any point the letter is not contained in the string then it changes the attribute self.isword to false. What I don't understand is what the code does when the word is only ie 3 letters long - at 3 letters it still says true and then the fourth letter is false right there is nothing to compare to? In time every wordintable will result in a false, no? Crucially, how is the last rule, that requires self.isword to be true acknowledging a word as found since everyword in a table will eventually return a false as every word when the textlength(self.myword) due to text replace eventually is less than self.wordfromtable and would thus give a false value. Shouldn't it have a true value for the wordsfound rule to function and add words that are found to match?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @fmakawa said:

    This is great and working like a charm when I tested it with a full dictionary.
    However I am confused a little regarding your logic.
    .....
    What I don't understand is what the code does when the word is only ie 3 letters long - at 3 letters it still says true and then the fourth letter is false right there is nothing to compare to? In time every wordintable will result in a false, no?

    No
    Its just a 'feature' of the way string comparisons are handled in Lua. Basically, it is ignoring any comparisons that do not make sense. Pretty sloppy, eh!

    Hmmm.... I did throw it together rather quickly. (And did not even save or test it until it was done. Good thing it worked and didn't crash.) It was meant as a quick idea to show a possible path you can take.

    You can modify it as needed. For example, you might feel more comfortable with it by adding more conditions for each nested rule. For example, you might want to add a condition for the third-letter rule that says:
    If wordlength≥3 and letter 3 is found in myWord
    then
        modify myWord
    else
        change isWord to false

    Have fun!

  • fmakawafmakawa Member Posts: 565

    @RThurman that's an interesting behaviour!!! Thanks, now it make sense! Already modifying it to suit my needs.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Gad you can find a use for it!

Sign In or Register to comment.