python_data_scien/poc2/poc2_mini_proj_1.py
def compute_distance_field(self, entity_type):
        """
        Function computes and returns a 2D distance field
        Distance at member of entity_list is zero
        Shortest paths avoid obstacles and use four-way distances
        """
        height = poc_grid.Grid.get_grid_height(self)
        width = poc_grid.Grid.get_grid_width(self)

        visited = poc_grid.Grid(height,width)
        distance_field = [[width*height for dummy_col in range(width)] 
                       for dummy_row in range(height)]

        boundary = poc_queue.Queue()
        if entity_type == ZOMBIE:
            for item in self._zombie_list:
                boundary.enqueue(item)
        elif entity_type == HUMAN:
            for item in self._human_list:
                boundary.enqueue(item)
        else:
            print 'entity_type error in func:compute_distance_field!!!'
        for b_item in boundary:
            visited.set_full(b_item[0],b_item[1])
            distance_field[b_item[0]][b_item[1]] = 0

        while len(boundary) != 0:
            current_cell = boundary.dequeue()
            for neighbor_cell in poc_grid.Grid.four_neighbors(self,current_cell[0], current_cell[1]):
                if visited.is_empty(neighbor_cell[0],neighbor_cell[1]) and poc_grid.Grid.is_empty(self,neighbor_cell[0],neighbor_cell[1]):
                    visited.set_full(neighbor_cell[0],neighbor_cell[1])
                    boundary.enqueue(neighbor_cell)
                    distance_field[neighbor_cell[0]][neighbor_cell[1]] = distance_field[current_cell[0]][current_cell[1]] + 1
        #print distance_field
        return distance_field

        Function computes and returns a 2D distance field
        Distance at member of entity_list is zero
        Shortest paths avoid obstacles and use four-way distances
        
Function computes and returns a 2D distance field
Distance at member of entity_list is zero
Shortest paths avoid obstacles and use four-way distances
Function computes and returns a 2D distance field Distance at member of entity_list is zero Shortest paths avoid obstacles and use four - way distances
def compute_distance_field(self, entity_type):
        height = poc_grid.Grid.get_grid_height(self)
        width = poc_grid.Grid.get_grid_width(self)
        visited = poc_grid.Grid(height,width)
        distance_field = [[width*height for dummy_col in range(width)] 
                       for dummy_row in range(height)]
        boundary = poc_queue.Queue()
        if entity_type == ZOMBIE:
            for item in self._zombie_list:
                boundary.enqueue(item)
        elif entity_type == HUMAN:
            for item in self._human_list:
                boundary.enqueue(item)
        else:
            print 'entity_type error in func:compute_distance_field!!!'
        for b_item in boundary:
            visited.set_full(b_item[0],b_item[1])
            distance_field[b_item[0]][b_item[1]] = 0
        while len(boundary) != 0:
            current_cell = boundary.dequeue()
            for neighbor_cell in poc_grid.Grid.four_neighbors(self,current_cell[0], current_cell[1]):
                if visited.is_empty(neighbor_cell[0],neighbor_cell[1]) and poc_grid.Grid.is_empty(self,neighbor_cell[0],neighbor_cell[1]):
                    visited.set_full(neighbor_cell[0],neighbor_cell[1])
                    boundary.enqueue(neighbor_cell)
                    distance_field[neighbor_cell[0]][neighbor_cell[1]] = distance_field[current_cell[0]][current_cell[1]] + 1
        return distance_field
def compute_distance_field ( self , entity_type ) : height = poc_grid . Grid . get_grid_height ( self ) width = poc_grid . Grid . get_grid_width ( self ) visited = poc_grid . Grid ( height , width ) distance_field = [ [ width * height for dummy_col in range ( width ) ] for dummy_row in range ( height ) ] boundary = poc_queue . Queue ( ) if entity_type == ZOMBIE : for item in self . _zombie_list : boundary . enqueue ( item ) elif entity_type == HUMAN : for item in self . _human_list : boundary . enqueue ( item ) else : print 'entity_type error in func:compute_distance_field!!!' for b_item in boundary : visited . set_full ( b_item [ 0 ] , b_item [ 1 ] ) distance_field [ b_item [ 0 ] ] [ b_item [ 1 ] ] = 0 while len ( boundary ) != 0 : current_cell = boundary . dequeue ( ) for neighbor_cell in poc_grid . Grid . four_neighbors ( self , current_cell [ 0 ] , current_cell [ 1 ] ) : if visited . is_empty ( neighbor_cell [ 0 ] , neighbor_cell [ 1 ] ) and poc_grid . Grid . is_empty ( self , neighbor_cell [ 0 ] , neighbor_cell [ 1 ] ) : visited . set_full ( neighbor_cell [ 0 ] , neighbor_cell [ 1 ] ) boundary . enqueue ( neighbor_cell ) distance_field [ neighbor_cell [ 0 ] ] [ neighbor_cell [ 1 ] ] = distance_field [ current_cell [ 0 ] ] [ current_cell [ 1 ] ] + 1 return distance_field
Function computes and returns a 2D distance field
Distance at member of entity_list is zero
Shortest paths avoid obstacles and use four-way distances
Function computes and returns a 2D distance field Distance at member of entity_list is zero Shortest paths avoid obstacles and use four - way distances
"""
        Function computes and returns a 2D distance field
        Distance at member of entity_list is zero
        Shortest paths avoid obstacles and use four-way distances
        """ #print distance_field

self
entity_type