Quantcast
Viewing all articles
Browse latest Browse all 18

Scrabble game. Need help with parsing words from tiles.

So I'm learning Unity still and I'm trying to put together a Scrabble clone for fun. How I have it set up is I have a 21x21 grid (more than regular Scrabbs) and 42 strings. One for each row and column. When the player places a tile on a space, depending on the name of the space (say, "H11" or "M9") it will then insert the tile's letter into the right spot in two of the 42 strings. When the player has all of the tiles placed, the game will parse the strings, split them by spaces, and insert each string that's greater than 1 letter into a List<>. Then it checks to see that each string in the list is valid by checking it against a dictionary text file. If it is valid, each string gets put into a separate list of "played" words so that the player can't try to play them a second time. This all works great, but I have no idea how to prevent the player from laying down tiles with reckless abandon, leaving spaces in between, not building off other words, that sort of thing. As it is now, a player can play multiple words (within the seven tile limit per turn) all over the board, so he or she can just steal all of the triple word scores, just as long as the words are valid. I have no idea how to mitigate this issue. I imagine it's because my current solution just isn't gonna work in the end, so I'm hoping someone can provide some insight as to how to fix this issue or point me in the right direction for a complete code rewrite. Anyone have any experience with this?

Viewing all articles
Browse latest Browse all 18

Trending Articles