Résumé : The main issue in swarm robotics is to design the behavior of the individual robots so that a desired collective behavior is achieved. A promising alternative to the classical trial-and-error design approach is to rely on automatic design methods. In an automatic design method, the problem of designing the control software for a robot swarm is cast into an optimization problem: the different design choices define a search space that is explored using an optimization algorithm. Most of the automatic design methods proposed so far belong to the framework of evolutionary robotics. Traditionally, in evolutionary robotics the control software is based on artificial neural networks and is optimized automatically via an evolutionary algorithm, following a process inspired by natural evolution. Evolutionary robotics has been successfully adopted to design robot swarms that perform various tasks. The results achieved show that automatic design is a viable and promising approach to designing the control software of robot swarms. Despite these successes, a widely recognized problem of evolutionary robotics is the difficulty to overcome the reality gap, that is, having a seamless transition from simulation to the real world. In this thesis, we aim at conceiving an effective automatic design approach that is able to deliver robot swarms that have high performance once deployed in the real world. To this, we consider the major problem in the automatic design of robot swarms: the reality gap problem. We analyze the reality gap problem from a machine learning perspective. We show that the reality gap problem bears a strong resemblance to the generalization problem encountered in supervised learning. By casting the reality gap problem into the bias-variance tradeoff, we show that the inability to overcome the reality gap experienced in evolutionary robotics could be explained by the excessive representational power of the control architecture adopted. Consequently, we propose AutoMoDe, a novel automatic design approach that adopts a control architecture with low representational power. AutoMoDe designs software in the form of a probabilistic finite state machine that is composed automatically starting from a number of pre-existing parametric modules. In the experimental analysis presented in this thesis, we show that adopting a control architecture that features a low representational power is beneficial: AutoMoDe performs better than an evolutionary approach. Moreover, AutoMoDe is able to design robot swarms that perform better that the ones designed by human designers. AutoMoDe is the first automatic design approach that it is shown to outperform human designers in a controlled experiment.