Exemplo n.º 1
0
 def __init__(self, lifespan=None, test=False):
     """
     Initialize the world. Base it on the grid_1D world.
     """
     Grid_1D_World.__init__(self, lifespan)
     self.name = 'grid_1D_delay'
     self.name_long = 'one dimensional grid world with delay'
     print '--delayed'
     self.MAX_DELAY = 4
     self.future_reward = [0.] * self.MAX_DELAY
     self.world_visualize_period = 1e6
Exemplo n.º 2
0
 def __init__(self, lifespan=None):
     """
     Initialize the world. Base it on the grid_1D world.
     """
     Grid_1D_World.__init__(self, lifespan)
     self.name = 'grid_1D_delay'
     self.name_long = 'one dimensional grid world with delay'
     print '--delayed'
     self.display_state = False 
     self.MAX_DELAY = 4
     self.future_reward = [0.] * self.MAX_DELAY
Exemplo n.º 3
0
    def __init__(self, lifespan=None):
        """
        Initialize the world. Base it on the grid_1D world.

        Parameters
        ----------
        lifespan : int 
            The number of time steps to continue the world.
        """
        Grid_1D_World.__init__(self, lifespan)
        self.name = 'grid_1D_delay'
        self.name_long = 'one dimensional grid world with delay'
        print '--delayed'
        self.max_delay = 9
        self.future_reward = [0.] * self.max_delay
        self.world_visualize_period = 1e6
Exemplo n.º 4
0
    """
    agent_name = '_'.join((world.name, 'agent'))
    agent = Agent(world.num_sensors,
                  world.num_actions,
                  agent_name=agent_name,
                  show=show)
    if restore:
        agent = agent.restore()
    actions = np.zeros((world.num_actions, 1))
    # Repeat the loop through the duration of the existence of the world
    while (world.is_alive()):
        sensors, reward = world.step(actions)
        world.visualize(agent)
        actions = agent.step(sensors, reward)
    return agent.report_performance()


def profile():
    print 'profiling BECCA\'s performance...'
    cProfile.run('test(World(lifespan=profiling_lifespan), restore=True)',
                 'tester_profile')
    p = pstats.Stats('tester_profile')
    p.strip_dirs().sort_stats('time', 'cumulative').print_stats(30)


if __name__ == '__main__':
    if profile_flag:
        profile()
    else:
        test(World(lifespan=testing_lifespan), restore=True)