Load a cart that has both a weight limit and a space limit
Hay is light but bulky, gold is small but heavy. Sorting by price per kilo fills the cart's space with hay and leaves it nearly empty of value. This entry ranks goods by how much of the cart they really use up, and loads in that order until neither limit is left.
Why this works
Whatever limit runs out first decides what a cart can really carry. Judging each good by the bigger of its two shares of the cart, instead of by price per kilo alone, follows the limit that actually binds, so the load holds the most value it can.
When not to use it
Skip it when the player should pack by hand, as in a game about clever packing, or when only one limit exists. With a single limit, plain value per unit is enough. For a rare, exact answer, try every combination instead.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- 26 lines of example code with 3 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Load a cart that has both a weight limit and a space limit" (read_entry load-cart-weight-and-space-limits) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP