Example #1
0
    def __init__(self, lifespan=None):
        """
        Initialize the world.

        Parameters
        ----------
        lifespan : int 
            The number of time steps to continue the world.
        """
        BaseWorld.__init__(self, lifespan)
        self.reward_magnitude = 1.
        self.energy_cost = 0.05 * self.reward_magnitude
        self.jump_fraction = 0.1
        self.name = 'grid_2D'
        self.name_long = 'two dimensional grid world'
        print "Entering", self.name_long
        self.num_actions = 8
        self.world_size = 5
        self.num_sensors = self.world_size**2
        self.world_state = np.array([1., 1.])
        # Reward positions (2,2) and (4,4)
        self.targets = [(1, 1), (3, 3)]
        # Punish positions (2,4) and (4,2)
        self.obstacles = [(1, 3), (3, 1)]
        self.world_visualize_period = 1e6
        self.brain_visualize_period = 1e3
Example #2
0
    def __init__(self, lifespan=None):
        """
        Initialize the world.

        Parameters
        ----------
        lifespan : int 
            The number of time steps to continue the world.
        """
        BaseWorld.__init__(self, lifespan)
        self.reward_magnitude = 1.
        self.energy_cost = 0.05 * self.reward_magnitude
        self.jump_fraction = 0.1
        self.name = 'grid_2D'
        self.name_long = 'two dimensional grid world'
        print "Entering", self.name_long
        self.num_actions = 8
        self.world_size = 5
        self.num_sensors = self.world_size ** 2
        self.world_state = np.array([1., 1.])
        # Reward positions (2,2) and (4,4)
        self.targets = [(1,1), (3,3)]
        # Punish positions (2,4) and (4,2)
        self.obstacles = [(1,3), (3,1)]
        self.world_visualize_period = 1e6
        self.brain_visualize_period = 1e3
Example #3
0
    def __init__(self, lifespan=None, test=False):
        """
        Set up the world.

        Parameters
        ----------
        lifespan : int 
            The number of time steps to continue the world.
        """
        BaseWorld.__init__(self, lifespan)
        self.reward_magnitude = 1.
        self.jump_fraction = .05
        self.name = 'image_2D'
        self.name_long = 'two dimensional visual world'
        print "Entering", self.name_long
        self.fov_span = 5
        # Initialize the image_data to be used as the environment 
        self.image_filename = os.path.join(mod_path, 'images', 
                                                 'block_test.png') 
        self.image_data = plt.imread(self.image_filename)
        # Convert it to grayscale if it's in color
        if self.image_data.shape[2] == 3:
            # Collapse the three RGB matrices into one b/w value matrix
            self.image_data = np.sum(self.image_data, axis=2) / 3.0
        # Define the size of the field of view, its range of 
        # allowable positions, and its initial position.
        (im_height, im_width) = self.image_data.shape
        im_size = np.minimum(im_height, im_width)
        self.max_step_size = im_size / 2
        self.target_column = im_width / 2
        self.target_row = im_height / 2
        self.reward_region_width = im_size / 8
        self.noise_magnitude = 0.1
        self.fov_fraction = 0.5
        self.fov_height =  im_size * self.fov_fraction
        self.fov_width = self.fov_height
        self.column_min = np.ceil(self.fov_width / 2)
        self.column_max = np.floor(im_width - self.column_min)
        self.row_min = np.ceil(self.fov_height / 2)
        self.row_max = np.floor(im_height - self.row_min)
        self.column_position = np.random.random_integers(self.column_min, 
                                                         self.column_max)
        self.row_position = np.random.random_integers(self.row_min, 
                                                      self.row_max)
        self.num_sensors = 2 * self.fov_span ** 2
        self.num_actions = 16
        self.sensors = np.zeros(self.num_sensors)
        self.column_history = []
        self.row_history = []
        self.world_visualize_period = 1e3
        self.brain_visualize_period = 1e3
        self.print_features = False
