private void digOut(final LayeredMap map,
                        Point p, Point dir, int range, Random rand)
    {
        if(range < 1) {
            return;
        }

        // System.err.println("Digging " + range + " squares.");

        final Point pos = new Point(p.x, p.y);

        for(int x=0; x<range; x++) {
            
            if(pos.x >= 1 && pos.y >= 1 && pos.x < map.getWidth() - 1 && pos.y < map.getHeight()-1) {
                map.set(1, pos.x, pos.y, 0);
            } else {
                // we would run off map ...
                return;
            }

            if(rand.nextInt(1000) < branchChance) {
                final Point side = new Point(dir.x, dir.y);

                if(rand.nextBoolean()) {
                    rot90l(side);
                } else {
                    rot90r(side);
                }

                digOut(map, pos, side, range/4 + rand.nextInt(range/5+1), rand);
            }

            pos.x += dir.x;
            pos.y += dir.y;
        }
    }