Spielerando

Grid Backpack

A grid backpack is a rectangle of cells where each item covers a rectangle of its own, so a long sword takes more room than a ring. An item can sit anywhere it is wholly inside and covers no cell another item covers. Placing, moving and turning are checked first and change nothing when they do not fit.

Also called: Grid inventory, Shape inventory, Spatial inventory, Packing puzzle bag.

A little frog porter watches as a long red wrench turns a quarter in mid-air above an open pack, a green outline showing the tall slot of grid cells where it will fit between neatly packed shapes.
Tessellume Depot, an invented isometric packing puzzle game. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Grid Backpack" to my game.

What it should do: Shape turns carrying into a puzzle. The player decides what to take, and also how to pack it, so a full bag is a question of fitting things together, not only of counting them.

Use these starting values:
- width: 8 cells
- height: 5 cells
- allowTurn: 1 0 or 1

Watch out for these common mistakes:
- An item blocked by itself: Tell your AI: when moving or turning an item, leave that item out of the overlap check.
- Half off the edge: Tell your AI: check the whole rectangle, the far edge included, not only the top-left corner.
- Room in total but not in one piece: Tell your AI: look for an actual spot where the whole shape fits. Say plainly that there is no room, however many cells are free.
- A failed move loses the item: Tell your AI: check the new spot first and only then change the item. Never lift it out before knowing it fits.
- Turning around the wrong corner: Tell your AI: keep the top-left corner where it is, swap the sides, and check the new rectangle in full.
- The same item put in twice: Tell your AI: refuse to place an item whose id is already in the bag.

Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

What it does

Shape turns carrying into a puzzle. The player decides what to take, and also how to pack it, so a full bag is a question of fitting things together, not only of counting them.

Good starting values

ValueStart withWhat it changes
width8 cellsHow many cells wide the bag is. Eight is wide enough to fit a long item beside a few small ones and still fit on a screen.
height5 cellsHow many cells tall the bag is. Five rows make forty cells, enough to hold a handful of mixed items while tight enough that packing matters.
allowTurn1 0 or 1With 1, an item may be turned a quarter, swapping its width and height. This makes packing kinder. With 0 every item keeps its shape, which suits items that must stay upright.

What usually goes wrong

An item blocked by itself

The player nudges a long item one cell to the right. Most of the cells it wants are the ones it already covers, so a check against every item, itself included, says the way is blocked.

Fix: Tell your AI: when moving or turning an item, leave that item out of the overlap check.

Half off the edge

The player drops a wide item with its corner on the last column. Only the corner cell is checked, it is inside, and the item hangs off the side of the bag.

Fix: Tell your AI: check the whole rectangle, the far edge included, not only the top-left corner.

Room in total but not in one piece

Four cells are free, but they are scattered. A game that only compares the free count with the size of the item says there is room, then fails to place it.

Fix: Tell your AI: look for an actual spot where the whole shape fits. Say plainly that there is no room, however many cells are free.

A failed move loses the item

The game lifts the item out of the grid to try the new spot. The new spot is taken, the code gives up, and the item was never put back.

Fix: Tell your AI: check the new spot first and only then change the item. Never lift it out before knowing it fits.

Turning around the wrong corner

A tall item is turned and the game keeps its centre. The item now sticks out past the edge by half a cell, or lands on cells that were never checked.

Fix: Tell your AI: keep the top-left corner where it is, swap the sides, and check the new rectangle in full.

The same item put in twice

A pickup arrives twice, or a drag is repeated. Two entries with one id exist, and removing one removes both, or neither.

Fix: Tell your AI: refuse to place an item whose id is already in the bag.

How to check it works

Works well with

Variations: Inventory System.

Common questions

what do i tell my ai to add a grid inventory

Paste this: Add a bag that is a grid of 8 by 5 cells. Each item covers a rectangle. An item may only be placed wholly inside the grid on cells nobody else covers. Moving and turning must ignore the item's own cells, and a failed action must leave everything exactly as it was.

why can't i move an item one cell in my grid inventory

The check probably counts the item's own cells as blocked. When you move an item, leave it out of the check, since the cells it covers now will be free once it moves.

how big should a grid backpack be

Eight by five is a good start. Make the biggest item about a third of the bag's long side, so it fits with room for others. If every item fits easily, make the bag smaller.

should items be allowed to turn in a grid inventory

Usually yes. Turning makes packing kinder, and the player does not feel stuck by an item that almost fits. Switch it off only when items must stay upright, such as long tools hung on a rack.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

Your AI gets the code

Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it