#### Archived

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

# 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.

## 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 on other sites
There were some old school RPN calculators that did the same thing back in the 70s so I gather...

##### Share on other sites
It''s called "Genetic Programming". Google it.

##### Share on other sites
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 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 on other sites
quote:
Original post by ace_lovegrove
[...]why exactly would i google it[...]

##### 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 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 on other sites
i''m optimising the code once a solution has been found, but i know what yer saying.

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633350
• Total Posts
3011470
• ### Who's Online (See full list)

There are no registered users currently online

×