Exemple #1
0
    def __init__(self):
        """initialize environment and initial solution"""
        self.args = asteroids_exp.parse_args()
        self.args['visual'] = True
        self.env_state, self.window_width, self.window_height = asteroids_exp.init_asteroid_model(
            self.args)
        self.view = None

        # create the initial state
        initial_state, window_width, window_height = asteroids_exp.init_asteroid_model(
            self.args)
 def __init__(self, args):
     """
     Initialize environment
     Returns
     -------
     None.
     """
     self.args = asteroids_exp.parse_args(args)
     self.args['visual'] = True
     self.env_state, self.window_width, self.window_height  = asteroids_exp.init_asteroid_model(self.args)
     self.view = None
    def __init__(self):
        """initialize environment and intial solution"""
        self.args = asteroids_exp.parse_args()
        self.args['visual'] = True
        self.env_state, self.window_width, self.window_height = asteroids_exp.init_asteroid_model(
            self.args)
        self.view = None

        # finish this method (10 points)
        """simulate a solution, return a reward value (10 points) """
        """choose a new random solution, via a local edit of current solution (10 points) """
        """determine whether to move to new state or remain in same place (10 points) """
    def __init__(self, args):
        """
        Initialize environment and intial solution

        Returns
        -------
        None.

        """
        self.args = asteroids_exp.parse_args(args)
        self.args['visual'] = True
        self.env_state, self.window_width, self.window_height  = asteroids_exp.init_asteroid_model(self.args)
        self.view = None
        self.solution = []
        self.init_state = [('s', 0), ('d', self.window_width)]
Exemple #5
0
def get_sa_stats():
    """
    Get the statistics for simulated annealing algorithm run

    Returns
    -------
    sa_fuel : List
        Fuel left for each game.
    sa_game_time : List
        Game run time for each game.
    sa_sys_time : List
        System run time for each game.

    """
    sa_fuel = []
    sa_game_time = []
    sa_sys_time = []
    for i in range(25):
        print("Game #" + str(i) + ": ", end='')
        #for j in range(5):

        SA = asteroids_sa.SA_Agent(line_args.format(i))
        start = time.time()
        SA_path = SA.run()
        end = time.time()

        args = asteroids_exp.parse_args(line_args.format(i))
        game_time, fuel_left = asteroids_exp.check_soln(SA_path, args)

        # if not np.isnan(fuel_left) or i == 9:
        #     break
        if not np.isnan(fuel_left):
            print("success")
        else:
            print("failure")

        sa_fuel.append(fuel_left)
        sa_game_time.append(game_time)
        sa_sys_time.append(round(end - start, 4))

    return sa_fuel, sa_game_time, sa_sys_time
Exemple #6
0
def get_tree_stats():
    """
    Get the statistics for tree search algorithm run

    Returns
    -------
    tree_fuel : List
        Fuel left for each game.
    tree_game_time : List
        Game run time for each game.
    tree_sys_time : List
        System run time for each game.

    """
    tree_fuel = []
    tree_game_time = []
    tree_sys_time = []
    for i in range(25):
        print("Game #" + str(i) + ": ", end='')
        #for j in range(5):
        tree = asteroids_tree.Search_Agent(line_args.format(i))
        start = time.time()
        tree_path = tree.run()
        end = time.time()

        args = asteroids_exp.parse_args(line_args.format(i))
        game_time, fuel_left = asteroids_exp.check_soln(tree_path, args)

        # if not np.isnan(fuel_left) or i == 9:
        #     break
        if not np.isnan(fuel_left):
            print("success")
        else:
            print("failure")

        tree_fuel.append(fuel_left)
        tree_game_time.append(game_time)
        run_time = end - start
        tree_sys_time.append(round(run_time, 4))

    return tree_fuel, tree_game_time, tree_sys_time
Exemple #7
0
def get_ga_stats():
    """
    Get the statistics for genetic algorithm run

    Returns
    -------
    ga_fuel : List
        Fuel left for each game.
    ga_game_time : List
        Game run time for each game.
    ga_sys_time : List
        System run time for each game.

    """
    ga_fuel = []
    ga_game_time = []
    ga_sys_time = []
    for i in range(25):
        print("Game #" + str(i) + ": ", end='')
        #for j in range(5):

        GA = asteroids_ga.GA_Agent(line_args.format(i))
        start = time.time()
        GA_path = GA.run()
        end = time.time()

        args = asteroids_exp.parse_args(line_args.format(i))
        game_time, fuel_left = asteroids_exp.check_soln(GA_path, args)

        # if not np.isnan(fuel_left) or i == 9:
        #     break
        if not np.isnan(fuel_left):
            print("success")
        else:
            print("failure")
        ga_fuel.append(fuel_left)
        ga_game_time.append(game_time)
        ga_sys_time.append(round(end - start, 4))

    return ga_fuel, ga_game_time, ga_sys_time
 def __init__(self, args):
     self.args = asteroids_exp.parse_args(args)
     self.args['visual'] = True
     self.state, self.window_width, self.window_height = asteroids_exp.init_asteroid_model(
         self.args)
     self.view = None