๐—ฉ๐—ฎ๐—น๐—ถ๐—ฑ๐—ฎ๐˜๐—ถ๐—ป๐—ด ๐—ฃ๐—ฎ๐˜๐—ต๐˜€ ๐—ถ๐—ป ๐—ฎ ๐—•๐—ฟ๐—ผ๐˜„๐˜€๐—ฒ๐—ฟ-๐—•๐—ฎ๐˜€๐—ฒ๐—ฑ ๐—ช๐—ผ๐—ฟ๐—ฑ ๐—ฃ๐˜‚๐˜‡๐˜‡๐—น๐—ฒ ๐—š๐—ฎ๐—บ๐—ฒ

Word puzzle games look simple. Players connect letters and form words.

The code is not simple.

A browser game must answer these questions:

A tile needs more than a letter. It needs a position. You must store the row and column. Without coordinates, you cannot check if tiles connect.

Movement rules change the game feel.

If you allow diagonal movement, players get more freedom. If you only allow horizontal and vertical movement, paths become stricter.

You also must prevent players from reusing tiles. You can do this by storing tile coordinates in a Set. If a coordinate appears twice in a path, the move is invalid.

A full path validator follows three steps:

  1. Check if the path is empty.
  2. Check for duplicate tiles.
  3. Check if every tile is adjacent to the next one.

After you validate the movement, you check the word. Do not use a massive dictionary. Large dictionaries create accidental words. Use a curated list. This gives you control over the puzzle design.

A fair puzzle must also be solvable. A board might have valid words but still leave impossible tiles behind. You must track how many unique tiles the player covers. If the count does not match the required tiles, the board is incomplete.

If you want every tile to belong to exactly one answer, you must check for overlapping paths. This is vital when you build a puzzle generator.

Do not start with random letters. Random boards are hard to make fair.

Follow this process instead:

For your first version, build a daily puzzle mode. A daily mode only needs one good board per day. This allows you to perform extra checks for quality.

The hard part of a puzzle game is not the graphics. The hard part is the validation.

Build your rules first:

Build the validator first. Then build the game around it.

Source: https://dev.to/airobus/validating-paths-in-a-browser-based-word-puzzle-game-2nim