Fixed a bug about the logic to judge if the game is over.