Example #4
0
 def __init__(self, lifespan=None, test=False):
     """
     Set up the world
     """
     BaseWorld.__init__(self, lifespan)
     self.REWARD_MAGNITUDE = 1.
     self.JUMP_FRACTION = .1
     self.print_feature_set = True
     self.animate = False
     self.name = 'image_2D'
     self.name_long = 'two dimensional visual world'
     print "Entering", self.name_long
     self.fov_span = 10
     # Initialize the block_image_data to be used as the environment 
     self.block_image_filename = os.path.join(mod_path, 'images', 
                                              'block_test.png') 
     self.block_image_data = plt.imread(self.block_image_filename)
     # Convert it to grayscale if it's in color
     if self.block_image_data.shape[2] == 3:
         # Collapse the three RGB matrices into one b/w value matrix
         self.block_image_data = np.sum(self.block_image_data, axis=2) / 3.0
     # Define the size of the field of view, its range of 
     # allowable positions, and its initial position.
     (im_height, im_width) = self.block_image_data.shape
     im_size = np.minimum(im_height, im_width)
     self.MAX_STEP_SIZE = im_size / 2
     self.TARGET_COLUMN = im_width / 2
     self.TARGET_ROW = im_height / 2
     self.REWARD_REGION_WIDTH = im_size / 8
     self.NOISE_MAGNITUDE = 0.1
     self.FIELD_OF_VIEW_FRACTION = 0.5
     self.fov_height =  im_size * self.FIELD_OF_VIEW_FRACTION
     self.fov_width = self.fov_height
     self.column_min = np.ceil(self.fov_width / 2)
     self.column_max = np.floor(im_width - self.column_min)
     self.row_min = np.ceil(self.fov_height / 2)
     self.row_max = np.floor(im_height - self.row_min)
     self.column_position = np.random.random_integers(self.column_min, 
                                                      self.column_max)
     self.row_position = np.random.random_integers(self.row_min, 
                                                   self.row_max)
     self.num_sensors = 2 * self.fov_span ** 2
     self.num_actions = 16
     self.sensors = np.zeros(self.num_sensors)
     self.column_history = []
     self.row_history = []
     self.last_feature_vizualized = 0
     self.step_counter = 0
     self.world_visualize_period = 1e6
     self.brain_visualize_period = 1e3
Example #5
0
 def __init__(self, lifespan=None, test=False):
     BaseWorld.__init__(self, lifespan)
     self.REWARD_MAGNITUDE = 1.0
     self.ENERGY_COST = self.REWARD_MAGNITUDE / 100.0
     self.JUMP_FRACTION = 0.1
     self.name = "grid_1D"
     self.name_long = "one dimensional grid world"
     print "Entering", self.name_long
     self.num_sensors = 9
     self.num_actions = 8
     self.action = np.zeros((self.num_actions, 1))
     self.world_state = 0
     self.simple_state = 0
     self.world_visualize_period = 1e6
     self.brain_visualize_period = 1e3
Example #6
0
 def __init__(self, lifespan=None):
     BaseWorld.__init__(self, lifespan)
     self.VISUALIZE_PERIOD = 10 ** 4
     self.REWARD_MAGNITUDE = 1.
     self.ENERGY_COST =  self.REWARD_MAGNITUDE / 100.
     self.JUMP_FRACTION = 0.1
     self.name = 'grid_1D'
     self.name_long = 'one dimensional grid world'
     print "Entering", self.name_long
     self.num_sensors = 9
     self.num_actions = 8
     self.action = np.zeros((self.num_actions,1))
     self.world_state = 0
     self.simple_state = 0
     self.display_state = False
Example #7
0
 def __init__(self, lifespan=None):
     BaseWorld.__init__(self, lifespan)
     self.VISUALIZE_PERIOD = 10**4
     self.REWARD_MAGNITUDE = 100.
     self.ENERGY_COST = self.REWARD_MAGNITUDE / 100.
     self.JUMP_FRACTION = 0.1
     self.name = 'grid_1D'
     self.name_long = 'one dimensional grid world'
     print "Entering", self.name_long
     self.num_sensors = 9
     self.num_actions = 9
     self.action = np.zeros((self.num_actions, 1))
     self.world_state = 0
     self.simple_state = 0
     self.display_state = False
