The beginning of the game works correctly.
Shortened code