The Tiles Problem

Why is tile not working?

If your tile coding agent or tile-based puzzle solver isn't working, the common causes are tile width, too few tilings, unsolvable starts, and bad heuristics.

On this page
  1. Short answer
  2. If tile coding is not learning
  3. If a tile-based puzzle solver fails
  4. A debugging checklist

Short answer

In AI and machine learning, “tile” usually means one of two things: tile coding, a method used in reinforcement learning, or a solver for a sliding tile puzzle. If yours isn’t learning or isn’t solving, the cause is often a setting, a missing check, or an off-by-one error rather than one big mystery. The sections below go through the common causes.

If you meant a floor tile, a bathroom tile, or a tracking device, this site does not cover those.

If tile coding is not learning

Tile coding splits the state space into a grid of tiles and uses several offset copies of that grid. Each state activates one tile per copy, and the value estimate is the sum of the weights of those active tiles. When the agent stops improving, check the following.

Tiles that are too narrow or too wide

Narrow tiles cover little ground, so experience rarely carries over to nearby states. Learning is slow, and the estimates stay noisy. Wide tiles lump different situations together, so the value estimate cannot tell them apart. Compare the tile width with the range of each input. A width that covers a modest fraction of the range is a common starting point, but the right size depends on the task.

Too few tilings

One grid gives a stepped estimate with visible edges. Several offset tilings smooth those edges. If the value estimate looks blocky or striped when you plot it, add tilings and check again.

A learning rate that is too large

Large updates can make the weights swing back and forth, and the estimates can grow without bound. Lower the step size first. Scaling it down by the number of tilings is a common starting point.

Inputs on very different scales

If one input runs from 0 to 1 and another from 0 to 1,000, a single tile width for both will suit one of them and not the other. Set widths separately for each dimension, using the range of that input.

Index and offset bugs

Several bugs look like bad learning but are really code errors:

  • Each tiling must actually be shifted. If every tiling has the same offset, you have one grid repeated.
  • Indexes must stay inside the weight table. An index one past the end is a common off-by-one error.
  • Angle-like inputs need to wrap around correctly, so that 359 degrees and 1 degree count as close together.

To test this quickly, print the active tile indexes for a few states. If every state activates the same tiles, or an index runs past the end of the table, something is wrong.

If a tile-based puzzle solver fails

The sliding tile puzzle has a few traps that can make a solver look broken.

The start state cannot be solved

Half of all arrangements can never reach the goal. For a 3 by 3 board, count the inversions: pairs of numbered tiles in the wrong relative order when you read the board row by row, ignoring the blank. An odd count means the puzzle has no solution. Check this before searching. Otherwise the solver can run without ever reaching the goal, which can look like a hang.

The goal test does not match the board

Many bugs come from disagreement about the goal. One version places the blank in the top-left corner, while another places it in the bottom-right. Numbering may start from 0 in one part of the code and from 1 in another. Print the goal state and the board side by side, and confirm that the goal test checks the same layout.

A heuristic that overestimates

Heuristics such as Manhattan distance should never overestimate the moves left. If a heuristic does overestimate, A* may return a longer solution than the shortest one. This is a quality problem, not a crash, so it is easy to miss. A quick check: on a board that is one move from the goal, the heuristic should return at most 1. Types of heuristic search in artificial intelligence explains why admissibility matters.

Running out of memory

Breadth-first search stores every state it has seen, so larger boards run out of memory first. Use a heuristic such as Manhattan distance, or a memory-friendly variant of A*, instead of plain breadth-first search.

A debugging checklist

  1. Test the smallest case first: a puzzle one move from the goal, or a tile coder with a single tiling.
  2. Print the active tiles for two nearby states and two states far apart. Check that the pattern matches what you expect.
  3. Check the goal test and the heuristic on boards whose answers you already know.
  4. Lower the learning rate if the values grow without bound.
  5. Compare against a simple baseline, such as a plain table on a small problem or breadth-first search on a small board.

Also check the data your agent sees. If it visits only a small part of the state space, the tiles in the rest of that space never get trained, and no setting will fix that. Data coverage matters for any learning method. The general case is covered in why is data important for machine learning.

The complete guide to the tiles problem

The Tiles Problem in Artificial Intelligence
Read the guide

Keep exploring

Guides from other topics

All topics →