Principles of minimal cognition in smart slime molds and social bacteria