Sex Bots

robots in love
you’ll have to pardon me while i wax anthropomorhpic for a moment.  why is it that robots, designed or imagined, always exist solely to fulfill a purpose or pleasure for human beings?  don’t they have feelings too?  maybe it’s about time we made some robots whose sole purpose is to hook up with other robots, get a little freaky, and make some robot progeny.

in this article we’ll be exploring robot love.  i made a couple of simple lego mindstorms robots and programmed them to reproduce — i.e. they can swap code.  effectively, two robots come together, trade their genome, die, and two new robots are born in their place.

turn up the barry white.  get out your mindstorms.  let’s get it on.


when i started working on this project, i had to make some initial decisions about how robot reproduction would actually work.  since they can’t create a new robot, their reproduction will have to function a little differently than what we are accustomed to.

what i wanted was some mechanism that would enable two parent robots to combine their software to produce two distinct child robots, which would replace their parents and exhibit new and unique behavior.

the robots i am using are simple two-wheel, two-sensor bots.  in these bots, the genome will serve to determine the behaviors of the robot’s normal life processes, namely:

  • the robot’s primary execution loop

  • what to do if the left sensor is hit

  • what to do if the right sensor is hit

the genetic code determines what happens in each of these three tasks.  possible actions can be any combination of the following:

  • go forward

  • go backward

  • turn left

  • turn right

  • attempt to reproduce

  • do nothing

so a reasonable execution loop might be: forward, mate, forward, etc.

a left sensor loop might be: backward, right, right, etc.

getting it on
mating robots
each of the three life processes has a fixed length.  when the robot is turned on, these are initialized to a very basic routine and most of the possible actions are filled with noops.

when a robot attempts to mate, it sends out a signal on the ir port.  if the other robot is able to see this signal, it will initiate a handshake to begin the genome transfer.  the parents trade one piece of a routine at a time, replacing their former actionwith the new child program.

in order to deter child generations from becoming lazy, i added a requirement that a certain number of movements had to occur between each successful mating before they could become ‘mature’ and capable of initiating the mating procedure.


when two robots reproduce, each recieves a copy of the other’s genetic code.  the outcome for each possible action for each life routine is a random choice between the two parent codes.  this alone would result in some pretty booring children, given that both parents are initialized with the same code, so i added a roughly 1 percent chance that a mutation will occur for each action that is copied.

the idea is that a robot which is better capable of maneuvering around without getting stuck will have a better chance of finding another robot and procreating.

unfortunately, i only have two robots at my disposal, but the results have still been really interesting.  all sorts of different behaviors have cropped up, from robots that drive in big circles and zig-zags,  to ones that always go in the same direction when they hit something.

robotic extinction
in a small population, however, things don’t always work out for the best.  one of the robots pictured above mutated such that it didn’t turn when a sensor was hit.  the second robot managed to mate with it once, but then became plagued with the same genetic malfunction.  they were unable to get out of the corner and basically became extinct.

with a larger population, you would probably see fewer mass extinctions and more interesting group behavior.  with only two robots, they tend to have a nearly identical makeup in each generation.

one could imagine a larger colony breaking up into different classes — some robots that don’t move much and are easy to be found, and others that are good at wandering and spreading throughout the community.

if anyone out there has access to a bunch of mindstorms, give it a try and let us know about your results.

possible applications
aside from just being a simple and fun way to model life and evolution (not to mention a shameless title for an article), sex bots have some interesting potential applications.

robot optimization
when i released my robots for the first time, the software that i initialized them with was not ideally suited for the environment i placed them in.  occasionally they got hung up in corners, or moved around in continuous circles that would never intersect and allow them to see eachother.

with a small starter community, you could just turn them loose in their environment and let them run for a while.  they would genetically optimize their routine to fit their environment.  those that couldn’t find eachother would essentially become extinct.  the rest would adapt to maneuvering in their environment while maintaining communication.

automatic software updates
you could also pretty easily code in a version identifier.  when mating, a robot would check to see if they are from the same version pool as the other.  a previous version would adopt the new version in whole, whereas two robots of the same version would mate normally.  imagine a distributed, loose network of robots that need a software upgrade.  simply release a few robots with the new software and the population would eventually convert automatically to the new version.

