We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Self developing Programms
Page Index Toggle Pages: 1
Self developing Programms (Read 2288 times)
Self developing Programms
Jul 4th, 2009, 10:42am
 
Hi folks,

is it possible to write a programm with processing, that changes its source code and runs the changed version of itself?

if yes... how can I do this? Tongue

thanks for your answers
Re: Self developing Programms
Reply #1 - Jul 4th, 2009, 11:15am
 
I recall somebody asked that some time ago.
Basically, you cannot: Processing uses Java, which is not interpreted but compiled. You have to get the compiler to do that.
Well, actually, you can do that (after all, Processing is a Java program that compile Java), but it is less than trivial and I am not sure it is worth the effort...
An alternative is to generate directly the bytecode, which is a magnitude harder... Smiley (and not what you ask).
Or use an interpreted language for the JVM, some of them (JRuby, JPython, etc.) have a Processing Implementations.
Re: Self developing Programms
Reply #2 - Jul 7th, 2009, 9:56pm
 
While it is possible with Java, it is definitely not simple.
I would recommend something along the lines of defining a set of functions and generating sequence of calls to those functions (a switch statement and a function ID, perhaps).

But... if you want to look into it:
http://en.wikipedia.org/wiki/Javassist
(there are other links on that page)

You might also look up custom class loaders.
Re: Self developing Programms
Reply #3 - Jul 9th, 2009, 8:21am
 
this topic somehow reminds me of oldschool viral polymorphic engines: giving a look at the old virer ezines could certainly give you lots of ideas of a how a program can change itself. hardcore skills needed, anyway Smiley
Re: Self developing Programms
Reply #4 - Jul 12th, 2009, 10:42pm
 
Hi domi,

sure, it is possible to create self-modifying code. In what context do you want to create a program?

Regard, Mario
Re: Self developing Programms
Reply #5 - Jul 21st, 2009, 2:16am
 
I would like to create some semi-intelligent creature Tongue just for fun and maybe to put it on my portfolio-page so the visitors can play around with it a little bit (or so Cheesy )


But I think it would be able to solve in JavaScript isn't it?
Havn't had much time to test it Sad
Re: Self developing Programms
Reply #6 - Jul 21st, 2009, 2:21am
 
I don't get the JavaScript part.
But well, to reach your goal, you don't need to have self-modifying code. Sure, some people did that in Lisp, for example, which is well suited to this usage (it processes lists and programs are lists too...).
But in Java, you would more rely on evolving data in a well defined set of classes.
You might also want to read on neural networks, they are well suited to self-learning entities.

[EDIT] Neural networks, not neutral ones!  Grin These fingers sometime just type what they want, not what I think! Shocked Funny typo anyway.
Re: Self developing Programms
Reply #7 - Jul 23rd, 2009, 3:39am
 
also you'll have to think about what "semi-intelligent" means to you: for example, if you want to make a chatterbot there are a few widely used libraries out there (ie: alicebot).
Re: Self developing Programms
Reply #8 - Aug 6th, 2009, 5:15am
 
The best method of doing this I found is by using an L-System approach.

An L-System instruction list in a way is a type of program and it is also capable of modifying itself.

Here's an example:

http://processing.org/learning/topics/pentigree.html

There's more in learning.

What's interesting branching from the LSystem is that you can start to use other characters to suggest brackets - or code blocks. I did the same for a game, where a letter followed by brackets signified a set of instructions or a program within a program.

http://www.nitrome.com/games/fatcat/

The instructions indicated firing patterns or were monsters within monsters.

I used a cut down version of this method for an art game where shooting down the creatures makes them more agressive, because it saves the monsters that do best in attacking you.

http://www.robotacid.com/flash/provocation/index.html

Source code for the second is linked to on the page. It's in AS3 but shouldn't be too hard to read.
Page Index Toggle Pages: 1