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

Asked

Viewed 386 times

4

I was developing an artificial intelligence program with neural networks, but what always left me chained is that every time I open the program, it will have to repeat the entire learning path to get 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 finishes its execution with the variable count = 3, then the next time it is opened, the value will be assigned 3 for count again.


Why not store these values in a file txt or xml?

Because I wish that, anyone without external files, could use my program, from where it stopped.

  • 1

    A compiled program modifies its own source code? If it exists, I want to learn how to use :p

  • If you don’t want external files, you can use webservice, cloud, something online. Now if it can’t be online, ai complica.

  • Yes, I would not like to use anything online, because, the environment in which I will use this code, nor have access to internet.

1 answer

8


First, you don’t need to change the code to avoid repeating the learning. I have no deep knowledge about AI, because it’s a lot more complicated than people think it is, but I know learning isn’t about generating new code on your own.

If I 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. The Jitters do it all the time.

Even if this is available it would not be too difficult to make a mechanism that changes the sources and generates a new executable.

If you just want to change the executable gives also, you need to know where to put it. It seems to me a lot 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?

Values of variables are changed all the time, so they carry this name.

My program finishes its execution with the Count = 3 variable, so the next time it opens, it will be assigned the value 3 to Count again.

Just persist the value somewhere, there is no need to change the code. Do you want to persist in the executable? Can, I don’t think it is recommended.

Because I wish that, anyone without external files, could use my program, from where it stopped.

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 wish is just not to have an external file, which I find a little needed advantage.

  • Hotswapping has something to do with it too?

  • If that’s what I’m thinking, no.

  • I’ve never heard of a Windows program being able to modify the features built into it; the Resource API seems to me completely read-only. Will be some change from Vista?

  • @Wtrmute did not say it has API for this, it has how to modify. It is brute force. I speak until it is gambiarra.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.