Is it possible for a program to modify its own code?

4

I was developing an artificial intelligence program with neural networks, but what always made me embarrassed is that every time I open the program, it will have to repeat the whole course of learning to achieve the same result as before.

My question then is, is it possible for the program to modify its own source code and modify the values of the variables? If so, how?

Example:

My program terminates its execution with the variable count = 3 , so the next time it is opened, the value 3 to count will be assigned again.

Why not save these values to a file txt or xml ?

Because I wish anyone with no external files could use my program, where it left off.

    
asked by anonymous 08.07.2017 / 23:33

1 answer

8

First, you do not need to change the code to avoid repeating learning. I have no in-depth knowledge of AI, because it's a lot more complicated than people think it is, but I know that learning is not about generating new codes on their own.

If it were and could not change the code itself then it would be impossible to do this.

Then of course you can change the code itself. JITters do this all the time.

Even though this is available it would not be very difficult to make a mechanism that changes fonts and manages a new executable.

If you just want to change the executable, you also need to know where to put it. It seems like a lot of gambiarra.

  

My question then is, is it possible for the program to modify its own source code and modify the values of the variables? If so, how?

Variable values are changed all the time, so they take this name.

  

My program finishes its execution with the variable count = 3, so the next time it is opened, it will be assigned a value of 3 for count again.

Just persist the value somewhere, it is not necessary to change the code. Do you want to persist in the executable? You can, I do not think it is recommendable.

  

Because I wish anyone with no external files could use my program, where it left off.

This is not exactly changing the code itself, it is at most persist within the executable.

It is even possible to use resources to store these values since the desire it's just not having an external file, which I find a little necessary advantage.

    
08.07.2017 / 23:45