from minecraft_pb2 import *
from utils_novelty import *
from utils_deap_tools import *
from utils_workspace_manger import *
from utils_evolution_tools import *
from utils_coordinates import *
from utils_server_client import *
from evolution_layout import layout_evolution
from evolution_roof import building_evolution
from evolution_gradient import gradient_evolution

if __name__ == "__main__":
    sc = ServerClient()
    wm = WorkspaceManager(sc)
    sc.send_message("*** EVOLUTION STARTED ***")
    wm.create_grid_workspace(
        Coordinates(-1024,0,-1024),
        Coordinates(10,1,10),
        Coordinates(16,100,16),
        Coordinates(14,16,14),
        create_platform = True,
        margin = Margin(1,1,1,1)
    )

    ngen = 100
    
    print("\n___ LAYOUT EVOLUTION ___")
    sc.send_message("___ LAYOUT EVOLUTION ___")
    layout = layout_evolution(wm, ngen = ngen, archive_type="lc")
    print("\n___ BUILDING EVOLUTION ___")
    sc.send_message("___ BUILDING EVOLUTION ___")
    building = building_evolution(wm, layout, ngen = ngen)
    print("\n___ GRADIENT EVOLUTION ___")
    sc.send_message("___ GRADIENT EVOLUTION ___")
    gradient = gradient_evolution(wm, building, ngen = ngen, archive_type="lc")

    sc.send_message("Evolution cleanup...")
    wm.delete_workspace_grid()
    
    sc.send_message("*** EVOLUTION FINISHED ***")