Weight Limit
A weight limit gives everything the player carries a weight and lets the total slow them down. Up to a comfortable load there is no cost. Past it, speed falls steadily down to a floor, and at the hard limit nothing more can be picked up. A pickup that only partly fits takes what fits.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Weight Limit" to my game.
What it should do: Weight makes carrying a choice without a fixed number of slots. The player can take one more thing and move slower, or leave something behind, and the cost is easy to feel and easy to read.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> light
light: Light load
burdened: Burdened
full: At the limit
light --> burdened: picks up past comfort
light --> full: picks up to the limit
burdened --> light: drops below comfort
burdened --> full: reaches the limit
full --> burdened: drops a little
full --> light: drops a lot
```
Use these starting values:
- capacity: 100 weight units
- hardLimitPercent: 150 % of capacity
- minSpeedPercent: 30 % of full speed
Watch out for these common mistakes:
- Something that weighs nothing: Tell your AI: if the weight is zero, take them all. Only divide when the weight is above zero.
- Decimals add up wrong: Tell your AI: keep weights as whole numbers, for example in tenths, so the total is exact.
- The limit drops while carrying: Tell your AI: the room left is never below zero, the speed never goes below the floor, and dropping always works.
- Only part of a pickup fits: Tell your AI: take as many as fit, round down, and report how many were left behind.
- Slowing down in steps: Tell your AI: fall in a straight line between the comfortable load and the hard limit, so each extra item costs a little.
- Exactly on the line: Tell your AI: up to and including the comfortable load is light, and use the same test everywhere.
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
Weight makes carrying a choice without a fixed number of slots. The player can take one more thing and move slower, or leave something behind, and the cost is easy to feel and easy to read.
How it runs, as a diagram
Everything it can be in, and what moves it on. Your AI builds from exactly this.
How it runs, as a diagram
- Light load → Burdened: picks up past comfort
- Light load → At the limit: picks up to the limit
- Burdened → Light load: drops below comfort
- Burdened → At the limit: reaches the limit
- At the limit → Burdened: drops a little
- At the limit → Light load: drops a lot
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| capacity | 100 weight units | The comfortable load. Up to here the player moves at full speed. A round hundred makes percentages easy to read, and small items of weight 1 to 10 then show up on the load. |
| hardLimitPercent | 150 % of capacity | How far past the comfortable load the player can go, as a share of it. Half again lets a player grab one more thing and feel it. At 100 there is no slow band, so the player is either free or stuck. |
| minSpeedPercent | 30 % of full speed | How fast the player still moves at the hard limit. It is never zero: a player who cannot move cannot walk to a chest to put things down, and the game seems to hang. At 100, weight has no effect on speed. |
What usually goes wrong
Something that weighs nothing
A note or a key weighs zero. A pickup that works out how many fit by dividing the free room by the weight divides by zero, and the game either takes none or takes an endless number.
Fix: Tell your AI: if the weight is zero, take them all. Only divide when the weight is above zero.
Decimals add up wrong
The player picks up thirty feathers that each weigh 0.1. Added one at a time, the total comes out a hair above or below three, and the game decides they are over the limit.
Fix: Tell your AI: keep weights as whole numbers, for example in tenths, so the total is exact.
The limit drops while carrying
A strength bonus ends while the player carries 140 with a new capacity of 40. The room left is a negative number, and the speed formula gives zero or less, so the player cannot move at all.
Fix: Tell your AI: the room left is never below zero, the speed never goes below the floor, and dropping always works.
Only part of a pickup fits
The player stands on twenty gems and has room for four. A game that refuses all twenty makes the player pick them up one by one. One that takes all twenty ignores the limit.
Fix: Tell your AI: take as many as fit, round down, and report how many were left behind.
Slowing down in steps
Speed drops from full to half the moment the load passes the comfortable line. The player feels a cliff and picking up one more herb suddenly costs half their speed.
Fix: Tell your AI: fall in a straight line between the comfortable load and the hard limit, so each extra item costs a little.
Exactly on the line
A load that equals the comfortable load exactly is treated as over it in one place and under it in another, so the speed and the state disagree.
Fix: Tell your AI: up to and including the comfortable load is light, and use the same test everywhere.
How to check it works
- A comfortable load of 100 and a hard limit of 150. you carry 0, 100 or 101: speed is full at 0 and at exactly 100, which is still light, and a load of 101 counts as burdened.
- A comfortable load of 100, a hard limit of 150 and a floor of 30 percent. you carry 110, 125, 149 or 150: speed is 86, 65, 31.4 and 30 percent of full.
- A player carrying 140 whose comfortable load drops to 40. you check the speed, try to pick up one more, and then put ten down: speed is the 30 percent floor, the pickup is refused, and putting things down works.
- A player carrying 120 and ten gems of weight 7 on the ground. you pick up the gems: four are taken, because 30 free divided by 7 rounds down to 4, six are reported left behind, and the player is burdened at 148.
- A player carrying exactly 150. you try to pick up one more thing of weight 1: it is refused and the load stays at 150.
- A player carrying exactly 150. you pick up 500 notes that weigh nothing: all 500 are taken and the load stays at 150.
- A player carrying 30 ore of weight 5, a load of 150. you put down 12 ore: the load is 90, the player is light again, and 18 ore remain.
- A player carrying 4 ore. you try to put down 5 ore, or an item you do not carry: nothing changes.
- A player carrying 4 ore of weight 5. you try to pick up 1.5 ore, an item with a weight of a tenth or minus 2, zero items, or an item with no name: each is ignored and the load stays at 20.
Works well with
- Item Stacking: A pickup may be cut short by weight, by slots, or by both. Report the smaller amount that fits. Check the weight for the whole pickup first, then let the stacks take what is allowed.
- Equipment Slots: Otherwise putting on heavy armour seems to lighten the player. Count worn items together with the bag, in one total.
- Stamina System: Decide on purpose whether weight slows movement, drains stamina, or both, and not by accident. Work out the weight first, then let it scale how fast stamina drains.
Variations: Inventory System.
Common questions
what do i tell my ai to add a weight limit
Paste this: Give every item a whole-number weight. Full speed up to 100, then speed falls in a straight line to 30 percent at a limit of 150, and nothing more can be picked up there. A pickup takes as many as fit and reports the rest. Dropping always works.
how heavy should things be in a game
Pick weights that make the player think about the biggest items first. If a sword is 10 and a potion is 1, the sword costs ten potions. Start with a comfortable load of about a hundred and adjust until the player has to leave something behind.
should too much weight stop the player completely
Slow is better than stuck. A floor on the speed keeps the game playable, and the player can always walk to a place to put things down. A hard stop is fine for the pickup, but not for movement.
why use whole numbers for weight
Small decimals add up with tiny errors, so a total that should be exactly the limit comes out a hair over or under. Counting in whole units, such as tenths, keeps every comparison exact.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 14 tests pass on the reference code.
- The state diagram was checked against the code, at the default values and at every listed low and high value.
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