Example #8
0
    def __init__(self, lifespan=None):
        """
        Set up the world

        Parameters
        ----------
        lifespan : int 
            The number of time steps to continue the world.
        """
        BaseWorld.__init__(self, lifespan)
        self.reward_magnitude = 1.
        self.jump_fraction = .1
        self.step_cost = .1 * self.reward_magnitude
        self.name_long = 'one dimensional visual world'
        self.name = 'image_1D'
        print "Entering", self.name_long
        self.fov_span = 5
        self.num_sensors = 2 * self.fov_span**2
        self.num_actions = 8
        self.world_visualize_period = 1e3
        self.brain_visualize_period = 1e3
        self.print_features = False

        # Initialize the image to be used as the environment
        self.image_filename = os.path.join(mod_path, 'images', 'bar_test.png')
        self.data = plt.imread(self.image_filename)
        # Convert it to grayscale if it's in color
        if self.data.shape[2] == 3:
            # Collapse the three RGB matrices into one b/w value matrix
            self.data = np.sum(self.data, axis=2) / 3.0
        # Define the size of the field of view, its range of
        # allowable positions, and its initial position.
        image_width = self.data.shape[1]
        self.max_step_size = image_width / 2
        self.target_column = image_width / 2
        self.reward_region_width = image_width / 8
        self.noise_magnitude = 0.1

        self.column_history = []
        self.fov_height = np.min(self.data.shape)
        self.fov_width = self.fov_height
        self.column_min = np.ceil(self.fov_width / 2)
        self.column_max = np.floor(self.data.shape[1] - self.column_min)
        self.column_position = np.random.random_integers(
            self.column_min, self.column_max)
        self.block_width = self.fov_width / (self.fov_span + 2)
        self.sensors = np.zeros(self.num_sensors)
Example #9
0
 def __init__(self, lifespan=None):
     BaseWorld.__init__(self, lifespan)
     self.VISUALIZE_PERIOD = 10**4
     self.REWARD_MAGNITUDE = 100.
     self.JUMP_FRACTION = 1. / 10.
     self.print_feature_set = True
     self.animate = False
     self.name = 'image_2D'
     self.name_long = 'two dimensional visual world'
     print "Entering", self.name_long
     self.fov_span = 10
     # Initialize the block_image_data to be used as the environment
     self.block_image_filename = os.path.join(mod_path, 'images',
                                              'block_test.png')
     self.block_image_data = plt.imread(self.block_image_filename)
     # Convert it to grayscale if it's in color
     if self.block_image_data.shape[2] == 3:
         # Collapse the three RGB matrices into one b/w value matrix
         self.block_image_data = np.sum(self.block_image_data, axis=2) / 3.0
     # Define the size of the field of view, its range of
     # allowable positions, and its initial position.
     (im_height, im_width) = self.block_image_data.shape
     im_size = np.minimum(im_height, im_width)
     self.MAX_STEP_SIZE = im_size / 2
     self.TARGET_COLUMN = im_width / 2
     self.TARGET_ROW = im_height / 2
     self.REWARD_REGION_WIDTH = im_size / 8
     self.NOISE_MAGNITUDE = 0.1
     self.FIELD_OF_VIEW_FRACTION = 0.5
     self.fov_height = im_size * self.FIELD_OF_VIEW_FRACTION
     self.fov_width = self.fov_height
     self.column_min = np.ceil(self.fov_width / 2)
     self.column_max = np.floor(im_width - self.column_min)
     self.row_min = np.ceil(self.fov_height / 2)
     self.row_max = np.floor(im_height - self.row_min)
     self.column_position = np.random.random_integers(
         self.column_min, self.column_max)
     self.row_position = np.random.random_integers(self.row_min,
                                                   self.row_max)
     self.num_sensors = 2 * self.fov_span**2
     self.num_actions = 17
     self.sensors = np.zeros(self.num_sensors)
     self.column_history = []
     self.row_history = []
     self.last_feature_vizualized = 0
     self.step_counter = 0
Example #10
0
    def __init__(self, lifespan=None, test=False):
        """
        Set up the world
        """
        BaseWorld.__init__(self, lifespan)
        self.REWARD_MAGNITUDE = 1.
        self.JUMP_FRACTION = 1. / 10.
        self.STEP_COST = 0.1 * self.REWARD_MAGNITUDE
        self.print_feature_set = True
        self.animate = False 
        self.graphing = True
        self.name_long = 'one dimensional visual world'
        self.name = 'image_1D'
        print "Entering", self.name_long
        self.step_counter = 0
        self.fov_span = 7 
        self.num_sensors = 2 * self.fov_span ** 2
        self.num_actions = 8
        self.world_visualize_period = 1e6
        self.brain_visualize_period = 1e3

        # Initialize the image to be used as the environment
        self.block_image_filename = os.path.join(mod_path, 'images', 
                                                 'bar_test.png') 
        self.data = plt.imread(self.block_image_filename)
        # Convert it to grayscale if it's in color
        if self.data.shape[2] == 3:
            # Collapse the three RGB matrices into one b/w value matrix
            self.data = np.sum(self.data, axis=2) / 3.0
        # Define the size of the field of view, its range of 
        # allowable positions, and its initial position.
        image_width = self.data.shape[1]
        self.MAX_STEP_SIZE = image_width / 2
        self.TARGET_COLUMN = image_width / 2
        self.REWARD_REGION_WIDTH = image_width / 8
        self.NOISE_MAGNITUDE = 0.1
    
        self.column_history = []
        self.fov_height = np.min(self.data.shape)
        self.fov_width = self.fov_height
        self.column_min = np.ceil(self.fov_width / 2)
        self.column_max = np.floor(self.data.shape[1] - self.column_min)
        self.column_position = np.random.random_integers(self.column_min, 
                                                         self.column_max)
        self.block_width = self.fov_width / (self.fov_span + 2)
        self.sensors = np.zeros(self.num_sensors)
