Is there any opensource 2d open-world simulation with python API?
You could try Mesa.

It has various examples that are commonly-used in agent-based modelling, like Epstein's model, a wolf/sheep predator/prey model, and many more.

There is also an introductory tutorial.