Add 'detect-end function to indicate various end-of-game conditions.