Player's input in Scrabble?

This is a discussion on Player's input in Scrabble? within the C Programming forums, part of the General Programming Boards category; Argh.. this is getting frustrated. I fix one problem, another one appears. I am now having trouble on how to ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    16

    Unhappy Player's input in Scrabble?

    Argh.. this is getting frustrated. I fix one problem, another one appears. I am now having trouble on how to take in the user's input in a game of Scrabble. Consider the first player already went, and placed down his word:

    Code:
    R A I D
    This word was entered by asking the user for a proper location and the FULL WORD that he wants to make.

    Now the next player's turn.

    How should I get his input? If I get in terms of location and letters, I can make a new word like this

    Code:
    R A I D S
    (just adding the letter S at location (0,4) for this case)

    or like this with location of (1,1)
    Code:
    R A I D
      S
    But what if the user wants a word like this:

    Code:
      D
    R A I D
      D
    then you are not just adding letters to preexisiting words but also adding letter(s) before and after. I looked into entering the whole word and the location but that won't work, if you want to make multiple words using your letters.

    I hope you guys understand what I am trying to say. Plz ask for any clarification as required.

    Once again, thanks
    Helix

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Just have them add a letter at a time. If the letters are not in a row, or not in a column, then they're invalid placement. IE:
    1) 5,5
    2) 5,6 (valid)
    3) 5,8 (valid)
    4) 6,9 (invalid)

    Then once they're done placing valid entries, and do whatever it is that you have be "Ok I'm done.", then you go through the rows and columns surrounding their letters to make sure every letter they place is part of a valid word, and that nothing makes an invalid word.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    Or use:
    Location,Direction,Word

    Using the words you mentioned:
    5,7,A,raid
    5,7,a,raids
    6,6,d,dad
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  4. #4
    Jez
    Jez is offline
    The C-er
    Join Date
    Mar 2004
    Posts
    192
    There is a Scrabble game on my Sharp Zaurus (PDA running linux). To enter words with this, first you arrange the tiles on your rack into the order they will be laid (by dragging), then the letters are "painted" onto the board with the stylus. If you're going to have a graphical interface, this might be worth looking at.

    I suspect WaltP and quzah are right tho, sometimes a change of perspective can make code fall into place more neatly.

    It's an interesting problem tho (well I think so). I'll see if I can think of something !

    Glad you're still plugging away at it vex_helix !

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    16

    Question Scanning all directions?

    I like yr idea Quzah regarding entering one at a time. But how do I check all directions for words?

    Consider initial words:

    Code:
          B
      G E T
      O
    And I make both NOT AND BET
    Code:
        B
      G E T
    N O T
    Since 'T' was the last character typed, I only use 'T' to scan up,down,right,left to find words?

    What about this scenario:

    Code:
    G O T
    and I make three words ON, NO, TO respectively:

    Code:
    G O T
      N O
    In this case I gotta check all directions for both 'N' and 'O'.

    Isn't there just one simple way to scan for words for all direction? Also, do I scan as I enter words?

    Helix

  6. #6
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161

    Re: Scanning all directions?

    Originally posted by vex_helix
    I like yr idea Quzah regarding entering one at a time. But how do I check all directions for words?

    Consider initial words:

    Code:
         B
      G E T
      O
    And I make both NOT AND BET
    Code:
        B
      G E T
    N O T
    Since 'T' was the last character typed, I only use 'T' to scan up,down,right,left to find words?
    Then don't "only use 'T'." You must use all tiles played. Keep track of the positions played and go back thru them to test for additional words in the 'other' direction.

    This may make my suggestion better because with quzah's code, you not only have to enter every single letter being placed, but you have to analyze the placement to figure out the direction. In my solution, you already know the direction.

    Originally posted by vex_helix
    What about this scenario:

    Code:
    G O T
    and I make three words ON, NO, TO respectively:

    Code:
    G O T
      N O
    In this case I gotta check all directions for both 'N' and 'O'.

    Isn't there just one simple way to scan for words for all direction? Also, do I scan as I enter words?
    Yes. See above.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. input redirection
    By sashaKap in forum C Programming
    Replies: 6
    Last Post: 06-25-2009, 01:59 AM
  2. For loop problems, input please.
    By xIcyx in forum C Programming
    Replies: 2
    Last Post: 04-22-2007, 03:54 AM
  3. I would love some input on my BST tree.
    By StevenGarcia in forum C++ Programming
    Replies: 4
    Last Post: 01-15-2007, 12:22 AM
  4. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  5. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM

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