# Thread: VB6 - Grammatical Evolution

1. ## VB6 - Grammatical Evolution

This is a small project inspired by Grammatical Evolution.

It's a Genetic Algorithm that evolves a Program-Code.
(in fact i'd prefer to call it Code-Evolution, since it involves even ROM and uses RAM, and since Grammatical Evolution is something more sophisticated)

The GA individuals-Structure is this:

-Inputs
-Outpus
-RAM
-ROM (Constants)
-Code

The Parts that evolve are ROM and CODE.

Public Sub INIT(PopulationSize As Long, Inputs As Long, Outputs As Long, Rams As Long, Roms As Long, NCodeLines As Long, _
EVOSonsPerc As Double, EVOChildMutationProb As Double, EVOMutationRate As Double)

At the Moment the CODE have this set of instructions:

R = A + B
R = A - B
R = A * B
R = A / B
R = A ^ B
R = IIf(A > B, A, B) Greater
R = IIf(A < B, A, B) Smaller
R = A

JUMP to line Code
Jump if A>B to line Code
Jump if A<B to line Code

Where A,B can be: Input,RAM,ROM
and R can be RAM,Output

One single line of code occupy 7 Values defined so:
1 - Main instruction
2 - Type of A
3 - Address of A (depending on its type)
4 - Type of B
5 - Address of B (depending on its type)
6 - Type of R
7 - Address of R (depending on its type)

(If 1 operand or jump,some of these are not used)

Launch the program and watch moving object learn to stay on "Green Circle"
In Test01 a set of Object move according to their Codes.
They have 2 imputs:
Difference of Angle to GreenCircle
Distance to GreenCircle
2 output:
Speed
Turn Angle

It has been written quickly and still a lot to improve.

By the way, I'd like to share this on Github or GitLab... cause I'd like to have contributors and new test tasks-designer.
I tried both, but both gives me error when I download the code and try to open it with VB6. Can someone tell me why?

If you have improvements or test-tasks designed.. Share!

Updated (GitLab) DOWNLOAD

2. ## Re: VB6 - Grammatical Evolution

It is really amazing!

3. ## Re: VB6 - Grammatical Evolution

Originally Posted by reexre
By the way, I'd like to share this on Github or GitLab... cause I'd like to have contributors and new test tasks-designer. I tried both, but both gives me error when I download the code and try to open it with VB6. Can someone tell me why?
Make sure your line-endings are explicitly set to CrLf. For a VB6 project, you should add something like this to your .gitattributes file:

Code:
```*.bas    eol=crlf
*.cls    eol=crlf
*.ctl    eol=crlf
*.frm    eol=crlf
*.vbp    eol=crlf```

4. ## Re: VB6 - Grammatical Evolution

@Tanner
I prefer to use GitLab, because it allows Web uploads.
In fact, files on GitLab here have just been uploaded. (As said before if I click Download, Unzip the Zip and open the project with VB6, it fails due to some error loading Form and clsGE...)
Thanks anyway. If you have some tips on GitLab too , they'll be welcome.

5. ## Re: VB6 - Grammatical Evolution

Just as the Tanner advises, in you gitlab project folder add file .gitattributes

Code:
```##################################################
# https://help.github.com/articles/dealing-with-line-endings/

##################################################
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

##################################################
# Declare files that will always have CRLF line endings on checkout.
*.ini eol=crlf
*.log eol=crlf
*.txt eol=crlf

*.vbp eol=crlf
*.vbw eol=crlf
*.frm eol=crlf
*.bas eol=crlf
*.cls eol=crlf
*.ctl eol=crlf

##################################################
# Denote all files that are truly binary and should not be modified.
*.frx binary
*.ctx binary

*.png binary
*.jpg binary
*.bmp binary
*.ico binary
*.cur binary
*.pdf binary```

6. ## Re: VB6 - Grammatical Evolution

thanks pekko, I ll update on gitlab soon

7. ## Re: VB6 - Grammatical Evolution

Yes, like pekko already shared (thanks, pekko!) .gitattributes and .gitignore files are a core part of Git. They have nothing to do with GitHub, specifically. I just shared the GitHub page because it has a nice explanation of the concept, with command-line instructions that work on any OS.

8. ## Re: VB6 - Grammatical Evolution

New update here with a new Test02 Project

@Tanner thanks. Sorry but it's the first time I'm on Git. So I thought it was specifically...
I have understood only a little about Git.... and I still haven't tried "Command-Line instructions".

9. ## Re: VB6 - Grammatical Evolution

.gitattributes is enough to stay only in main folder ?
In Test02 , still some problem with fMain.frm ....

10. ## Re: VB6 - Grammatical Evolution

Hi reexre,

I just had a quick look at your programs. First of, I'm impressed by how you managed to smoothly animate all those tiny figures. Pretty impressive. But, I'm having trouble understanding your explanation and what's suppossed to be going on. Could some one explain it, without getting too technical, because it sure looks interesting.

EDIT:
Just noticed the link to the wiki...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured

Click Here to Expand Forum to Full Width