Hello everyone!
So, I've been given an assignment to create something of a simplified Scrabble game in C.
I'll start of by mentioning that I'm aware of the vastness in similarities between C and C++, but I am more versed in C++ and so I'd consider my C to be slow but functional, so please bear with me if I'm making trivial syntax errors.
Now, the assignment is to take an existing 'board' with some letters already placed on it, and a 'tray' of letters for the player, and then output a new 'board_res' with the new words/letters on it, a new 'tray_res' with the letters removed that were added to the board, and the total word score for the letters added (no triple or double word/letter scoring either).
The idea is to create a function that finds the maximal score possible, and uses those letters to form those words. Scoring is based on a template similar to traditional Scrabble letter scoring.
Now, I haven't even began writing too much code for this yet as I am still in the design phase of this. I'm not really sure what the best approach of attack is.
My initial thought is to check each 'word' present on the board, or even each grouping of letters, and see if it matches in similarity to any other words possible with letters in my tray, but that seems roundabout and not necessarily capable of achieving the optimal score.
My second thought is to take the letters one by one and place them near the words and see if they match something in the dictionary, check the score of it, and store the highest scoring variation of this. Now of course, the problems with this are immediately easy to recognize, as this is also somewhat of a roundabout way of doing it, and may not allow taking advantage of things like multiple word scores or etc.
Btw, when I refer to the dictionary, I refer to the a random char *dictionary[]
array that I've been provided to check against, which we assume has words in it similar to what would be found in a dictionary.
So my other thought was to maybe start taking letters from my tray, and letters from the board, and checking in the dictionary the possibilities allowed by those letters. Maybe even establish some sort of order for the letters already on the board and then gauge the potential word scores there. But this seems a bit overly complex for this kind of thing.
Anyway, I assume that the creation of this design is one of the biggest purposes of this problem. I will continue to think about this obviously, but input/ideas/suggestions from you all would be most welcome.