Urgent.News

What's breaking now, across thousands of outlets.

Tech

The opening layout is part of the puzzle

Originally published on indiecore.net . Part 5 of 10 on building a word-block puzzle engine. Part 4: difficulty rates, progression places. A level opens with an empty grid and a scatter of loose blocks around it. I assumed this was presentation — put the pieces somewhere sensible, get on with the game. It is not presentation. It decides how big the grid is drawn, and it can give away the answer.…

The opening layout of a word-block puzzle is crucial to the player's experience. Initially, it appears to be merely presentation, with blocks scattered around an empty grid. However, this layout serves a much deeper purpose. It determines the size of the grid drawn and can even reveal the answer. To achieve this, the layout must be carefully designed.

The camera frames the board and loose blocks together, so the zoom is calculated as the minimum of the available width divided by the span width, and the available height divided by the span height. This ensures the grid is drawn at a comfortable size, preventing squinting on smaller screens.

The objective is not just fitting the blocks onto the screen, but maximizing the grid size. This is a packing problem, where the goal is to determine how large the grid can be drawn, given the loose blocks. A tightly packed arrangement can consume up to 20% of the board's space.

The puzzle's rule that makes it challenging is that a cut board can be tiled exactly by its own blocks. The most efficient packing arrangement is to rebuild this tiling, but this is not allowed. The blocks come out already assembled, making the level a matter of sliding a finished slab onto the grid. The near-misses are just as easy to make, as two neighboring blocks may accidentally end up in their solved positions.

To prevent this, a rule is enforced that no two blocks that are neighbors in the solution may share an origin. Blocks that are not neighbors are left alone, as they do not touch in their solved positions. This rule is checked three times during the solving process.

A loose block touching the board reads as if it is already placed, creating a clearance gap. However, this clearance is only on the axes that matter, not diagonally. A block sitting off a corner overlaps the board on neither axis and is not read as placed. Forbidding these four corner cells is costly and often makes it impossible to have an arrangement that wraps the board on all four sides.

Positions are stored as (row, col) in cells, relative to the board origin. This allows the arrangement to be reusable on any screen, any cell size, and any zoom. Blocks can be off the lattice on an axis where they are clear of the board, buying back span. However, on an axis where they share the board's extent, they must stay whole.

Arrangements that put something above, below, left, and right of the board are preferred, as they often result in a tighter fit. This arrangement may also look like a bug in the camera, causing the board to appear as if it failed to load. Symmetry is also valuable, even when the arithmetic suggests otherwise.

The harness reports four things per board, and the pipeline will not ship a pack that fails any of them. These include the kept, block cells per side, and the balanced distribution of cells above, below, left, and right. Overlapping cell pairs are allowed, but only filled cells are considered. Solving the arrangement offline is the slowest step of the pack pipeline, so it is computed once and stored in the board file for use at level load.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

CapCut nights vs code-shaped video

CapCut is honest about what it is: a fast human editor. The tax shows up when the same launch needs a second offer, a third aspect ratio, and a fourth “final” because the CTA moved.

  • CapCut simplifies basic video editing tasks
  • Remotion-class tools streamline complex campaigns
  • SceneRok offers cohesive branding and generative assets

More from Friday 18 September →