completed basic function to play a game