def set_up_patches():
    string = 'G.set_of_patches = list(product('  
    for x in G.DIM_SIZE:
        string = string + 'range(' + str(x) + '),'
    string = string[:-1] + '))'
    exec string
    set_of_patches = G.set_of_patches
    setup_loc_arr()
    G.hills = tuple([Hills(dim) for dim in G.HILL_DIM])
    G.peaks = set([x._location[:x._num_dim] for x in G.hills])
    # For Gaussian hills, deactive the For loop and until the next for loop (ie until "for patch...")
#    for hill in G.hills:
#        try:
#            starting_patches = hill._starting_patches & starting_patches
#            sig_patches = sig_patches | hill._sig_patches
#        except:
#            starting_patches = hill._starting_patches
#            sig_patches = hill._sig_patches
#    G.starting_patches = starting_patches
#    G.sig_patches_loc = sig_patches
#    G.sig_patches = len(sig_patches)
    for patch in set_of_patches:
        temp = Patches(patch)
        G.patches_sig[patch] = temp._sig
        G.patches_vis[patch] = 0
    G.total_significance = float(scipy_sum(G.patches_sig))
    
    #Finding neighborhood and neighborhood significance
    arr_size = G.arr_size
    patches_loc = G.patches_loc
    patches_sig = G.patches_sig
    patches_nhbd = [neighborhood(x) for x in patches_loc]
    G.patches_nhbd_sig = [[patches_sig[x] for x in patches_nhbd[i]] for i in range(arr_size)]
    G.patches_nhbd = patches_nhbd
def progress():
    patches_sig = G.patches_sig
    patches_vis = G.patches_vis
    sig_per_turtle_p = []
    sig_per_turtle_n = []
    total_explored = set()
    sum_n = 0
    for turtle in G.turtles:
#        explored = turtle._explored
        explored = turtle._explored - total_explored
        total_explored = total_explored | explored
#        This sig_per_turtle is calculated as a percentage of total significance on hill
        turtle_sig_p = sum([patches_sig[x] for x in explored])
        sig_per_turtle_p.append(turtle_sig_p/G.total_significance)
#        This sig_per_turtle is calculated as a percentage of significant patches
#        turtle_sig_n = len([x for x in explored if patches_sig[x] > 0])
        turtle_sig_n = len(explored & G.sig_patches_loc)
        sum_n += turtle_sig_n
        sig_per_turtle_n.append(float(turtle_sig_n)/G.sig_patches)
    G.sig_per_turtle_p = sig_per_turtle_p
    G.sig_per_turtle_n = sig_per_turtle_n
    G.percent_progress = sum(patches_sig[patches_vis != 0])/G.total_significance
    G.total_prog = G.count_patches[0]/Decimal(G.arr_size)
    G.wasted_effort = scipy_sum(patches_vis) - len(where(patches_vis > 0)[0])