Enemy movement

Hi, I’ve founded this code from the game Taleban vs Robot


class Fish extends SJGSprite
{
    
    
    public void move()
        {
            if(count == 0)
            {
                int i = d;
                do
                    switch((int)(4D * Math.random()))
                    {
                    case 0: // '\0'
                        dx = 1;
                        dy = 0;
                        d = 0;
                        break;

                    case 1: // '\001'
                        dx = 0;
                        dy = 1;
                        d = 1;
                        break;

                    case 2: // '\002'
                        dx = -1;
                        dy = 0;
                        d = 2;
                        break;

                    case 3: // '\003'
                        dx = 0;
                        dy = -1;
                        d = 3;
                        break;
                    }
                while(!maze.canMove(this, getX() + dx, getY() + dy) || Math.random() > 0.10000000000000001D && d != i);
            }

the maze.canMove method is:


public boolean canMove(SJGSprite sjgsprite, double d1, double d2)
    {
        double d3 = sjgsprite.getWidth();
        double d4 = sjgsprite.getHeight();
        double d5 = d1 - d3 / 2D;
        double d6 = d2 - d4 / 2D;
        for(int i = Math.max((int)Math.floor(d5 / (double)blockWidth), 0); i <= Math.min((int)Math.floor(((d5 + d3) - 1.0D) / (double)blockWidth), width - 1); i++)
        {
            for(int j = Math.max((int)Math.floor(d6 / (double)blockHeight), 0); j <= Math.min((int)Math.floor(((d6 + d4) - 1.0D) / (double)blockHeight), height - 1); j++)
                if(maze[i][j].isSolid())
                    return false;

        }

        return true;
    }

what does mean this line code???


for(int j = Math.max((int)Math.floor(d6 / (double)blockHeight), 0); j <= Math.min((int)Math.floor(((d6 + d4) - 1.0D) / (double)blockHeight), height - 1); j++)

What do you think about this code??
Anyone know something better?