Example #11
0
 def __init__(self, lifespan=None):
     BaseWorld.__init__(self, lifespan)
     self.VISUALIZE_PERIOD = 10 ** 4
     self.REWARD_MAGNITUDE = 100.
     self.ENERGY_COST = 0.05 * self.REWARD_MAGNITUDE
     self.JUMP_FRACTION = 0.1
     self.display_state = False
     self.name = 'grid_2D'
     self.name_long = 'two dimensional grid world'
     print "Entering", self.name_long
     self.num_actions = 9            
     self.world_size = 5
     self.num_sensors = self.world_size ** 2
     self.world_state = np.array([1, 1])
     # Reward positions (2,2) and (4,4)
     self.targets = [(1,1), (3,3)]
     # Punish positions (2,4) and (4,2)
     self.obstacles = [(1,3), (3,1)]
Example #12
0
 def __init__(self, lifespan=None):
     BaseWorld.__init__(self, lifespan)
     self.VISUALIZE_PERIOD = 10**4
     self.REWARD_MAGNITUDE = 100.
     self.ENERGY_COST = 0.05 * self.REWARD_MAGNITUDE
     self.JUMP_FRACTION = 0.1
     self.display_state = False
     self.name = 'grid_2D'
     self.name_long = 'two dimensional grid world'
     print "Entering", self.name_long
     self.num_actions = 9
     self.world_size = 5
     self.num_sensors = self.world_size**2
     self.world_state = np.array([1, 1])
     # Reward positions (2,2) and (4,4)
     self.targets = [(1, 1), (3, 3)]
     # Punish positions (2,4) and (4,2)
     self.obstacles = [(1, 3), (3, 1)]
Example #13
0
 def __init__(self, lifespan=None):
     """ Set up the world """
     BaseWorld.__init__(self, lifespan)
     self.VISUALIZE_PERIOD = 10 ** 4
     self.REWARD_MAGNITUDE = 100.
     self.ENERGY_COST = 0.01 * self.REWARD_MAGNITUDE
     self.JUMP_FRACTION = 0.1
     self.display_state = True  
     self.name = 'grid_1D_noise'
     self.name_long = 'noisy one dimensional grid world'
     print "Entering", self.name_long
     self.num_real_sensors = 3
     # Number of sensors that have no basis in the world. 
     # These are noise meant to distract.
     self.num_noise_sensors = 15        
     self.num_sensors = self.num_noise_sensors + self.num_real_sensors
     self.num_actions = 3
     self.action = np.zeros((self.num_actions,1))
     self.world_state = 0      
     self.simple_state = 0       
Example #14
0
 def __init__(self, lifespan=None, test=False):
     """
     Set up the world 
     """
     BaseWorld.__init__(self, lifespan)
     self.reward_magnitude = 1.
     self.energy_cost = 0.01 * self.reward_magnitude
     self.jump_fraction = 0.1
     self.name = 'grid_1D_noise'
     self.name_long = 'noisy one dimensional grid world'
     print "Entering", self.name_long
     self.num_real_sensors = 3
     # Number of sensors that have no basis in the world.
     # These are noise meant to distract.
     self.num_noise_sensors = 15
     self.num_sensors = self.num_noise_sensors + self.num_real_sensors
     self.num_actions = 2
     self.action = np.zeros((self.num_actions, 1))
     self.world_state = 0
     self.simple_state = 0
     self.world_visualize_period = 1e6
     self.brain_visualize_period = 1e3
