#NEWLINE# def _mazify_connected_shapes( self , entrance_space , border_spaces ) : #NEWLINE# #INDENT# for ( n_index , neighbor ) in entrance_space . neighbors ( ) : #NEWLINE# #INDENT# if ( neighbor is None ) : #NEWLINE# #INDENT# edge = entrance_space . edge ( n_index ) #NEWLINE# edge . viz_style = self . _PATH_STYLE #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# current_path = deque ( ) #NEWLINE# current_path . append ( entrance_space ) #NEWLINE# potential_exit_and_length = ( entrance_space , 1 ) #NEWLINE# space = entrance_space #NEWLINE# while current_path : #NEWLINE# #INDENT# space . viz_style = self . _FLOOR_STYLE #NEWLINE# for ( n_index , edge ) in space . edges ( randomize = True ) : #NEWLINE# #INDENT# if ( edge . viz_style != self . _WALL_STYLE ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# new_space = self . _grid . get ( n_index ) #NEWLINE# if ( new_space is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( not self . _has_paths ( new_space ) ) : #NEWLINE# #INDENT# edge . viz_style = self . _PATH_STYLE #NEWLINE# new_len = len ( current_path ) #NEWLINE# old_len = potential_exit_and_length [ 1 ] #NEWLINE# if ( ( new_len > old_len ) and ( new_space in border_spaces ) ) : #NEWLINE# #INDENT# potential_exit_and_length = ( new_space , new_len ) #NEWLINE# #UNINDENT# current_path . append ( space ) #NEWLINE# current_path . append ( new_space ) #NEWLINE# space = new_space #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# space = current_path . pop ( ) #NEWLINE# #UNINDENT# #UNINDENT# exit_space = potential_exit_and_length [ 0 ] #NEWLINE# for ( n_index , neighbor ) in exit_space . neighbors ( ) : #NEWLINE# #INDENT# if ( neighbor is None ) : #NEWLINE# #INDENT# edge = exit_space . edge ( n_index ) #NEWLINE# edge . viz_style = self . _PATH_STYLE #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# entrance_space . viz_style = self . _ENTRANCE_STYLE #NEWLINE# exit_space . viz_style = self . _EXIT_STYLE #NEWLINE# return ( entrance_space , old_len )