Scrambling Word C #

I am currently writing such a game in C #. I can get the computer to find the highest point words that can be made using the current rack, however I have no idea how to check if this word is β€œPlaceable” on the game board 15 * 15 (2D array: string [,] )

In this state, by default (without letters on the board), all elements are set to 0.

Allowed

--------------- -------H------- -------E------- -----FILL------ -------L------- -------O------- --------------- 

How to check for a word? For instance:

Is not allowed

  --------------- -H------------- -E------------- FILL------------ <-- F is out of bounds -L------------- -O------------- --------------- 

Is not allowed

  --------------- -H------------- -EW----------- -LO----------- -LR----------- FOLL----------- <-- Fill is overlapping with O ---D----------- 
+6
source share
2 answers

The article " The fastest Scrabble engine in the world (PDF), since 1988, describes the efficient Scrabble engine. It is short and surprisingly readable!

+18
source

I learned how to do this based on the F # SharpScrabble project . Even if you do not know F # (like me), you will feel how the author decided to do it.

The big things for me were:

  • Using the Coordinate System to Find Tiles
  • Filling the Board with Squares , which can contain a fragment (letter), but also contain information about the rating.
  • Tile is a letter both in the player's letter bank and on the board
  • Move , which represents the placement of players letters
  • Implement IComparable by coordinates and tiles to simplify sorting
  • Calculation Runs , which represents the words that will be moved, to calculate the score

All in all, a really good ground starting to wind the Scrabble engine. I was able to port most of this code to C # without knowing that F # was licking, so this should not be horrible for others.

0
source

Source: https://habr.com/ru/post/893268/


All Articles