This commit is contained in:
SimpleArt
2021-06-10 22:15:37 -04:00
3 changed files with 3 additions and 4 deletions

View File

@ -93,6 +93,7 @@ class GA(Attributes):
self.sort_by_best_fitness() self.sort_by_best_fitness()
# Save the population to the database # Save the population to the database
if self.save_data:
self.save_population() self.save_population()
# Adapt the ga if the generation times the adapt rate # Adapt the ga if the generation times the adapt rate

View File

@ -180,6 +180,7 @@ class Attributes:
database: Database = field(default_factory=sql_database.SQL_Database) database: Database = field(default_factory=sql_database.SQL_Database)
database_name: str = 'database.db' database_name: str = 'database.db'
save_data: bool = True
sql_create_data_structure: str = """ sql_create_data_structure: str = """
CREATE TABLE IF NOT EXISTS data ( CREATE TABLE IF NOT EXISTS data (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
@ -418,10 +419,8 @@ def get_database_name(self: Attributes) -> str:
def set_database_name(self: Attributes, name: str) -> None: def set_database_name(self: Attributes, name: str) -> None:
# Update the database class' name # Update the database class' name
self.database._database_name = name self.database._database_name = name
# Set the attribute for itself # Set the attribute for itself
self._database_name = name self._database_name = name

View File

@ -109,7 +109,6 @@ Chromosome - 8 [E][a][s][y][Z][A] / Fitness = 5
Chromosome - 9 [E][a][s][Y][G][A] / Fitness = 5 Chromosome - 9 [E][a][s][Y][G][A] / Fitness = 5
``` ```
![]()
<img width="500px" src="https://raw.githubusercontent.com/danielwilczak101/EasyGA/media/images/password_cracker_results.png" /> <img width="500px" src="https://raw.githubusercontent.com/danielwilczak101/EasyGA/media/images/password_cracker_results.png" />
## Issues ## Issues