Jump to content
  • Advertisement

Archived

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

dave

Has Anyone Tried This?

This topic is 5278 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

Share this post


Link to post
Share on other sites
Advertisement
OMG FAR OUT! I have done a VERY similiar thing before!!!

I used it for learning number sequences.
You evolve a program that produces outputs and score each program according to how closely it matches a given sequence.

e.g. Take the first N numbers output and work out the variance from a sequence like 1,2,4,8,16 (use result as part of fitness function). Evolve the best program and then run it to see what the next number would be. It was able to learn finonacci sequences and all sorts of funky sequences.

My version had goto''s and I had to make sure that I only ran each program through a maximum number of instructions in case there was an infinite loop.

Pretty cool actually. Good to hear someone else is doing this too.

Share this post


Link to post
Share on other sites
yeah its awesome, BTW other dude, why exactly would i google it, i clearly didnt think this up myself else i''d me rich.

Share this post


Link to post
Share on other sites
quote:
Original post by ace_lovegrove
[...]why exactly would i google it[...]
To learn more about what other people have done in order to further your own work to even more impressive functionality

Share this post


Link to post
Share on other sites
i got a book, hehe, im writing routines to optimize the code, take out commands that dont do anything,

its getting well good.

regards

ace

Share this post


Link to post
Share on other sites
When doing a genetic algorithm it''s probably better not to write routines specifically to optimise the code. It is usually better to include the program length as part of the fitness function.

Share this post


Link to post
Share on other sites
i''m optimising the code once a solution has been found, but i know what yer saying.

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!