schrum2 / EvoCraft-SCOPE

0 stars 0 forks source link

Splitting code into separate modules #11

Closed schrum2 closed 2 years ago

schrum2 commented 2 years ago

Right now nearly all of our code is in evolve_CPPN.py. This makes it difficult to collaborate, and makes the code more confusing. We need to break things up a bit. For all of the code that you move into a different file, you will of course need to import that code back into evolve_CPPN.py and slightly change the way it is called or accessed in that file.

Make a module called neat_stagnation.py and place the InteractiveStagnation class there.

Make a module called minecraft_structures.py and move the place_number function there.

Make a module called util.py and place the argmax, distance, and scale_and_center functions there.

As you move all of these bits of code into separate files, it will be extremely important to provide proper docstrings to each one, since the purpose of each function will become less clear as they become scattered across various files. Refer to this site for style guidelines: https://www.datacamp.com/tutorial/docstrings-python

schrum2 commented 2 years ago

Also, the place_fences method is defined inside of the MinecraftBreeder class, but this could be turned into a function in the minecraft_structures.py module if every reference to an instance variable via self was turned into a parameter to the function.

alejmedinajr commented 2 years ago

Made the following modules: minecraft_structures, neat_stagnation, and util. Each now contain functions or classes that were originally causing the evolve_CPPN module to look more messy. The functions still seem to work. Although I would think that there are still some other functions that can be moved into some of these modules (such as the clear_area function).

schrum2 commented 2 years ago

Go ahead and move clear_area as well

alejmedinajr commented 2 years ago

Just moved clear_areainto minecraft_structures

alejmedinajr commented 2 years ago

I reopened the issue so I could use it for a new commit with better comments.