A Self-Replication Basis for Designing Complex Agents