implemented endgame