AI now checks for end-of-game conditions