Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dave

Has anyone else done anything like this?

This topic is 5262 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, just wondering if anyone here has tried anything like this. I started it just for fun, but its turned out more complicated and powerful than i first thought. Its a virtual machine that writes a program using a simple set of maths instructions to get from a start number to a target number. My instructions: #define ADD 0 // Add A&B, result in A, B stays #define SUB 1 // Sub B from A, result in A, B stays #define MUL 2 // Mul A&B, result in A, B stays #define NOP 3 // Do nothing #define SWP 4 // Swap A&B #define DP1 5 // Duplicate A #define DP2 6 // Duplicate B #define INC 7 // Increment A #define DEC 8 // Decrement B #define SQR 9 // Square A #define MOD 10// Modulus A by B I am now writing optimization routines that cancel out instructions that don't alter the output. The Virtual Machine uses a stack based system for data manipulations like this: regA regB regC and temp for the swap function. It uses a pool of programs that contain a maximum of 50 instructins and through genetic mutation and natural selection algorythms provides the user with a swift answer. this program is turning out very cool, so anyone had a go? regards ace [edited by - ace_lovegrove on June 4, 2004 1:54:47 PM]

Share this post


Link to post
Share on other sites
Advertisement
http://alphard.ethz.ch/gerber/approx/default.html
http://http.icsi.berkeley.edu/~storn/code.html

Rogers, D. and A. J. Hopfinger (1994). "Application of genetic function approximation to quantitative structure-activity relationships and quantitative structure-property relationships." Journal of Chemical Information and Computer Sciences 34: 854-66.

Share this post


Link to post
Share on other sites
I am actually working on something similar in my implementation of Genetic Programming. In ym system, I am using the standard expression trees although I plan on allowing the user(scripter) to tell the system to use a setup similar to yours. I was also planning on creating a module in the system which would compile the expressions and or bytecode instructions. This is would make for a much much faster implementation then an interpreted one like I am currently using.

The compilation is really only advantagous though, if you are using many data sets to test the given program's fitness, or if they are large. The more operations executed per program fitness evaluation, the more advantagous compilation and/or bytecode system become.

I think that if you are trying to get the most speed out of your system, you might want to look for an article by someone who created a library that took asm as input and returned you callable function. In this way, you can compile the code in your sw and run it. It is also a fairly fast procedure, as with bytecodes, the compiler simply needs to change the codes and methods for accessing the registers. (ease of portability to low level CPU will vary based on how closely your VM is related in structure and execution to the real thing)

I found an article/code example that I refered to above. It might help some if you decide to persue the compilation idea to dramatically increase speed.

Hope I've Helped!

Dwiel

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!