The max possible number is determined using brute force indeed. when you think about it, there are not that much possible configurations (for a computer at least)
And yeah, the game can get quite laggy in endless 😬
Thanks for trying out the game, really happy to see you liked it!