Update README.md
This commit is contained in:
66
README.md
66
README.md
@ -14,7 +14,7 @@ Run python's pip3 to install:
|
||||
pip3 install EasyGA
|
||||
```
|
||||
|
||||
## Getting started with EasyGA:
|
||||
## Getting started with EasyGA(Basic Example):
|
||||
```Python
|
||||
import EasyGA
|
||||
|
||||
@ -45,6 +45,70 @@ Chromosome - 8 [5][8][8][6][10][10][5][7][2][7] / Fitness = 2
|
||||
Chromosome - 9 [7][2][8][10][3][5][5][8][1][7] / Fitness = 2
|
||||
```
|
||||
|
||||
## Getting started with EasyGA (Password Cracker Example):
|
||||
```Python
|
||||
import EasyGA
|
||||
import random
|
||||
|
||||
ga = EasyGA.GA()
|
||||
|
||||
word = input("Please enter a word: \n")
|
||||
ga.chromosome_length = len(word)
|
||||
ga.fitness_goal = len(word)
|
||||
|
||||
ga.population_size = 50
|
||||
ga.generation_goal = 10000
|
||||
|
||||
|
||||
def password_fitness(chromosome):
|
||||
|
||||
return sum(
|
||||
1
|
||||
for gene, letter
|
||||
in zip(chromosome, word)
|
||||
if gene.value == letter
|
||||
)
|
||||
|
||||
ga.fitness_function_impl = password_fitness
|
||||
|
||||
ga.gene_impl = lambda: random.choice(["A","a","B","b","C","c","D","d","E","e",
|
||||
"F","f","G","g","H","h","I","i","J","j",
|
||||
"K","k","L","l","M","m","N","n","O","o",
|
||||
"P","p","Q","q","R","r","S","s","T","t",
|
||||
"U","u","V","v","W","w","X","x","Y","y",
|
||||
"Z","z"," "])
|
||||
|
||||
# Evolve the gentic algorithm
|
||||
ga.evolve()
|
||||
|
||||
# Print out the current generation and the population
|
||||
ga.print_generation()
|
||||
ga.print_population()
|
||||
|
||||
# Show graph of progress
|
||||
ga.graph.highest_value_chromosome()
|
||||
ga.graph.show()
|
||||
```
|
||||
|
||||
## Ouput:
|
||||
```
|
||||
Please enter a word:
|
||||
EasyGA
|
||||
Current Generation : 44
|
||||
Chromosome - 0 [E][a][s][y][G][A] / Fitness = 6
|
||||
Chromosome - 1 [E][a][s][Y][G][A] / Fitness = 5
|
||||
Chromosome - 2 [E][a][s][O][G][A] / Fitness = 5
|
||||
Chromosome - 3 [E][a][s][Y][G][A] / Fitness = 5
|
||||
Chromosome - 4 [E][a][s][c][G][A] / Fitness = 5
|
||||
Chromosome - 5 [E][a][s][c][G][A] / Fitness = 5
|
||||
Chromosome - 6 [E][a][s][y][Z][A] / Fitness = 5
|
||||
Chromosome - 7 [E][a][s][Y][G][A] / Fitness = 5
|
||||
Chromosome - 8 [E][a][s][y][Z][A] / Fitness = 5
|
||||
Chromosome - 9 [E][a][s][Y][G][A] / Fitness = 5
|
||||
```
|
||||
|
||||
![ihttps://github.com/danielwilczak101/EasyGA/blob/media/images/password_cracker_results.png]
|
||||
|
||||
## Issues
|
||||
We would love to know if your having any issues. Please start a new issue on the [Issues Page](https://github.com/danielwilczak101/EasyGA/issues).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user