Example #1
0
 def stop_drawing(self,pt,npt,cpt):
     parent_pt = find(self.ds_nodes[pt[0]][pt[1]])
     parent_npt = find(self.ds_nodes[npt[0]][npt[1]])
     parent_cpt = find(self.ds_nodes[cpt[0]][cpt[1]])
     
     if parent_npt == parent_cpt:
         return True
         
     if parent_pt != parent_npt and self.map[npt[0]][npt[1]].get_type() == FLOOR:
         return True
     else:
         return False
Example #2
0
    def __vet_door(self, r, c, _dir, _sqrs, start):
        _next_r = r + _dir[0]
        _next_c = c + _dir[1]

        if not self.__in_bounds(_next_r, _next_c):
            return False
        if self._map[_next_r][_next_c].get_type() != FLOOR:
            return False
        if find(start) == find(_sqrs[_next_r][_next_c]):
            return False

        return True
Example #3
0
 def __get_candidate(self, node):
     _candidates = []
     _nr = node.value[0]
     _nc = node.value[1]
     
     if self.in_bounds(_nr - 2, _nc) and self.map[_nr-1][_nc].get_type() == CYBERSPACE_WALL:
         _c_node = self.__ds_nodes[_nr/2-1][_nc/2]
         if find(_c_node) != find(node):
             _candidates.append((_c_node, _nr-1, _nc))
     if self.in_bounds(_nr + 2, _nc) and self.map[_nr+1][_nc].get_type() == CYBERSPACE_WALL:
         _c_node = self.__ds_nodes[_nr/2+1][_nc/2]
         if find(_c_node) != find(node):
             _candidates.append((_c_node, _nr+1, _nc))
     if self.in_bounds(_nr, _nc - 2) and self.map[_nr][_nc-1].get_type() == CYBERSPACE_WALL:
         _c_node = self.__ds_nodes[_nr/2][_nc/2-1]
         if find(_c_node) != find(node):
             _candidates.append((_c_node, _nr, _nc-1))
     if self.in_bounds(_nr, _nc + 2) and self.map[_nr][_nc+1].get_type() == CYBERSPACE_WALL:
         _c_node = self.__ds_nodes[_nr/2][_nc/2+1]
         if find(_c_node) != find(node):
             _candidates.append((_c_node, _nr, _nc+1))
     
     if len(_candidates) > 0:
         return choice(_candidates)
     else:
         return None 
Example #4
0
    def __look_ahead(self, _sqrs, _start, _dir, r, c):
        if self._map[r][c].get_type() == FLOOR:
            return True
    
        _next_r = r+_dir[0]
        _next_c = c+_dir[1]
        if not self.__in_bounds(_next_r, _next_c):
            return False
        
        if _next_r >= len(_sqrs) or _next_c >= len(_sqrs[0]):
            return False

        if find(_start) == find(_sqrs[_next_r][_next_c]):
            return True
        
        return False
Example #5
0
    def __check_for_short_hallway(self, r, c, _dir, _sqrs, start):
        _second_r = r + _dir[0]
        _second_c = c + _dir[1]
        _third_r = _second_r + _dir[0]
        _third_c = _second_c + _dir[1]

        if not self.__in_bounds(_second_r, _second_c) or not self.__in_bounds(_third_r, _third_c):
            return False
        if not self._map[_second_r][_second_c].get_type() == WALL:
            return False
        if not self._map[_third_r][_third_c].get_type() == FLOOR:
            return False
        if find(start) == find(_sqrs[_third_r][_third_c]):
            return False
    
        self._map[r][c] = self.__floor
        union(start, _sqrs[r][c])
        self._map[_second_r][_second_c] = self.__floor
        union(start, _sqrs[_second_r][_second_c])
        union(start, _sqrs[_third_r][_third_c])
    
        return True