Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Mutating Programs

This thread is locked; no one can reply to it. rss feed Print
Mutating Programs
Billybob
Member #3,136
January 2003

I thought I should finally just say it.

A couple of months ago, maybe half a year to a year ago, I made what I call a Progranism (cross between the words Program and Organism). The point of the program was to prove my theory that a program could mutate and show signs of evolution by doing so. The project was a success, mind you.

It took several tries before I got a good version of my Progranism. The final version is a win32 app, if I remember correctly. Here is what it does:

1. On run it waits 60000 milliseconds (1 minute)
2. It then creates two copies of itself in the same directory.
3. As it reads through its own file and outputs to one of the copies, it has a 10% chance of making a mistake(mutation), either adding, removing, or changing a byte of machine code. There is also a 1% chance of 2 mistakes.
4. It runs the two new copies, and shuts itself down.

The first "lab" computer I used was not prime feasting grounds for my baby Progranisms, so I switched to a rather decent Win XP computer. The babies grew into ugly, but cool, mutants.

So, what exactly went on? Well, of course the Progranisms multiplied, the system would always max out at 800 processes because then the number of Progranisms being added was equal to the number being removed, due to the ever decreasing CPU power per Progranism. After about 2 hours of running the Progranisms I'd do a cold shutdown, i.e. unplug the comp. The folder with the Progranisms would often have 10,000+ files. I'd find the 800 most recent, non-empty Progranisms, delete the rest, and run what was left.

These tests went on for a long time before I eventually stopped for whatever reason. By the time I had stopped though, the Progranisms had gained some amazing abilities. They now created 3 copies, and multiplied every 10 seconds instead of the original 60. You can see how that was a problem for my computer, heh. Even more amazing was that they had learned how to kill each other...a bit brutal, but they did it. They would delete other Progranisms in the folder, don't ask me how they did it, but they did, and I was fricken amazed when I noticed that they were doing that.

I'm sure they are doing WAY more things, but it's not like I can watch the computer process their code, so a lot of what they do is hidden from me, heh.

They also increased in file size several bytes, I can't remember how many, but it was a fair amount. OH, and one time, a Progranism found its way to my Desktop :) didn't work though, was what I call a defective Progranism :-\

So, besides this being a really cool project, I think it can also benefit games. How about mutating AI? Create some sort of "Tactical code" and have that mutated, favoring AIs that can score the most points.

So, after this long post, what do you gals/guys think of what this freakish idea? Want to try some Progranisms out for yourself? If anyone is interested I have both the source code I used to make the original Progranism, and I have a set of 800 Progranisms from the last "batch" that was run. OH and I have a couple of Progranisms from my enlargement tests where I tried to breed a Progranism that would grow in file size as fast as possible. So, if anyone here is interested, just ask and I'll whip up a zip file for ya'll.

NOTES:
One thing I should mention is that Progranisms are !DANGEROUS! They mutate their machine code, hence they can do all sorts of things, and overwhelm the system with dieing processes. Occasionally I had to use the Win XP disc to boot and run a scandisk, because Win XP would error on boot :(. This is why I used a "lab" computer that didn't have important stuff on the HD. That and the Progranisms will likely shorten the life of your HD.

OH, and you may ask why I'm posting about this NOW that it had been like half a year...well...cause I wanted to make a safer and cooler Progranisms 3D game, basically giving the Progranisms a 3D environment to play in...but I have other projects I got to do, so I decided to just let the secret go.

Another Note: I'm not sure this is the right area to post in...seems like it, I mean it is a Game Concept, it isn't exactly Programming related, and since it is a game concept, I don't think it belongs in Off-Topic ordeals...any who, don't yell at me if it's not in the right spot please.

X-G
Member #856
December 2000
avatar

That is incredibly cool - it's basically Darwinian evolution applied to machine code. :)

I wanted to do a project like this, but I never got around to it.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

CGamesPlay
Member #2,559
July 2002
avatar

NICE!!!

Anyways, in practice, just use a simulated GA using your own VM instead of dangerous machine code. Maybve have them modify their LUA source like that. BTW, that is NOT a good idea for a game AI, randomly doing stuff like that.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Billybob
Member #3,136
January 2003

Well, in the case of AI, of course the concept would need to be advanced more so it doesn't do crazy stuff, heh, but it isn't like it COULDN'T be applied. Also, once Progranisms are taken away from the machine, and attached to a virtual machine, they lose some important concept features, like being able to hack into a fellow Progranism...

X-G
Member #856
December 2000
avatar

Quote:

once Progranisms are taken away from the machine, and attached to a virtual machine, they lose some important concept features, like being able to hack into a fellow Progranism

Then you need a better VM. ;)

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Billybob
Member #3,136
January 2003

true......anywho...it's cool watching my computer choke on Progranims, hehe, that and, how would they ever gain the ability to spread across a network if they are stuck inside a VM? I'm dumb!

CGamesPlay
Member #2,559
July 2002
avatar

If it was supposed to be anything biological, they can't just kill others. But maybe have them all running in one script space?

Have you read on GAs? You basically make a tree of all your statements (or the machine code, but not as effective), like an if node with a true node and a false node, then mutate them by taking one random section and putting it onto another:

      p1          p2
       |           |
      s1          s2
      /\          /\
    s3  s4      s5  s6
     |  /\      /\   /\
    s7 s8 s9  sa sb sc sd

