Genetic Algorithm : password
My first genetic algorithm program ! Input a word or string using only lowercase characters and spaces, choose a population size and a maximum number of generation, and let darwinism do its work !
I made this program alone within half a day on Java, using IntelliJ for IDE.
An execution example :
\------------------------------------------------
Enter the word the algorithm has to find ( only lowercase letters + space character allowed ) :
hello world
Enter the size of the population generated by the algorithm, bigger is faster
200
Enter the maximum number of generation allowed, if no results is found after this number of generation, the algorithm will stop :
50
\------------------------------------------------
Word to find : 'hello world'
Population size : 200
Maximum number of generations : 50
\------------------------------------------------
Generation #1 : utlixwtyrlz, fit : 3.125, age : 0
Generation #2 : qhliyetotlo, fit : 3.375, age : 0
Generation #3 : aeklneqdrbd, fit : 4.25, age : 0
Generation #4 : rmlddkvorlo, fit : 4.5, age : 0
Generation #5 : helddcutrld, fit : 6.25, age : 0
Generation #6 : helddcutrld, fit : 6.25, age : 1
Generation #7 : helldb omld, fit : 7.25, age : 0
Generation #8 : helldoqorle, fit : 7.375, age : 0
Generation #9 : helld qorld, fit : 9.125, age : 0
Generation #10 : helld qorld, fit : 9.125, age : 1
Generation #11 : helld qorld, fit : 9.125, age : 2
Generation #12 : helli world, fit : 10.0, age : 0
Generation #13 : hellw world, fit : 10.125, age : 0
Generation #14 : hellw world, fit : 10.125, age : 1
Generation #15 : hello world, fit : 11.0, age : 0
Algorithm terminated after 15 generations !
Best result : hello world, fit : 11.0, age : 0
Number of mutation : 1316