Use of findNearest with created objects - Python

First, I don’t see the reason for creating a set of coins within 25m, but if none then within 50m, etc. Why bother with all that?

Second, I didn’t try to figure out if the coordinate calculations are correct, but why not use vectors? The distance between two points (=positions, vectors) can be simply calculated with Vector.distance(A, B) where A and B can be e.g. something.pos or Vector(x, y)

OR

use the distance() method as explained here

Third, if you want to find the closest peasant (or whatever) to a specific coin, you could use the coin’s methods coin.distanceTo() and coin.findNearest()

Happy coding!