your idea here
there are undoubtedly many ways to go about making a reproducing robot, and i’m sure there are many more uses for this technology that i haven’t even though of.  so go make your own sex bots and let us know about it!

84 thoughts on “Sex Bots

  1. ryan,

    that’s a really good idea. there’s an lcd built in, so i could display the generation info there. it would be nice to have it dump the current genome to the lcd as well.

    currently, i just use the lcd to debug the ir messages that are being sent between robots.

  2. i come to this site almost everyday, and this is the first “hack” i have seen that made me go “wow, that is really cool!” how about writing a small tutorial for those of us that don’t know what the hell we are doing? i would love to play with these and see what kind of upgrades i could come up with…

  3. if you had a message at the beginning stating how many bit of info would be soon transmitted, the receiving robot could say “hey, i missed something” (they would say it in binary, but that would be the jist of it) and the sending robot could repeat the message. a failsafe could be instrumented in case this first message was garbled or blocked, forcing the sending robot to resend the info.

    i hope i mead the clear enough, basically it’s a transmission stating the length of the message so the receiving robot could say if it got it all

  4. i’d like to see a bunch of mindstorm owners get together and do this on a mass scale – i’m talking 50+ mindstorms here, in a warehouse or something. maybe even start with two or three different code seeds – one could emphasize mobility, another brute force, etc.

  5. Whenever I considered the idea of robot “sex”, I always thought more along the lines of physical changes, not software ones. I figured that two robots would probably build their offspring from scratch, and that they could make offspring with the best tools and design elements of each parent. Of course, you couldn’t do that with Legos.

    That must sound strange, to say I’ve thought of robot sex before.

  6. Just a suggestion. For evolution to occur on such a small scale one would need to satisfy (imho) at least two conditions:

    1. A challenging environment, such as a simple hill or hallway between two boxes.
    2. Extinction.

    The reason for these conditions is that evolution needs to be promoted. If the bots have no challenge to reproduce, then there is no benefit to exchanging their genomes, hence a challenging terrain. There needs to be extinction, so that, again, evolution provides a benefit. If a bot is able to traverse the tunnel between two boxes faster and mate more often, then it will create better progeny, that will, in turn, reproduce more. To introduce extinction, just give the robots a time limit to pass on their genome, if they don’t find someone to mate with within ten minutes, or so, then their genome becomes erased, and they become idle and only receptive to mating. And, since their genome is empty, the mating will be strictly unidirectional, so that the new bot has the best available genome.


    “Kim Jong-Hwan, the director of the ITRC-Intelligent Robot Research Centre, has developed a series of artificial chromosomes that, he says, will allow robots to feel lusty, and could eventually lead to them reproducing. He says the software, which will be installed in a robot within the next three months, will give the machines the ability to feel, reason and desire.”

  8. IT would be very intereseting if someone tried this with very complex hardware (e.g. simple arms, a light sensor, etc.) and a more complex environment. Perhaps a box with a bunch of legos obstructing movement. And you’d need more than two robots. Anyway, it be a cool experiment.

  9. Interesting experiment. This is my first time through this site and i really liked this one. I am studying anthropology and thought of how such experiments could work in studying human populations. based on the biggest source of error in social science (human error ), in designing and studying for only basic functions (eg. finding and procreating with a mate), we can add layers of functions that would resemble the characteristics we wished to isolate.
    Of course the obvious fallacy to that in human studies is that you’re not studying humans. however, i think much insight could be gained if something like this was adopted by the larger science community.

  10. this is the most interesting project to build that I’ve seen on this site.

    it’s too bad i don’t have any lego mindstorms to try this out with. for those of you in the same situation as me, you could try writing a program that simulates the same thing. that method will allow much more robots, but probably won’t be as cool as watching them live.

  11. ~Reminds me of some of the genetic algorithm stuff the government is getting into (look genetic algorithm up on google….free government source code).
    ~How about after a robot doesn’t mate for a while (the dumb ones) the are reborn with a random algorithm. Then you wouldn’t need to much mutation. They keep mutating till they can mate.

  12. I’ve tested something like the Version update before. I simply coded a php script that would check the main SQL DB for an UPDATE table. The row would hold 2 rows, VER and DATA. Every few days, a unix cron job on the server connects to the master host ( for this program it was Using a encrypted user password it checks the sql rows for the the VER number.
    If the ver number on the server is greater than the one on the localhost, it will select all the code in the DATA row. This row holds a sepecal XML (or RSS) code, understood only by the update programe. The cron job runs again, 5 seconds after (to ensure all the code has finished transfering). It sends an email to the system admin, saying “Would you like to update?”. If the admin clicks “Yes” then the server reads the DATA row, reads what code needs to be written to what page. After that it just runs the code to apply it.

    NOTE: Opensource updating is hard because the user needs to read from the host, posing a security threat. This was seems to work pretty well. (And its PHP / MYSQL only, no need for any c++! YAY!)

  13. My only question is where would you run into problems? Such as, which robots wouldn’t be “matable” with others, or which genetic code lines wouldn’t be able to mix with another. Maybe it sounds like a stupid question, but it’s the same with living beings.

    For instance, dogs have a very large variety of breeds. You can take any two and create a different kind. On the other hand, a dog can’t mate with a cat, or bird. I wouldn’t want me defense robot mating with my refridgerator. Obviously, a smart coder wouldn’t allow for that interaction in the first place. But what about robots with similar applications to each other, but different equipments? I may be jumping the gun for current applications, but they’re things to consider if it’s going to take a larger role with robots.

  14. Interesting adaptation of classic alife ideas to hardware.

    Have you considered doing rapid evolution in a software simulation and moving some of the best candidates over to your hardware?

  15. The project looks great! This kind of work takes place at several universities. Often, the evolutionary model operates on a specification for a neural network (but not always).

    A good place to learn about this would be the course material for the Evolutionary and Adaptive Systems masters (University of Sussex, UK) I am currently taking. Perhaps start with the lecture notes for the Artificial Life course (
    Further academic papers can be found at or . One particular result from this work has shown that often, mutations seem to produce more useful results then sexual repoduction.

    Just to say again that the robots you have built look like a really good way to get into the Evolutionary Robotics field, so good luck with it!

  16. Correct me if I’m wrong, but it seems that while your robots do use mutation and recombination, you don’t seem to have any fitness criteria, and therefore no selection based on fitness. If you let the robots measure some property of their behaviour (such as how far they had actually moved, not just tried to move, using a Lego rotation sensor attached to a trailing wheel) and assign themselves fitness based on that, you could then let the fitter robot contribute more to the genome of the less fit than vice versa, and so get evolution with fitness-based selection.

    A robot that didn’t find anyone to mate with could also revert to a saved earlier version of it’s control program, to avoid robots getting stuck in corners.

  17. Going back 2 comments, I think that it should be addressed that Dogs are all the same species, allowing them to spawn viable offspring, hence the definition of separate species. If you wanted to reaaaallly get some results, what you would do would be to allow for speciation by allowing for extremely minor changes over broad generations (ie: variable1 can be 1,2,3 but it can’t be 4, and those definitions only work with variable1, however there may be connected variables which tend to trade together, equal chances that each “sexbot” will pass on given variable data). Given that all of the robots begin as 1 species (they can all reproduce w/ each other), allow them to reproduce more in a chromosomal trade pattern; having each phenotype (expressed code in offspring)be defined by a combination of the two bots would also be nice (think bio101 and punnet squares) You would allow for 2 or more types of mutations (ie: altering a variables data to a new, unowned definition; change in variable use, action). Etc, etc. You all get the idea.

  18. Very interesting project here. I wonder, if you could do a hybrid simulation/actual robot approach. You only have two robots, but you could keep a list on a larger computer system of all the genomes in the current population. You could then test each one on the robot hardware at a time and use that as a basis for mating the software. So you could sort of simulate a population with only one or two actual robots. May not look as cool, but its something you could do.

  19. Two things:
    1) I think you’ve found why small breeding populations and inbreeding are bad.

    2) A way you could extend your experiment is to hold a population of ‘entities’ on your computer, and send two at a time to the physical robot bodies for selection in their environment. The mating/combination itself doesn’t have to be done within the robots themselves – only the evaluation of performance within their environment. The rest can be handled by a larger master computer/software.

  20. I cant help but feel this would be great for computer games.
    Computer AI is terriblly dumb. But say for example in a racing game you started with eight different AI car drivers. You race them in 2 races of four and only the winners produce eight children to start the next generation.
    Mabey this could be aplied to MMORPGS? Only alowing the monster AI that kills the most humans to reproduce.

  21. Really nice project. Now the only thing to wait for is that they build each other from scratch ;) getting real childs in other words. With lego that wouldn’t be completely inpossible.

    On a sidenote – think about making small robots with for example Basic Stamp. Make these robots have Wireless Network and make use of the gnutella protocoll or something and you have a efficient way of communicating :)

  22. I cant help but feel this would be great for computer games.
    Computer AI is terriblly dumb. But say for example in a racing game you started with eight different AI car drivers. You race them in 2 races of four and only the winners produce eight children to start the next generation.
    Mabey this could be aplied to MMORPGS? Only alowing the monster AI that kills the most humans to reproduce.

  23. wow, very neat project. i have access to about a dozen mindstorm kits (work at a private school) and would love to see the results of this code implemented en mass. please let us know if you ever get a DIY up. thanks!

  24. Interesting. I have used genetic algorithms to do effective searches for square roots. Worked wonderfully.

    Several comments on your project. You need a goodness criteria. Just surviving mating is what you have but you may want something more but that is a base level one and the one evolution uses. You might add something like power gathering efficiency or something that would improve chances of surviving and mating.

    As to the parent child thing. A successful pattern on mating will give move offspring and increase the odds of surviving the next generation. Since you kill your parents each mating any existing pattern that might be successful is lost. So the evolutionary model you have is missing that multiplying factor for success. So you are working with a slightly different model than evolution but that may be good and may have the power to evolve in a different way. Who knows aliens that come to visit us may evolve in this way.

    You could however with a small set of bots start with some in reserve and when two mate, the reserve ones get the new programming. When bots become extinct (add an aging factor along with a health factor say, or criteria for deadly behaviour or unsuccessful prgrogramming) they go back into the pool to recieve the next re-incarnated child program. You could have some outside cache for these programs that came from the mating and a way to incarnate children from the pool of waiting bots.

    Sounds good. Would like to see you code. I have about 5 bricks myself.

  25. the robots should mate according to the other robots’ charateristics. Such as one robot liking only robots with certain type of genes. Just like with people and physical features except it won’t be physical features to the robots of course.

  26. superb! i would love to see your program. i may see if i can get a reasonable approximation of this up and running in robolab so i can do it with my class–i am going to be running a program in bot-to-bot communication this august and have been looking for some good advanced project ideas. we’ll have about 30 bricks available, so it should be interesting! (if it doesn’t turn out to be above all of our heads)

  27. superb! i would love to see your program. i may see if i can get a reasonable approximation of this up and running in robolab so i can do it with my class–i am going to be running a program in bot-to-bot communication this august and have been looking for some good advanced project ideas. we’ll have about 30 bricks available, so it should be interesting! (if it doesn’t turn out to be above all of our heads)

  28. very nice! Now let us try to make the bots react to changes in environment, e.g. start in a round pen, see how their movements get optimized for that area, then change the area into an oblong one, either abruptly or slowly, and see if the robots evolve into the optimal pattern for that area. I will certainly steal your idea for my AI classes!

  29. How exactly is winning defined there? Winner mates with looser and “mates with” is comutative relation, so success doesn’t count. Maybe you should set computer ir port up as third, “virtual” mate? Like, both bots have a number of tasks to perform in order to get to the “procreation pod” (computer ir port). Each time, both bots upload code snippet used (or critical) for accomplishing that task. At the end of all rounds, both bots get to the pod and download random combined snippets, with “winner genes” having set greater probability for download then “losers”. You can introduce “mutations” as you already did.

  30. Well I’m going to say this even though I’m not sure what sort of state information you can track on this machine, but, in order to make extinction a more compelling end you may want to program in a death interval.

    That is, a machine has a mean time to failure, which is added to some smaller random interval so all machines don’t have the same lifespan. Upon expiration it reinitializes itself with some other code (ie, it is reincarnated) and then goes out again. Of course, if the machine mates, it resets the counter.

    That way failing to mate within a specific time means that you are removed from the gene pool and you make way for another genetic combination. What do you think?

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.