Example #15
0
 def __init__(self, lifespan=None, test=False):
     """
     Set up the world 
     """
     BaseWorld.__init__(self, lifespan)
     self.reward_magnitude = 1.0
     self.energy_cost = 0.01 * self.reward_magnitude
     self.jump_fraction = 0.1
     self.name = "grid_1D_noise"
     self.name_long = "noisy one dimensional grid world"
     print "Entering", self.name_long
     self.num_real_sensors = 3
     # Number of sensors that have no basis in the world.
     # These are noise meant to distract.
     self.num_noise_sensors = 15
     self.num_sensors = self.num_noise_sensors + self.num_real_sensors
     self.num_actions = 2
     self.action = np.zeros((self.num_actions, 1))
     self.world_state = 0
     self.simple_state = 0
     self.world_visualize_period = 1e6
     self.brain_visualize_period = 1e3
Example #16
0
 def __init__(self, lifespan=None, test=False):
     """
     Set up the world 
     """
     BaseWorld.__init__(self, lifespan)
     self.REWARD_MAGNITUDE = 1.
     self.ENERGY_COST = 0.01 * self.REWARD_MAGNITUDE
     self.JUMP_FRACTION = 0.1
     self.name = 'grid_1D_noise'
     self.name_long = 'noisy one dimensional grid world'
     print "Entering", self.name_long
     self.num_real_sensors = 3
     # Number of sensors that have no basis in the world. 
     # These are noise meant to distract.
     self.num_noise_sensors = 15        
     self.num_sensors = self.num_noise_sensors + self.num_real_sensors
     self.num_actions = 2
     self.action = np.zeros((self.num_actions,1))
     self.world_state = 0      
     self.simple_state = 0       
     self.world_visualize_period = 1e6
     self.brain_visualize_period = 1e3
Example #17
0
    def __init__(self, lifespan=None):
        """
        Initialize the world.

        Parameters
        ----------
        lifespan : int 
            The number of time steps to continue the world.
        """
        BaseWorld.__init__(self, lifespan)
        self.reward_magnitude = 1.
        self.energy_cost = self.reward_magnitude / 1e10
        self.name = 'grid_1D_chase'
        self.name_long = 'one dimensional chase grid world'
        print "Entering", self.name_long
        self.size = 5
        self.num_sensors = self.size + 2 * (self.size - 1)
        self.num_actions = 2 * (self.size - 1)
        self.action = np.zeros(self.num_actions)
        self.position = 2
        self.target_position = 1
        self.world_visualize_period = 1e3
        self.brain_visualize_period = 1e3
Example #18
0
    def __init__(self, lifespan=None):
        """
        Initialize the world.

        Parameters
        ----------
        lifespan : int 
            The number of time steps to continue the world.
        """
        BaseWorld.__init__(self, lifespan)
        self.reward_magnitude = 1.
        self.energy_cost =  self.reward_magnitude / 1e10
        self.name = 'grid_1D_chase'
        self.name_long = 'one dimensional chase grid world'
        print "Entering", self.name_long
        self.size = 5
        self.num_sensors = self.size + 2 * (self.size - 1)
        self.num_actions = 2 * (self.size - 1)
        self.action = np.zeros(self.num_actions)
        self.position = 2
        self.target_position = 1
        self.world_visualize_period = 1e3
        self.brain_visualize_period = 1e3
Example #19
0
    def __init__(self, lifespan=None):
        """
        Initialize the world.

        Parameters
        ----------
        lifespan : int 
            The number of time steps to continue the world.
        """
        BaseWorld.__init__(self, lifespan)
        self.reward_magnitude = 1.
        self.energy_cost =  self.reward_magnitude / 100.
        self.jump_fraction = 0.1
        self.name = 'grid_1D'
        self.name_long = 'one dimensional grid world'
        print "Entering", self.name_long
        self.num_sensors = 9
        self.num_actions = 8
        self.action = np.zeros(self.num_actions)
        self.world_state = 0
        self.simple_state = 0
        self.world_visualize_period = 1e6
        self.brain_visualize_period = 1e3
Example #20
0
    def __init__(self, lifespan=None):
        """
        Initialize the world.

        Parameters
        ----------
        lifespan : int 
            The number of time steps to continue the world.
        """
        BaseWorld.__init__(self, lifespan)
        self.reward_magnitude = 1.
        self.energy_cost = self.reward_magnitude / 100.
        self.jump_fraction = 0.1
        self.name = 'grid_1D'
        self.name_long = 'one dimensional grid world'
        print "Entering", self.name_long
        self.num_sensors = 9
        self.num_actions = 8
        self.action = np.zeros(self.num_actions)
        self.world_state = 0
        self.simple_state = 0
        self.world_visualize_period = 1e6
        self.brain_visualize_period = 1e3