python_data_scien/poc2/poc2_mini_proj_1.py
def move_humans(self, zombie_distance_field):
        """
        Function that moves humans away from zombies, diagonal moves
        are allowed
        """
        height = poc_grid.Grid.get_grid_height(self)
        width = poc_grid.Grid.get_grid_width(self)
        for idx in range(len(self._human_list)):
            i_duple = self._human_list[idx]
            max_dis = i_duple
            neighbor_cell_list = poc_grid.Grid.eight_neighbors(self,i_duple[0], i_duple[1])
            for neighbor_cell in neighbor_cell_list:
                if zombie_distance_field[neighbor_cell[0]][neighbor_cell[1]] != width*height and zombie_distance_field[neighbor_cell[0]][neighbor_cell[1]] > zombie_distance_field[max_dis[0]][max_dis[1]]:
                    max_dis = neighbor_cell
            
            if zombie_distance_field[max_dis[0]][max_dis[1]] == width*height:
                self._human_list[idx] = i_duple
                return
                    
            max_dis_list = []
            cell_list = list(neighbor_cell_list)
            cell_list.append(i_duple)
            for k_item in cell_list:
                if zombie_distance_field[k_item[0]][k_item[1]] == zombie_distance_field[max_dis[0]][max_dis[1]]:
                    max_dis_list.append((k_item[0],k_item[1]))
            #print max_dis_list
            my_choice = random.choice(max_dis_list)
            #print my_choice
            self._human_list[idx] = my_choice

        Function that moves humans away from zombies, diagonal moves
        are allowed
        
Function that moves humans away from zombies, diagonal moves
are allowed
Function that moves humans away from zombies diagonal moves are allowed
def move_humans(self, zombie_distance_field):
        height = poc_grid.Grid.get_grid_height(self)
        width = poc_grid.Grid.get_grid_width(self)
        for idx in range(len(self._human_list)):
            i_duple = self._human_list[idx]
            max_dis = i_duple
            neighbor_cell_list = poc_grid.Grid.eight_neighbors(self,i_duple[0], i_duple[1])
            for neighbor_cell in neighbor_cell_list:
                if zombie_distance_field[neighbor_cell[0]][neighbor_cell[1]] != width*height and zombie_distance_field[neighbor_cell[0]][neighbor_cell[1]] > zombie_distance_field[max_dis[0]][max_dis[1]]:
                    max_dis = neighbor_cell
            if zombie_distance_field[max_dis[0]][max_dis[1]] == width*height:
                self._human_list[idx] = i_duple
                return
            max_dis_list = []
            cell_list = list(neighbor_cell_list)
            cell_list.append(i_duple)
            for k_item in cell_list:
                if zombie_distance_field[k_item[0]][k_item[1]] == zombie_distance_field[max_dis[0]][max_dis[1]]:
                    max_dis_list.append((k_item[0],k_item[1]))
            my_choice = random.choice(max_dis_list)
            self._human_list[idx] = my_choice
def move_humans ( self , zombie_distance_field ) : height = poc_grid . Grid . get_grid_height ( self ) width = poc_grid . Grid . get_grid_width ( self ) for idx in range ( len ( self . _human_list ) ) : i_duple = self . _human_list [ idx ] max_dis = i_duple neighbor_cell_list = poc_grid . Grid . eight_neighbors ( self , i_duple [ 0 ] , i_duple [ 1 ] ) for neighbor_cell in neighbor_cell_list : if zombie_distance_field [ neighbor_cell [ 0 ] ] [ neighbor_cell [ 1 ] ] != width * height and zombie_distance_field [ neighbor_cell [ 0 ] ] [ neighbor_cell [ 1 ] ] > zombie_distance_field [ max_dis [ 0 ] ] [ max_dis [ 1 ] ] : max_dis = neighbor_cell if zombie_distance_field [ max_dis [ 0 ] ] [ max_dis [ 1 ] ] == width * height : self . _human_list [ idx ] = i_duple return max_dis_list = [ ] cell_list = list ( neighbor_cell_list ) cell_list . append ( i_duple ) for k_item in cell_list : if zombie_distance_field [ k_item [ 0 ] ] [ k_item [ 1 ] ] == zombie_distance_field [ max_dis [ 0 ] ] [ max_dis [ 1 ] ] : max_dis_list . append ( ( k_item [ 0 ] , k_item [ 1 ] ) ) my_choice = random . choice ( max_dis_list ) self . _human_list [ idx ] = my_choice
Function that moves humans away from zombies, diagonal moves
are allowed
Function that moves humans away from zombies diagonal moves are allowed
"""
        Function that moves humans away from zombies, diagonal moves
        are allowed
        """ #print max_dis_list
 #print my_choice

self
zombie_distance_field