Exemplo n.º 1
0
def replay(import_path):

    print "Replaying simulation from:"
    print import_path
    print ""

    # Search and return step* folder inside import_path (e.g. step100, step200, step300 etc), ordered by number
    steps_paths = glob.glob(os.path.join(import_path, "step*"))

    if len(steps_paths) == 0:
        print "There is no step* folder to replay from."
        exit()
    else:
        steps_paths = sorted(steps_paths,
                             key=lambda name: int(
                                 name.replace(import_path, "").replace(
                                     "step", "").replace("/", "")))
        step_number = 0
        for step_path in steps_paths:
            step_number += 1
            if step_number % 30 == 0:  # Load every X saved state
                load_state(os.path.join(step_path))
                p.load_parameters_post()
                p.STEPS = p.start_step
                p.realtimePlot = True
                main_loop.main_loop(p.current_matrix)
Exemplo n.º 2
0
def replay(import_path):

    print "Replaying simulation from:"
    print import_path
    print ""

    # Search and return step* folder inside import_path (e.g. step100, step200, step300 etc), ordered by number
    steps_paths = glob.glob(os.path.join(import_path, "step*"))

    if len(steps_paths) == 0:
        print "There is no step* folder to replay from."
        exit()
    else:
        steps_paths = sorted(steps_paths, key=lambda name: int(name.replace(import_path, "").replace("step", "").replace("/", "")))
        step_number = 0
        for step_path in steps_paths:
            step_number += 1
            if step_number % 30 == 0: # Load every X saved state
                load_state(os.path.join(step_path))
                p.load_parameters_post()
                p.STEPS = p.start_step
                p.realtimePlot = True
                main_loop.main_loop(p.current_matrix)
Exemplo n.º 3
0
# Define some basic constants and parameters shared between new and saved simulations
p.load_parameters_pre()

# Function to list saved states

if p.simulation_mode == 'list':

    saved_states.list_saved_states(p.saved_state_path)

elif p.simulation_mode == 'new':

    # Load default parameters
    p.load_default_parameters()
    matrix_initialization.matrix_initialization()
    # Calculate some derivatives parameters
    p.load_parameters_post()
    # Run the simulation per se
    main_loop.main_loop(p.current_matrix)

elif p.simulation_mode == 'load': # Or load parameters from saved state

    saved_states.load_state(p.saved_state_path)
    # Calculate some derivatives parameters
    p.load_parameters_post()
    main_loop.main_loop(p.current_matrix)

elif p.simulation_mode == 'replay':

    # Replay simulation
    saved_states.replay(p.saved_state_path)