Then to mutate, pick two random nodes, say s3 and s2, and interchange them:

      p1          p2
       |           |
      s1          s3
      /\           |
     |  s4        s7
     |  /\
     | s8 s9
    s2
    / \
   s5  s6
  /\   /\
sa sb sc sd

It leads to things working more properly more often :)

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Billybob
Member #3,136
January 2003

interesting....anywho. The one thing I'd like to do is take out the extra junk in the EXE, like error messages and fluff that MSVC puts in there. That was the mutations are more likely to hit the core code, instead of the fluff.

X-G
Member #856
December 2000
avatar

Compile it to pure machine code and have it be a .com file.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

kazzmir
Member #1,786
December 2001
avatar

Thats really cool, but it seems like you would have to change more than one byte of a program for it to have an effect AND have the program still work. Also it seems like 99.9999% of the programs wouldnt work correctly. Are you just changing one byte every pass?

X-G
Member #856
December 2000
avatar

Quote:

Also it seems like 99.9999% of the programs wouldnt work correctly.

That's a basic principle of evolution - quantity over quality. ;)

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Billybob
Member #3,136
January 2003

you'd be surprised how much EXE can take before it chokes on itself, heh. Course, I'm sure a lot of the mutations are hitting the "fluff", but the mutations worked, cause the progranisms started deleting files...

X-G
Member #856
December 2000
avatar

It's dangerous letting them run wild like that, though; what if one of them suddenly develops the ability to erase your MBR? You'd be pretty screwed then. ;)

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Billybob
Member #3,136
January 2003

MUWHAHAHAHAHAHA, and so would they, I'm dumb!. Accually, Win XP might protect the MBR? Or maybe I should run them under a non-admin account...that'd be safe.

gnolam
Member #2,030
March 2002
avatar

And suddenly one day, Skynet is born ;)

Interesting idea to meddle with the executable itself instead of the source code :)

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Billybob
Member #3,136
January 2003

messing with the source code would be hard? sorta...computers aren't usually good at understanding languages other than machine code :) I'm dumb!. and about skynet, the Progranims are working on it, they said they'd be done by tuesday next week. ;D

gnolam
Member #2,030
March 2002
avatar

So when two of your Progranisms create another Progranism, do they get a Prograsm? ;D

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

X-G
Member #856
December 2000
avatar

It would be interesting to run these in a controlled environment (i.e. a VM) for a while and see what happens, which ones survive and which don't, etc ... and possibly use those conclusions to draw some more conclusions regarding evolution in general?

I think we would find that the winners are the ones that cheat. ;)

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Kanzure
Member #3,669
July 2003
avatar

Kick a.s.s idea! I bet this can be done for AI, maybe a "brain" class / neural net that is virtual, that can be screwed up?

Quote:

1. On run it waits 60000 milliseconds (1 minute)
2. It then creates two copies of itself in the same directory.
3. As it reads through its own file and outputs to one of the copies, it has a 10% chance of making a mistake(mutation), either adding, removing, or changing a byte of machine code. There is also a 1% chance of 2 mistakes.
4. It runs the two new copies, and shuts itself down.

Were the chances rand()? Or were they just because machines now a days suck? ^_^

EDIT

How long did it take to write the program? I sure as hell would love to write something like this..Maybe you can give me a basic outline? I mean, how in the hell did it move one to the DESKTOP?

EDIT2
On second thought, can you post the source code here? We could all bennefit from something like that...;D pweaze?

Quote:

And suddenly one day, Skynet is born

;) Thats the plan :)

Billybob
Member #3,136
January 2003

rand(), I'm dumb!, computers don't make mistakes, coders make mistakes, hehe. It's rather easy to code, I made the first one rather quickly, but the final product took awhile, cause I had to keep running back and forth with diskettes between the main comp and the lab comp.

It got on the desktop cause one of the progranisms got a mutation in its code and truncated the path(the Progranisms folder is on the desktop). Course, the mutation failed :'( OH, I forgot to note a mutation. I coded in an anti-biotic in the Progranisms so if the file Progranisms.AntiBiotic exsists, the progranisms will stop having babies :) Well, took them awhile, but eventually a strain came about that was immune to this and now they are ALL immune, muwhahahaha. funny stuff.

Korval
Member #1,538
September 2001
avatar

Quote:

Kick a.s.s idea!

Like most really good idea's, someone else beat you to it. Look into Artificial Life AI algorithms.

Kanzure
Member #3,669
July 2003
avatar

Hmm? Can you post source code? I don't know how I would run the exes I'm dumb!..I wanna try a project like this...hmm..I see a future: Randomly Generated Computers ^_~

Billybob
Member #3,136
January 2003

I'm uploading the zip file containing the latest progranisms from the standard run and the enlargement tests, but it's a big file so will take a minute. In the mean time: [url http://www.cljy.com/~billy/Progranism Source.zip] That's the source code...now that I look at it, I did some crazy stuff in there...anywho. I'll edit back the other url to the progranisms.

psundlin
Member #175
April 2000

Things like this is really funny! :)
I did some genetic programming stuff a couple of years ago. Nothing like this. I tried to make my small "organism" to calculate PI. Of course they cheated. :)
But it wasn't a serious attempt. Just wanted to try it out a little.

I was on a demo party some months ago and one guy talked about this. He also showed some videos of 3d organism trying to walk. Very interesting.

Kanzure
Member #3,669
July 2003
avatar

Yes..Very crazy. Is that for MSVC++?



Go to: