private void subsection ( TileBasedMap map , Space space , ArrayList spaces ) { if ( ! clear ( map , space ) ) { float width2 = space . getWidth ( ) / 2 ; float height2 = space . getHeight ( ) / 2 ; if ( ( width2 < smallestSpace ) && ( height2 < smallestSpace ) ) { return ; } subsection ( map , new Space ( space . getX ( ) , space . getY ( ) , width2 , height2 ) , spaces ) ; subsection ( map , new Space ( space . getX ( ) , space . getY ( ) + height2 , width2 , height2 ) , spaces ) ; subsection ( map , new Space ( space . getX ( ) + width2 , space . getY ( ) , width2 , height2 ) , spaces ) ; subsection ( map , new Space ( space . getX ( ) + width2 , space . getY ( ) + height2 , width2 , height2 ) , spaces ) ; } else { spaces . add ( space ) ; } }
Subsection a space into smaller spaces if required to find a non - blocked area .