hilariously ugly Python implementation of the game logic with random AI