Algorithm of the game app