def play_game(state):
    while True:
        yield state
state = step(state)
initial = [(0, 0), (0, 1), (0, 2)]
game = play_game(initial)
ani = animation.FuncAnimation(fig, lambda : next(game))
plt.show()
анимация python без глобальных переменных