implement the judgement of gameover and clear