Make sure exchanging coins around the world cannot create money
If three kingdoms each have their own coin and the rates are set one by one, a clever player can trade around in a circle and end with more than they started. Here is how to find such a loop and what fee closes it.
Why this works
Trading around a circle should never leave you richer, because that would make money out of nothing. Turning rates into sums lets a machine look for a circle that pays, and a small cut on every swap, larger than the circle's gain, makes the trick unprofitable.
When not to use it
Skip it when the player is meant to be a trader who finds clever deals and gets rewarded for it, or when trading is limited to one place and one direction. Then a profit loop is the game, so keep it small and slow.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- A diagram of every state
- 33 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 "Make sure exchanging coins around the world cannot create money" (read_entry currency-exchange-loop-that-prints-money) 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