• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating a “world” for evolution of programs  RSS feed

 
okom ijin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a "world" where "copies of programs" are allowed to evolve, proliferate and fight for resources. Organisms copy information with errors and memorize the results. It seems like one can create a "world" with resources, place various copies of a program and let them fight for resources, grow and evolve.

What would it be for Java programs. World has cells each producing certain amount of letters per tic. An organism is a String of text that extends Life, compiles correctly, has methods eat, move and breed. Every tic move, eat, breed are executed. On move organism can decide to move to nearby cell. On eat it can move all free letters from cell to it's body (store those behind /* here */ to make sure program compiles). During breed stage it it can build it's own copy using letters from the commented area of the program body. Copying is error prone. If the resulting copy compiles it joins the race for resources.

Here are the problems I am having: A single character change in a program tends to cause compile time error. How to increase survival chances of an offspring with a point mutation? IRL organisms eat each other. How to model predator attacking prey? Some simple injectPoison(prey); that injects */ between 50th and 51st characters in the body of prey string would kill pretty much any program. Something like "to fight: run Robocode - winner gets all loser's letters" would turn the world into a Robocode engine competition. IRL organisms do exchange information. One can allow programs to exchange their methods, but then it is very tempting for a program to just inject a suicide method and eat the body of dead partner.

Which level of abstraction should I use? How to deal with "almost all mutations are deadly"?
 
Stephan van Hulst
Saloon Keeper
Posts: 7991
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An interesting aspect could be some sort of immune reaction. When a predator attacks a prey, the prey is given a chance to restore their program using the resources they already collected. That way, and organism has to make a choice between using resources to procreate, or saving them to heal themselves.

This is a really interesting idea, but it involves a lot of reflection and thinking time, so I fear for the speed of such a simulation.
 
Tim Moores
Saloon Keeper
Posts: 4034
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a fun and interesting project. Maybe rather than let Java code evolve (which might become uncompilable), how about Javascript code (which can be handled in Java using its built-in Javascript engine), or data (which could be interpreted as having a maybe numerical quality that determines whether it is more or less likely to procreate into the next generation).

You might also be interested in reading about the Axelrod tournaments in which algorithms executing prisoner's dilemma strategies competed against each other, with winners more likely to be around and multiply than losers.
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The idea is not new. For a very interesting experiment, Google for 'Tom Ray'  and 'Tierra'.
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may have noticed people describing Java as a "verbose" language, or if you haven't, take it from me that people do say that.

What that means in practice is that there's a lot of stuff in Java code which is not strictly necessary to describe the actual function of that code. So for every "unit of meaning" (I just made up that phrase to avoid getting into heavy math) in a piece of Java code there is a large number of characters. Unfortunately for you, changing any of those characters is unlikely to produce another "unit of meaning". In math terms, there's a space consisting of arbitrary strings of characters and the density of valid Java classes in that space is extremely small.

I suspect that the projects which Piet referred to used a space in which the density of, say, Tierra programs was not so small. (And perhaps their mutations were more targeted?) So switching to a language which is less verbose would be helpful. Perhaps Java byte code (instead of source code) would do better at being mutated, for example?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!