Skip to content

Commit

Permalink
Polished the code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
kul-sudo committed Jun 6, 2022
1 parent 684247a commit b112eca
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ def select_ai_survivor() -> object:
show_tip('Working on the prediction of AI...')

# Storing the initial states of plants and bodies
bodies_copy = []
for body in bodies:
bodies_copy.append(deepcopy(body))
plants_copy = []
for plant in plants:
plants_copy.append(deepcopy(plant))
bodies_copy = [deepcopy(body) for body in bodies]
plants_copy = [deepcopy(plant) for plant in plants]

# Modelling the evolution
data_for_smart_body['steps'] = 0
Expand Down Expand Up @@ -61,7 +57,7 @@ def select_ai_survivor() -> object:

max_descendants_by_id = max( # Returns the ID
(dict_key for dict_key in survived_bodies_dict_by_id),
key=lambda x: survived_bodies_dict_by_id[x]
key=survived_bodies_dict_by_id.get
)

for body in bodies:
Expand Down

0 comments on commit b112eca

Please sign in to comment.