Rules for grids and multiple rows
A single row is easy — one “in this order” rule and you’re done. A grid needs a different recipe, because a grid is really two questions at once: which column is each object in, and which row. Here’s the pattern, using eight objects in two rows of four as the worked example.
The recipe
Pin the columns and the rows separately, using pairs of objects that are clearly apart on the axis you’re testing.
- Within each row, go left to right. Add A is left of B for each neighbouring pair: 1→2, 2→3, 3→4. That’s three rules per row, six for two rows. You don’t need 1→3 or 1→4 — those follow automatically.
- Between the rows, go top to bottom. Add A is above B for each column: top-left above bottom-left, and so on across. That’s four rules, one per column.
Ten rules in total for a two-by-four. The general shape, for R rows and C columns, is (C − 1) × R “left of” rules plus C × (R − 1) “above” rules — so a three-by-three comes to twelve.
That set is exact: with the ten rules above, the only arrangement of the eight objects that opens the lock is the intended one. Swapping two neighbours inside a row breaks a “left of” rule; moving an object to the other row breaks an “above” rule.
“Left of” and “above” compare the centre points of two objects, with no slack. So compare along the axis that actually separates them — “left of” for two objects in the same row, “above” for two in the same column. Asking whether one object is above another when they sit side by side in the same row is a coin toss that a little camera tilt will flip.
Don’t use one big “in this order” rule
It’s tempting to add a single in this order rule listing all eight objects along the horizontal axis. Don’t — it’s the one approach that looks right and isn’t, and it goes wrong in two different ways depending on how you list them.
Listed in reading order — the top row left to right, then the bottom row — the rule can never pass, not even on a perfect photo. It sorts purely by horizontal position, so it expects the fifth object to sit further right than the fourth; in a grid the fifth is back at the left margin. The lock simply never opens.
Listed column by column — top-left, bottom-left, then on to the next column — the rule is exactly right on paper and unreliable in practice. Two objects stacked in the same column have almost the same horizontal position, so which one “comes first” is decided by a fraction of a pixel of camera wobble. The same correct arrangement then passes or fails at random between two photos.
Keep “in this order” for what it’s good at: a single row, a single column, or any set of objects strung out along one axis.
Use “Test / play” and photograph the solved arrangement the way a player will. Then deliberately swap two objects and shoot it again — the lock should refuse it. If it opens anyway, you’re missing a rule for that pair. More in building your first game.