Like Tree1Likes
  • 1 Post By Matticus

Word Scramble Game

This is a discussion on Word Scramble Game within the C++ Programming forums, part of the General Programming Boards category; Hi all, I am currently doing the design for my project - The World Scramble Game. I think it is ...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    15

    Smile Word Scramble Game

    Hi all,

    I am currently doing the design for my project - The World Scramble Game.

    I think it is possible for me to do in the 2 ways below:
    1. Randomize the alphabets and put onto the board. User has no limit in creating words from those alphabets, as long as they match the words in the dictionary.
    2. Limit the user to follow certain pattern in forming the words, like, the alphabets have to be linking with each other in order to form a word. Meaning that the words will be firstly put onto the board, then fill in the rest empty blank with random alphabets. (please let me know if you have better idea to do this)

    Which way do you guys think is better and less complicated?

    Fyi, my programming ain't that good, so I'm looking for a simpler way to do this.
    Thank you.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    We need to know what exactly your world scramble game is.
    I suspect its what we in the UK call a wordesearch puzzle - where the answer words are placed in the grid on a diagonal or horizontal or vertical and then a load of random letters are scrambled up around them? Your description does sort of match this but i have kind of erm.. elucidated.

    I personally think the very easiest way is to first write a text file with your words laid out in it- in their various positions and orientations - and then read this file into the program and if there is a whitespace found then swap for a randomly generated character.
    Output the file char / random char as you go along.

    In fact the most utterly simple thing to do is type a load of random letters into a file then go back and type the answer words over the random chars, save then load into your program - your coding goal is then handling user input and guesses etc/progress etc
    Maybe I am not answering all of your requirements but thats something that might help overall.

    Are you wanting the user to design the puzzle for the program goal? Or are you wanting the user to enter guesses to the words in there? Its not too clear from your original post.
    Last edited by rogster001; 07-13-2012 at 03:09 PM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    15
    Quote Originally Posted by rogster001 View Post
    We need to know what exactly your world scramble game is.
    I suspect its what we in the UK call a wordesearch puzzle - where the answer words are placed in the grid on a diagonal or horizontal or vertical and then a load of random letters are scrambled up around them? Your description does sort of match this but i have kind of erm.. elucidated.

    I personally think the very easiest way is to first write a text file with your words laid out in it- in their various positions and orientations - and then read this file into the program and if there is a whitespace found then swap for a randomly generated character.
    Output the file char / random char as you go along.

    In fact the most utterly simple thing to do is type a load of random letters into a file then go back and type the answer words over the random chars, save then load into your program - your coding goal is then handling user input and guesses etc/progress etc
    Maybe I am not answering all of your requirements but thats something that might help overall.

    Are you wanting the user to design the puzzle for the program goal? Or are you wanting the user to enter guesses to the words in there? Its not too clear from your original post.
    Hi, thanks for your reply
    Yeah, the game is just like what you mentioned.
    Random letters are generated in a 4*4 grid, and user will form words based on the generated letters.
    Please correct me if i'm wrong
    From what you've suggested, I can design my words' arrangement in a txt file then load it into the program? and then fill the rest empty grids with random characters?

    My objective is to let user form words wit the provided letters.

  4. #4
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    From what you've suggested, I can design my words' arrangement in a txt file then load it into the program? and then fill the rest empty grids with random characters?

    My objective is to let user form words wit the provided letters.
    In answer to the first bit of the quote, yes, and you can add the random characters in the same function that reads the file - every time you detect a whitespace, - but I think the game that describes would kind of conflict with your second bit - the user is to form words -

    I think you are talking about just generating a random grid of letters and then the user has to just use the letters they see to make as many words as they can or something? do they then have to input the words? Or is it supposed to be like in a newspaper where you would just see the puzzle and then write the answers down somewhere.

    what i meant by the simple wordsearch is like:

    wewrsdfgs
    sdfhsetfxc
    aeoxvniifd
    dfgugdfffe
    rbbssfgsd
    wqertwer

    And you have to find the word ' house ' in the grid.
    Last edited by rogster001; 07-14-2012 at 10:29 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    2,272
    Quote Originally Posted by Erica View Post
    Hi, thanks for your reply
    Yeah, the game is just like what you mentioned.
    Random letters are generated in a 4*4 grid, and user will form words based on the generated letters.
    Please correct me if i'm wrong
    From what you've suggested, I can design my words' arrangement in a txt file then load it into the program? and then fill the rest empty grids with random characters?

    My objective is to let user form words wit the provided letters.
    It seems like you don't want a game with predetermined words that have to be found - but instead a game with completely random letters and the user has to find any words that occur. It sounds a lot like the game Boggle. If this is the case, then you don't need to write/load a text file for the game board, but can instead just randomly generate 16 letters.

    That would be the easy part. The difficult part would be validating all the words that the user enters; (1) Find out if the string of letters actually occurs on the board, then (2) determining if it's a real word.
    rogster001 likes this.

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    lets see some code eh ?...
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  7. #7
    Registered User
    Join Date
    Jun 2009
    Posts
    15
    Quote Originally Posted by Matticus View Post
    It seems like you don't want a game with predetermined words that have to be found - but instead a game with completely random letters and the user has to find any words that occur. It sounds a lot like the game Boggle. If this is the case, then you don't need to write/load a text file for the game board, but can instead just randomly generate 16 letters.

    That would be the easy part. The difficult part would be validating all the words that the user enters; (1) Find out if the string of letters actually occurs on the board, then (2) determining if it's a real word.
    Quote Originally Posted by rogster001 View Post
    In answer to the first bit of the quote, yes, and you can add the random characters in the same function that reads the file - every time you detect a whitespace, - but I think the game that describes would kind of conflict with your second bit - the user is to form words -

    I think you are talking about just generating a random grid of letters and then the user has to just use the letters they see to make as many words as they can or something? do they then have to input the words? Or is it supposed to be like in a newspaper where you would just see the puzzle and then write the answers down somewhere.

    what i meant by the simple wordsearch is like:

    wewrsdfgs
    sdfhsetfxc
    aeoxvniifd
    dfgugdfffe
    rbbssfgsd
    wqertwer

    And you have to find the word ' house ' in the grid.
    Quote Originally Posted by rogster001 View Post
    lets see some code eh ?...
    Hi Mattics and Rogster,

    Yeap, it's like what you guys said, generate random letters and the user has to use the letters to form as many words as possible. And yeah, the validating part is a bit hard.
    I haven't started coding yet, i'm just doing the design for it first, with the pseudocode and stuffs.

  8. #8
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    Validating the user input is a good challenge for you yes - limit it to max 9 letter words maybe? But it is going to be harder - and more advanced - to determine if the word itself is valid - you will need a database as a dictionary - or download / create a flatfile with a ton of words in it then write some fancy voodoo to lookup if the user has an answer that hits a match.

    Maybe theme it - so the user has to find sports team names or something - then you can have a much smaller reference - you could even ask user to input the category to start - football teams - authors - presidents of etc. - And you could write a routine to find the maximum hits for your generated grid - that way you can calibrate the targets before the user starts, you could say - 5 = excellent 3 = good, 1 = go watch more football.
    stuff like that.

    Also consider supressing the output of a grid until it contains a useful mix of letters - so thats another test you need to write in. Or maybe take a selection of your lookup reference names and insert them into the grid at random until no space is left- that way there are guaranteed to be valid words in there.
    Last edited by rogster001; 07-15-2012 at 07:45 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  9. #9
    Registered User
    Join Date
    Jun 2009
    Posts
    15
    Quote Originally Posted by rogster001 View Post
    Validating the user input is a good challenge for you yes - limit it to max 9 letter words maybe? But it is going to be harder - and more advanced - to determine if the word itself is valid - you will need a database as a dictionary - or download / create a flatfile with a ton of words in it then write some fancy voodoo to lookup if the user has an answer that hits a match.

    Maybe theme it - so the user has to find sports team names or something - then you can have a much smaller reference - you could even ask user to input the category to start - football teams - authors - presidents of etc. - And you could write a routine to find the maximum hits for your generated grid - that way you can calibrate the targets before the user starts, you could say - 5 = excellent 3 = good, 1 = go watch more football.
    stuff like that.

    Also consider supressing the output of a grid until it contains a useful mix of letters - so thats another test you need to write in. Or maybe take a selection of your lookup reference names and insert them into the grid at random until no space is left- that way there are guaranteed to be valid words in there.
    thanks a lot for your suggestions!
    I think for now I will go for simpler one first
    The theme-it idea is good!
    Will be start coding soon, and I'll ask here if in case I'm stuck anywhere, hope you guys may help me
    Other than that, I'm having a problem, when user input the answer, I have to check with the dictionary, which consists of huge amount of words, so I need an efficient way to search through the dictionary. I was suggested to use hashtable or decision tree, any ideas?
    Thanks!

  10. #10
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    I was suggested to use hashtable or decision tree, any ideas?
    Are you up for that right off the bat? I think you should stick with your simple policy - Just get a program working that can populate a grid with letters - then just use a small file of say 100 words and lookup if the word your user has input matches any of them - of course you have an extra layer of validation that has not been mentioned yet - you need to check if the word the user inputs can actually be formed from the letters available in the grid.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  11. #11
    Registered User
    Join Date
    Jun 2011
    Posts
    2,272
    Quote Originally Posted by rogster001 View Post
    ...of course you have an extra layer of validation that has not been mentioned yet - you need to check if the word the user inputs can actually be formed from the letters available in the grid.
    Quote Originally Posted by Matticus View Post
    (1) Find out if the string of letters actually occurs on the board...
    =)

    But yes, the policy of simplicity is probably the best.

    @OP: This would also be a good exercise in modular programming. You can create an empty (or simple) function to check if the user input is a real string. Then as another separate project, write a program to compare an input string to "valid" words. Then integrate that second program into the first. This way, one project won't be too overwhelming.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 28
    Last Post: 10-23-2011, 07:17 PM
  2. Scramble Elements in Array
    By fcommisso in forum C Programming
    Replies: 13
    Last Post: 10-07-2009, 03:09 PM
  3. C++ Simple Puzzle Word Game
    By ijAcK in forum C++ Programming
    Replies: 2
    Last Post: 09-23-2008, 06:41 AM
  4. Word Scramble
    By Unregistered in forum C++ Programming
    Replies: 30
    Last Post: 08-22-2002, 08:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21