Spielerando

Choose the order to collect several pickups with the shortest total walk

Always going to the nearest coin next seems natural but leaves the last ones far away. Here is how a game computes the best order for a handful of pickups, with the real walking distances through the level, and when to give up and use a rule of thumb.

Why this works

Always taking the nearest coin leaves a stray one for the end and a long walk back. Comparing whole orders, with the real walking distances between each pair, finds the one that is truly shortest, which is affordable as long as there are only a handful.

When not to use it

Skip it when there are many pickups, because the number of orders explodes. Take the nearest one and improve it. Also skip it when pickups appear or move while you collect, since the plan is out of date after the first change.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • 48 lines of example code with 5 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "Choose the order to collect several pickups with the shortest total walk" (read_entry collect-all-coins-in-the-best-order) 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