I wonder.. do you really need the code to be *self* modifying?
I mean, in terms of solving the problem of automatic code improvement, there are two directions you can go.
1, Have some 'candidate' code, which is the code you want to modify and improve, and then have some 'supervisor' code which manages the candidates. The 'supervisor' code is in charge of actually performing the modifications. In the example of a genetic algorithm, the 'supervisor' code is what stores a bunch of candidates and their fitness values, and then performs mutations and crossovers and stuff. The 'supervisor' code doesn't modify itself.
2, Have the code itself initiate the code modification operation, on itself.
Both approaches solve the same problem. It sounds like you really want to implement #2. But #1 is far easier and more effective to implement.
#2 is actually very limiting. Like you pointed out, it's very hard to write a piece of code that can safely iterate over itself. You end up in a weird holistic world, where you can't change one line of code because it mysteriously breaks a piece of code 10 lines above it. So there are certain operations you just won't try to implement.
Whereas with the #1 approach, the sky is the limit on which code modification operations you want to use.
I think a good analogy is brain surgery. Is it more effective for someone to perform brain surgery on themselves, or for someone else to perform it?
One thing to point out.. you can certainly write the system so that the code itself can *influence* how the modification takes place. One example, I experimented with using the ? mark as an operator in Circa. You could put it after a value or function, and that would be a signal to the modification code that it should favor making changes to that thing instead of other things.
Self-replicating, self-modifiying scripting language
Quote:
Sure. But would that be easy? If self-replicating behavior is part of the organisms, you probably don't want to have a thousand-page program that does nothing but replicate.
But I don't want to have a quine. A quine is only able to replicate its own exact structure. If you change a quine slightly, it no longer works. It couldn't for example have a robust self-replicating system that accomodates parts that might be changing.
A quine is like a crystal that repeats its own structure. The self-replicating scripts I wanted to make would be more than that.
Also, a quine can't have any other functionality besides outputting its own code. The scripts I wanted to make would be able to have any functionality besides replication (this is what those 'accomodated parts that might be changing' would be).
And a thousand-page program is very big, but several pages would be good to give the organisms some complexity and create some interesting things (in terms of variety, processes, evolution).
Quote:
I wonder.. do you really need the code to be *self* modifying?
The self-replicating scripts would also have to be self-modifiable.
If the scripts can traverse their own structures and assemble the same structures based on this, where there is no built-in difference between 'this' script and 'that' script (like in CoreWars/Tierra), then there's no reason why the scripts can't self-modify too.
I think they might evolve to take advantage of the ability to self-modify. It might allow for them to have a smaller self-replicating size that uses self-modification 'shortcuts' during the self-replication process. But I have no idea how it could do this, so that's just daydreaming about what it might be like.
And maybe there could be 'parasitic' scripts that parasitize another script's replicating machinery (like in Tierra).
And the self-modification isn't for just self-improvement (or evolution, as mutation would not be done by the organisms on themselves). But I don't know the ways that the scripts might evolve to use self-modification. I would have to have written the self-replicating script to know this.
[edit]
Quote:
Sure. But would that be easy? If self-replicating behavior is part of the organisms, you probably don't want to have a thousand-page program that does nothing but replicate.
And no this wouldn't be easy to have this non-directional jumble of inter-connected instructions, but it is necessary for the interesting results I want to create.
I am basically taking CoreWars/Tierra and making it so that the self-modification/code-manipulation-within-the-program does not depend on the expression of the code but that it is able to functionally change it, and has high level functions and variables unlike in CoreWars/Tierra.
[Edited by - polyfrag on April 1, 2009 10:35:14 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement