Last active
August 29, 2015 14:00
-
-
Save syllogismos/cb5d5f7458d1aa9be7b7 to your computer and use it in GitHub Desktop.
Genetic programming brief explanation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http://forums.aichallenge.org/viewtopic.php?f=17&t=1136 | |
| We represent every program internally as an object tree, | |
| very much like a compiler internally represents a program | |
| after parsing and before generating executable code. | |
| A compiler manipulates these objects in order to optimize | |
| the code, we do it in order to randomly change the | |
| code (mutation) and to insert parts of one program | |
| into another (crossover). | |
| For example, an IF node has 3 subnodes: a condition, | |
| a then part and an else part. When we do a crossover, | |
| we randomly chose any node (say the condition) and replace | |
| it by any randomly selected boolean expression that appears | |
| anywhere in the code of the other program. The result is a | |
| new program that does nonsense in most cases, but occasionally | |
| it works better than both of the original programs. | |
| Doing these object manipulations is actually pretty simple, | |
| just copying references to objects while making sure the | |
| result is a valid program. | |
| In an effort to make this process more efficient, we analyse | |
| the code before we use it and remove all the useless parts | |
| whenever we can identify them. For example, if we see | |
| Code: IF 4 > 7 THEN <a> ELSE <b> | |
| we replace it by | |
| Code: <b> | |
| If we see | |
| Code: IF planet_is_mine AND planet_is_mine THEN ... | |
| we replace it by | |
| Code: IF planet_is_mine THEN ... | |
| If we see | |
| Code: IF planet_is_mine AND planet_is_neutral THEN ... | |
| then we don't recognize in our static analysis that this | |
| is nonsense. However, we insert code that counts how often | |
| this combined condition is true. If it appears to be never | |
| true, then we remove the whole statement. If it appears to | |
| be always true, then we stop checking it. | |
| The main purpose of these simplifications is that we want | |
| to copy some code from a parent to a child only when it actually | |
| contributed to the success of the program. Propagating dead | |
| code is much less likely to improve the strategies than | |
| propagating code that has been used to win games. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment