extract the game logic